« first day (2072 days earlier)      last day (1563 days later) » 

THZ
4:35 PM
Is asking for help banned here?
 
@THZ no, just ask
 
THZ
well, I need to write down an algorithm but I can't reach a decent solution
shouldn't be anything too hard just a school project
 
@THZ well, what kind of algorithm are we talking about here? :}
 
THZ
you guys know the Pacman game I guess?
 
Well, it's classics...
 
THZ
4:45 PM
good. So, I am writing an algorithm for the ghosts movement
nothing complex, just the way they move around the map
like take a direction, keep it untill you find a wall
 
sounds neat - what's the problem?
 
THZ
the way I wrote it down, the ghosts never reach some parts of the map
seems like it's not so random even if it should hum
 
what it does when it finds a wall?
 
THZ
I think I should show you the code maybe
I've left out some other parts because otherwise it would be too long
this one sorry
 
5:05 PM
I think it'd be better if you could explain the flow of the program
 
THZ
well it's more a matter of actual code and not about the flow of the program
the wrong part is when the ghost can chose between more than 1 direction
 
umh, perhaps you could keep like a record of the directions of a ghost
so In case you go DIR_UP and then you have to random the direction again
if its DIR_DOWN, then you just random it again
so this way you won't go back the same path
unless its the only way
 
THZ
well that's what it does already
that switch construct, checks if the next position for each of the four is a wall, and if it's not it tells it's an available direction
and the one is randomly chosen by the available ones
 
5:23 PM
I'm talking about when you random the direction
you are just checking for the next direction
nextDir=ChoseDir(ghostPos, map);
 
THZ
you mean into the choseDir function?
oh
 
lets say, for instance, the current direction its DIR_UP and it moves up until it finds a wall
 
THZ
if you check, it gives the next round direction
 
and lets assume that at the wall there are 3 possible directions
left, down and right
now when it randoms into down
you check the previous direction if it was up
 
THZ
i think you missed this:
if (flag==1){
chosenDir=nextDir;
 
5:26 PM
so this way you have unique paths
 
THZ
flag==1 means that a direction has been chosen
 
yeh but next dir could be the opposite of chosenDir
so you just went back the same direction you came
 
THZ
yeah that's not a problem. I mean, if the ghost is going UP, find a wall, he can chose back to go DOWN
 
this could lead to a lot of loops tho
 
THZ
let's assume that the ghost is going UP; he goes up till he finds a wall; now, he find that LEFT and DOWN are available, he randomly choose one, and takes it till he find another wall
 
5:31 PM
yeah but wouldn't be nicer if it would take it left
so this way it covers the entire map
 
THZ
it can take left yeah, but it's chosen randomly
i don't want anything too complicate to be honest. and my code looks already like spaghetti code
that's why I'm asking for help, I just can't write down a clean and simple solution :(
 
guess we could get rid of those if statements inside the switch and put one outside
and check if the current position is a wall
if it is, then generate a random direction
 
THZ
by current, you mean the next one?
 
current
 
THZ
like, he's going UP, and checks if map[y+1] is a wall?
his current position would't ever be something different than a blank space
wouldn't*
 
 
5 hours later…
11:07 PM
0
Q: OSERR: Cannot load library xxx, module cannot be found?

heisthereI tried to call a py file with pypy3, which import a dll that I wrote in c. The first version of the dll (x86) file did not include threads, that worked just fine under pypy3. With the second version I employed threads, then this Error raised. (I tested the code before it was made to a dll file...

 

« first day (2072 days earlier)      last day (1563 days later) »