# # # # # # # # #
@ 1 2 3 4 5 6 m #
# # # # # 6 # # #
# 7 #
Then it says:
"Multiply every value in the map by a negative number somewhere in the neighborhood of -1.2"
# # # # # # # # #
@ -1.2 -2.4 -3.6 -4.8 -6 -7.2 m #
# # # # # -7.2 # # #
# -8.4 #
"Take the result and pass it back through the Dijkstra scanning function. "
That's what I am stuck on. The scanning function involves:
"If any floor tile has a value that is at least 2 greater than its lowest-value floor neighbor, set it to be exactly 1 greater than its lowest value neighbor."
But how will that ever be true? How will any tile be at least 2 greater than its lowest-value floor neighbour when I have multiplied them all by 1.2?
As it stands the monkey is just going to sit in that dead end as the player approaches rather than jump out and flee to the south.
I suspect I've misread something and got the wrong end of the stick concerning the -1.2 multiplication and the rescan. But I've read it again and again and nothing springs to mind.
Stick to integers when you multiply by -1.2. That is, multiply by -6 and then divide by 5, dropping any decimals as usual in integer math.
Let's change the diagram to demonstrate, by moving the player and extending that corridor:
# # # # # # # # #
-4.8 -3.6 -2.4 -1.2 @ -1.2 -2.4 m # (monkey is at -3.6)
# # # # # -2.4 # # #
# -3.6 # (the scale is a little stretched here)
# -4.8 -6.0 -7.2 -8.4 -9.6 -10.8 -12.0 -13.2 -14.4 -15.6 -16.8 -18.0 #
Which is actually this, since we're dealing with integers only:
# # # # # # # # #
-4 -3 -2 -1 @ -1 -2 m # (monkey is at -3)
# # # # # -2 # # #
# -3 #
# -4 -6 -7 -8 -9 -10 -12 -13 -14 -15 -16 -18 #
And which turns into this once you run the scan again:
# # # # # # # # #
-4 -3 -2 -2 @ -4 -3 m # (monkey's tile is now -2)
# # # # # -5 # # #
# -6 #
# -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 #
Now you can kinda see what the multiplier does as the distances grow. Parts of the dungeon that are very far from the player will look more attractive - in this diagram, the monkey would now make a break for it because that -3 is lower than the monkey's current -2 (and therefore safer).
Notice, in the above diagram, what would happen if we had cut the corridor off 1 tile earlier. The tile that ended up as -17 would be -16 instead, and the floor right next to the monkey would be -2. The monkey wouldn't have a lower tile to step to. What if we want the monkey to run sooner, or with less space? The next diagram shows what happens if we increase the -1.2 multiplier to -1.5:
# # # # # # # # #
@ -1 -3 -4 -6 -7 -9 m # (monkey's tile is -10)
# # # # # -9 # # #
# -10 #
# -12 -13 -15 -16 -18 -19 -21 -22 -24 -25 -27 -28 #
And the final result:
# # # # # # # # #
@ -10 -11 -12 -13 -14 -13 m # (monkey's tile is -12)
# # # # # -15 # # #
# -16 #
# -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 #
The monkey was just barely deciding to flee before (-3 vs -2) - even though the player was much closer in that instance! - but with a bigger multiplier, the monkey will start fleeing much sooner.
Hope this helps. Good luck.