Challenge #5

Frodo & The Lord of the Rings Game!

Can you help Frodo escape from the dark forest and avoid the Dark Riders? Write the computer game!

Frodo is trapped in the Dark Forest (a 10 by 10 grid). Each turn, the player can choose which way he should move – either up, down, left, right or diagonally (1,2,3,4,6,7,8,9). So long as he stays inside the forest. His objective is to reach the Exit (E). Meanwhile there are Dark Riders (R) trying to capture Frodo, which begin in random squares. The riders can only see the squares around them, so if Frodo is next to them, they will move to his square and kill him – if he is not next to them, they will move randomly. On level 1, there are 3 riders, but if Frodo makes it to the Exit, he will enter level 2, which has 6 riders. There are 10 levels in total, and each level adds 3 new Riders.

Of course Frodo has the ring, which he can use once per level, to become invisible and quickly move 3 times while the Riders are frozen.