ID:262344
 
Code:
        proc/dirprob(list/L)
var/dirmap/md = new(movedir) // set dir mapping
world.log << "running dirprob() function."
del(md)
return pick(L)
/*
if(L.len==5)
return pick(
prob(md.Get(N))
N,
prob(md.Get(E))
E,
prob(md.Get(W))
W,
prob(md.Get(NE))
NE,
prob(md.Get(NW))
NW
)
return pick(
prob(md.Get(N))
N,
prob(md.Get(S))
S,
prob(md.Get(E))
E,
prob(md.Get(W))
W,
prob(md.Get(NE))
NE,
prob(md.Get(NW))
NW,
prob(md.Get(SE))
SE,
prob(md.Get(SW))
SW
)
*/


dirmap
var
headpos
list/dirs = new/list(N,NE,E,SE,S,SW,W,NW)
list/propability = new/list(Np=100,NEp=100,Ep=100,SEp=100,Sp=100,SWp=100,Wp=100,NWp=100)
New(var/d)
// headpos = dirs.Find(d)
world.log << "headpos = [headpos]."
// MapProb()
// Span()
proc/Get(dir)
var/pos = dirs.Find(dir)
return propability[pos]
proc/MapProb()
propability[headpos] += 30
propability[shiftb()] += 25
propability[shiftf()] += 25
propability[shiftb(3)] -= 35
propability[shiftf(3)] -= 35
proc/shiftb(num=1)
var/counter=0
var/headque=headpos
while(counter<num)
headque--
counter++
if(headque<1)
headque=8
return headque
proc/shiftf(num=1)
var/counter=0
var/headque=headpos
while(counter<num)
headque++
counter++
if(headque>8)
headque=1
return headque
proc/Span()
propability[1] -= 25
propability[3] += 25
propability[5] -= 25
propability[7] += 25


Problem description:

Ok when I run the code it freezes. Im guessing an infinte loop of some kind. The line var/dirmap/md = new(movedir) // set dir mapping is what is causing it. How I am not too sure of. But I have commented this line of code out and it worked fine.

If you need more of my code I will post it just say so.