Rush Hour is a board game, where there are some cars in a parking lot, in a random position, your goal is to find a path (by moving other cars horizontally or vertically) to exit the parking lot.
For detailed description check the link below: http://en.wikipedia.org/wiki/Rush_Hour_(board_game)
I would start by making a function to draw an empty parking lot. Then make a container (array, vector, whatever) to describe whether or not there is a car in a space. Implement this container in the first function so that the board is always drawn correctly. Then write a function to seed the container with random cars. Figure out a good way to have the user enter a car that he/she wishes to move, and then move that car (while makeing sure the choice of car and direction of moving are valid).
Once the board and user input is done correctly, I would start programming the rules of the game.
Can I use struct in order to draw an empty parking lot? and should I put the container in the the struct? I need help.
Can somebody write a sample to draw an empty parking lot? I am a bit confused..
Thanks for any help.
Thanks Lowestone, it helped me a lot, but there is an issue popped up, if I want to draw a 6x6 matrix-like parking lot and insert some cars in randomly horizontally or vertically, probably I will need some more complicated code, will 2D Array help me in that?
Thanks in advance.
It might. I don't think I would do that though, but that is because the way I set it up. My parking lot is not drawn in a loop, so I'm typing the actual index of the array every time. Having it be 2d might make that more complicated.
Also, think about the way that you are randomly making cars, 1d array is easy:
1 2 3 4
for (int i = 0; i < SIZE_OF_ARRAY; i++)
if (aRandomResultIsTrue()) spaces[i] = '*';
not as easy with 2d.
It's up you though, somethings are easier, somethings might take some thinking.