See previous thread
After two nights of wading through binary and thoroughly confusing my easts and wests I've now got a proper handle on the 'random' portion of a roaming walk. It's surprisingly simple, though devilishly difficult to figure - until you know how.
Every tile on the map is 'seeded' with an apparently random number which seems to be generated when the map is created and preserved when it is saved. These numbers are used for a variety of purposes, though I don't pretend to know all of them. In my last post on this subject I reported some of the effects of 'zeroing' the entire grid so as to negate the influence of those numbers on various game mechanisms.
I took this a step further. I ended up filling the 'random grid' of a custom 160x160 map with blocks of constant data, 32 tiles by 32. The first block was filled with zeros, the second with 1's, then 2's, 3's and so on. Apart from the rather pleasing cabbage-patch effect on the terrain I was thus able to run side-by-side tests and (eventually) unravel the mystery.
The four semi-cardinal directions in the game (NE, SE, SW, NW) are represented by the numbers 0 to 7, so that 0 or 1 is NE, 2 or 3 is SE, 4 or 5 is SW and 6 or 7 is NW. Since there are two numbers for each direction, I suppose it's possible that one of them might actually represent an in-between (cardinal) direction like North or West, but since the random part of a walk is confined to semi-cardinals (with rare exceptions) we can ignore that possibility.
Since we are using only the eight numbers 0 to 7, in computer terminology we are only interested in the last three bits of a number. We get this by taking the remainder after dividing by eight, so that 27 resolves to the number 3, the number 63 resolves to 7 and 80 resolves to 0 (Those three bits are the same as the ones used to determine where houses will merge). It so happens the same number determines the 'initial seeker' direction - the quadramble first executed by the labor seeker of a newly placed building depends on the result of divide-by-eight on the seed associated with the building's northern tile and in accordance with the number-to-direction relationships I itemised earlier.
StephAmon's "Ambulomancy" paper, a remarkable piece of deductive observation, gives us the means to predict a walker's path up to the end of its first 'outward-bound' phase. He coined a number of terms for different walker types. We need not concern ourselves with the 'distance-shorted' walker since it has no 'random' phase. The same goes for 'teleporting' walkers who do not return to their buildings after the outbound phase (schoolchildren and 'long distance' engineers, tax collectors and entertainers).
The 'grounded' walker travels in destination mode (using gardens if a shorter route is thereby provided) to a target tile (the algorithm for determining the target is beyond the scope of this post, but interested readers can refer to StephAmon's paper). A mode conversion takes place on the target tile, which becomes Tile #1 of the random walk which will continue (road-bound) for the normal default walk length (26 tiles for most walkers) from that point. He then returns home by the shortest route (using gardens if appropriate). A grounded walker need not be road-connected to his target if there is a garden path.
The 'blockage-shorted' walker travels in destination mode towards a target until it meets a gatehouse which prevents it from continuing. It then converts to random mode for the remainder of its normal walk length, following which it returns home (except that engineers, tax collectors and entertainers don't visibly return home). Tile #1 if the random phase of this walk type is the last walkable tile before the blockage. Note that destination mode walkers approaching a gatehouse 'sideways', i.e. on a road which passes along its front rather than meeting it square on, will attempt to enter it diagonally, so the last walkable tile is the one immediately before it:
The 'default' walker has no target and travels (almost) entirely in random mode. Tile #1 of his walk is the tile where he spawns (which, thanks to Brugle a long time ago, is also predictable).
All that was a rather long-winded way of determining where Tile #1 of the random phase is. This is important, because you cannot hope to predict a turn without knowing that. Neither, unfortunately, can you hope to predict it without knowing what value has been used to 'seed' the tile on which the intersection lies. That probably means finding the map coordinates (0,0 is the northern corner - x increments SE and y increments SW), working out the offset into the random grid and inspecting the value stored there.
Prediction is then just a simple matter of adding together the tile number (counting along the walker's path so far beginning at tile #1) and the 'random' seed. Divide by eight, take the remainder, and you have the direction he will take. And that's all there is to it
If the computed direction is unavailable the first available clockwise direction is taken, remembering that the direction he has come from, which may be the direction computed, is not available due to the 'no reversing' rule. That will not affect the outcome of the computation at the next intersection.
Example: Walker meets 4-way intersection on tile #7 of his walk. random 'seed' is 172. Total = 179. Remainder of divide-by=eight is 3. Walker will go SE (unless he is approaching from that direction, whereupon he will go SW).
Caveats:
(1) There seem to be exceptions to everything in this game, and I haven't exhaustively tested every walker. I wouldn't be surprised if one of those highly individual walker types breaks some rule somewhere.
(2) Targetted walkers thatundergo mode conversion in an intersection appear to follow the rules. Default walkers that spawn in an intersection are a little less reliable. Sometimes they do, sometimes they don't.
You can see how I arrived at my conclusions in my last post - given that the 'seed' was always zero, tile #1 carried an inherent NE disposition while walkers on tiles 2 and 3 wanted to go SE, and the direction cycles clockwise every second tile.
Since gleaning this knowledge I've been playing with traps that will ensnare some walkers and not others (good for keeping labor seekers in contact with housing). And it's not strictly necessary to get out the hex-editor either. The number associated with an intersection (or at least the important part of it - the last three bits) can usually be deduced by watching what existing walkers are doing prior to placing an important building. If one walker goes SE on Tile #6 the seed must be a 4 or a 5 (unless he is going that way because he can't go they way he really wants). Another walker going NW on tile #3 more or less confirms it's a 4.
One final area I'll be exploring - these 'seeds' are associated with certain terrain graphics. The graphic system is quite sophisticated and it's quite difficult to pick out one type once they are all mixed up and merged together, but if a sharp-eyed player can spot a tile in the landscape where he knows a house will/will not merge or he can deduce the direction seed from that tile's appearance, he would have an advantage.
I do hope I've not overlooked anything - I've made enough gaffs for one week
After two nights of wading through binary and thoroughly confusing my easts and wests I've now got a proper handle on the 'random' portion of a roaming walk. It's surprisingly simple, though devilishly difficult to figure - until you know how.
Every tile on the map is 'seeded' with an apparently random number which seems to be generated when the map is created and preserved when it is saved. These numbers are used for a variety of purposes, though I don't pretend to know all of them. In my last post on this subject I reported some of the effects of 'zeroing' the entire grid so as to negate the influence of those numbers on various game mechanisms.
I took this a step further. I ended up filling the 'random grid' of a custom 160x160 map with blocks of constant data, 32 tiles by 32. The first block was filled with zeros, the second with 1's, then 2's, 3's and so on. Apart from the rather pleasing cabbage-patch effect on the terrain I was thus able to run side-by-side tests and (eventually) unravel the mystery.
The four semi-cardinal directions in the game (NE, SE, SW, NW) are represented by the numbers 0 to 7, so that 0 or 1 is NE, 2 or 3 is SE, 4 or 5 is SW and 6 or 7 is NW. Since there are two numbers for each direction, I suppose it's possible that one of them might actually represent an in-between (cardinal) direction like North or West, but since the random part of a walk is confined to semi-cardinals (with rare exceptions) we can ignore that possibility.
Since we are using only the eight numbers 0 to 7, in computer terminology we are only interested in the last three bits of a number. We get this by taking the remainder after dividing by eight, so that 27 resolves to the number 3, the number 63 resolves to 7 and 80 resolves to 0 (Those three bits are the same as the ones used to determine where houses will merge). It so happens the same number determines the 'initial seeker' direction - the quadramble first executed by the labor seeker of a newly placed building depends on the result of divide-by-eight on the seed associated with the building's northern tile and in accordance with the number-to-direction relationships I itemised earlier.
StephAmon's "Ambulomancy" paper, a remarkable piece of deductive observation, gives us the means to predict a walker's path up to the end of its first 'outward-bound' phase. He coined a number of terms for different walker types. We need not concern ourselves with the 'distance-shorted' walker since it has no 'random' phase. The same goes for 'teleporting' walkers who do not return to their buildings after the outbound phase (schoolchildren and 'long distance' engineers, tax collectors and entertainers).
The 'grounded' walker travels in destination mode (using gardens if a shorter route is thereby provided) to a target tile (the algorithm for determining the target is beyond the scope of this post, but interested readers can refer to StephAmon's paper). A mode conversion takes place on the target tile, which becomes Tile #1 of the random walk which will continue (road-bound) for the normal default walk length (26 tiles for most walkers) from that point. He then returns home by the shortest route (using gardens if appropriate). A grounded walker need not be road-connected to his target if there is a garden path.
The 'blockage-shorted' walker travels in destination mode towards a target until it meets a gatehouse which prevents it from continuing. It then converts to random mode for the remainder of its normal walk length, following which it returns home (except that engineers, tax collectors and entertainers don't visibly return home). Tile #1 if the random phase of this walk type is the last walkable tile before the blockage. Note that destination mode walkers approaching a gatehouse 'sideways', i.e. on a road which passes along its front rather than meeting it square on, will attempt to enter it diagonally, so the last walkable tile is the one immediately before it:
GGRRRRRRR
GGR
*
R
R
The asterisk marks the conversion point for walkers coming up along the vertical road.The 'default' walker has no target and travels (almost) entirely in random mode. Tile #1 of his walk is the tile where he spawns (which, thanks to Brugle a long time ago, is also predictable).
All that was a rather long-winded way of determining where Tile #1 of the random phase is. This is important, because you cannot hope to predict a turn without knowing that. Neither, unfortunately, can you hope to predict it without knowing what value has been used to 'seed' the tile on which the intersection lies. That probably means finding the map coordinates (0,0 is the northern corner - x increments SE and y increments SW), working out the offset into the random grid and inspecting the value stored there.
Prediction is then just a simple matter of adding together the tile number (counting along the walker's path so far beginning at tile #1) and the 'random' seed. Divide by eight, take the remainder, and you have the direction he will take. And that's all there is to it
If the computed direction is unavailable the first available clockwise direction is taken, remembering that the direction he has come from, which may be the direction computed, is not available due to the 'no reversing' rule. That will not affect the outcome of the computation at the next intersection.
Example: Walker meets 4-way intersection on tile #7 of his walk. random 'seed' is 172. Total = 179. Remainder of divide-by=eight is 3. Walker will go SE (unless he is approaching from that direction, whereupon he will go SW).
Caveats:
(1) There seem to be exceptions to everything in this game, and I haven't exhaustively tested every walker. I wouldn't be surprised if one of those highly individual walker types breaks some rule somewhere.
(2) Targetted walkers that
You can see how I arrived at my conclusions in my last post - given that the 'seed' was always zero, tile #1 carried an inherent NE disposition while walkers on tiles 2 and 3 wanted to go SE, and the direction cycles clockwise every second tile.
Since gleaning this knowledge I've been playing with traps that will ensnare some walkers and not others (good for keeping labor seekers in contact with housing). And it's not strictly necessary to get out the hex-editor either. The number associated with an intersection (or at least the important part of it - the last three bits) can usually be deduced by watching what existing walkers are doing prior to placing an important building. If one walker goes SE on Tile #6 the seed must be a 4 or a 5 (unless he is going that way because he can't go they way he really wants). Another walker going NW on tile #3 more or less confirms it's a 4.
One final area I'll be exploring - these 'seeds' are associated with certain terrain graphics. The graphic system is quite sophisticated and it's quite difficult to pick out one type once they are all mixed up and merged together, but if a sharp-eyed player can spot a tile in the landscape where he knows a house will/will not merge or he can deduce the direction seed from that tile's appearance, he would have an advantage.
I do hope I've not overlooked anything - I've made enough gaffs for one week
[This message has been edited by Trium3 (edited 06-24-2008 @ 11:18 PM).]