The game appears as a 5-by-5 board, where one "X" barrier is randomly placed on each row of the board. The player's "*"-marker is placed on the upper left square of the board. (Obviously, the barrier placed in the top row of the board must not be in the same leftmost square!) The object of the game is to move the "*"-marker to the board's lower right corner in as few moves as possible. A square can be occupied at most once, and once the "*"-marker leaves a square, the square is filled by an "X". The game ends either when the player ``wins'' by moving the "*" to the lower right corner or when the player ``loses'' when the "*" is blocked and cannot move further. The program must announce when the player wins, but it is not required that the program announce when a player is blocked and loses.
Here is an example of the initial state of the maze:
$ Maze Moves: 0 * _ X _ _ _ X _ _ _ _ X _ _ _ _ _ _ X _ _ _ X _ _ Type a move (l,r,u,d):Perhaps the player types d to moves down:
Type a move (l,r,u,d): d Moves: 1 Moves: 2 X _ X _ _ and then down again: X _ X _ _ * X _ _ _ X X _ _ _ _ X _ _ _ * X _ _ _ _ _ _ X _ _ _ _ X _ _ _ X _ _ _ _ X _ _ Type a move (l,r,u,d): d Type a move (l,r,u,d): dand again:
Moves: 3 Moves: 4 X _ X _ _ and then right: X _ X _ _ X X _ _ _ X X _ _ _ X X _ _ _ X X _ _ _ * _ _ X _ X * _ X _ _ _ X _ _ _ _ X _ _ Type a move (l,r,u,d): r Type a move (l,r,u,d):The game must prohibit illegal moves (e.g., from the last configuration, a move upwards ("u") is illegal, and it must announce when the player wins.
string[] maze = new string[MAZE_SIZE];This data structure uses the techniques you developed in lab. (See the sample solution posted on the CIS200 Assignments web page.) The second choice is a two-dimensional array:
string[,] maze = new string[ROW_SIZE,ROW_SIZE];
To generate random numbers in C#, do this:
Random ran = new Random() // construct the random-number generator object ... int LOWER = 1; int UPPER = 10; ... int random_num = ran.Next(LOWER, UPPER); // assign to random_num a randomly // generated int in the range, LOWER..(UPPER-1). // Reuse this command as often as needed.
Use the web page at http://www.cis.ksu.edu/~schmidt/200s08/Assign to submit your program, Maze.cs.