My general approach to this sort of thing is to try to design right from the start in a way that doesn't depend on non-deterministic details of implementation. (Well, conceptually nondeterministic, that is; obviously it's not literally nondeterministic. But if someone else trying to implement the same rules will be forced to mimic your internal storage and enumeration algorithms instead of being free to use one of their choice, it's bad enough.)
So in this case, I'd have arranged for all the characters to move as if simultaneously, with the possible exception of the human-controlled character moving before or after the computer-controlled ones. That is, each Pooh thinks independently and works out which square they'd like to move to, and then if no two Poohs' target squares clash they can all move as they'd planned, and if they do then both the Poohs who were aimed at that target square have to do something different.
(Or alternatively there could be a fixed rule that says which one wins: the Poohs could carry around invisible priority numbers on their foreheads, or the rule could be that a Pooh moving downward into a square beats one moving sideways or upwards, or something else. But it should be fixed by some reasonably simple and externally trackable property of the Poohs rather than fiddly implementation details such as which one happened to end up first in a hash table or linked list.)
I'm generally not a fan of processing things in an explicit order if I don't absolutely have to. I like simultaneity; it's easier to prove things about.
no subject
Date: 2006-12-30 02:38 pm (UTC)So in this case, I'd have arranged for all the characters to move as if simultaneously, with the possible exception of the human-controlled character moving before or after the computer-controlled ones. That is, each Pooh thinks independently and works out which square they'd like to move to, and then if no two Poohs' target squares clash they can all move as they'd planned, and if they do then both the Poohs who were aimed at that target square have to do something different.
(Or alternatively there could be a fixed rule that says which one wins: the Poohs could carry around invisible priority numbers on their foreheads, or the rule could be that a Pooh moving downward into a square beats one moving sideways or upwards, or something else. But it should be fixed by some reasonably simple and externally trackable property of the Poohs rather than fiddly implementation details such as which one happened to end up first in a hash table or linked list.)
I'm generally not a fan of processing things in an explicit order if I don't absolutely have to. I like simultaneity; it's easier to prove things about.