1. ## Hunt The Wumpus.

Hey,

I'm going to have a go at coding the 1970's game Hunt The Wumpus today which is an exercise from the book I am using. Just a quick question before I get started. The game relies on interconnecting rooms that can be navigated using the number keys.

If I want say 20 rooms, I was thinking of having a 6x6 vector for 36 elements, randomly assigning numbers 1-20 to them and setting the others to 0 indicating that you cannot select them (enter that room as it doesn't exist). Obviously I will have to ensure 1-20 are connected. Would this be the correct way to set up the gameboard?

Thanks,

Darren.

2. Edit: What I may actually do is create 5 or 6 static game boards and then use a random generator to select a new gameboard for each game. I van then build on that. Babysteps.......

3. Didn't your book give you any hint?

4. Originally Posted by siavoshkc
Didn't your book give you any hint?
Ha, no. Just the rules of the game.

5. When a book provides an exercise its usually for a recent topic. For example arrays.

6. Okay, so I have started on this and I have created the game board and can move around it fairly normally now.

My problem lies when checking for adjacent rooms. I have designed a 6x6 vector holding 17 numbered rooms. All other elements are initialised to 0. When I want to move, I need to print out all the adjacent rooms. My problem is, what if the room I am currently in is on the border of the 2d space and if the adjacent elements are set to 0.

The code that I am thinking of writing to check this seems extremely verbose and long winded, as I need to check for i!=0, i!=5, j!=0, j!-d, [i+1 != 0 || i-1 ! = 0|| j-1 != 0|| j+1 != 0]

Hope you can understand this. Is there an easy way to move around a maze in a 2d vector?

Thanks

Edit: Figured it out.