Hunt The Wumpus.

This is a discussion on Hunt The Wumpus. within the C++ Programming forums, part of the General Programming Boards category; Hey, I'm going to have a go at coding the 1970's game Hunt The Wumpus today which is an exercise ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    329

    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. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    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. #3
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    Didn't your book give you any hint?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Quote Originally Posted by siavoshkc View Post
    Didn't your book give you any hint?
    Ha, no. Just the rules of the game.

  5. #5
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    When a book provides an exercise its usually for a recent topic. For example arrays.
    Go ahead and implement whats in your mind.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  6. #6
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    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.
    Last edited by darren78; 07-29-2010 at 08:30 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Substring hunt and gather
    By reRanger in forum C++ Programming
    Replies: 5
    Last Post: 11-23-2004, 01:56 PM
  2. what was your first game?
    By jverkoey in forum Game Programming
    Replies: 36
    Last Post: 03-03-2003, 06:22 PM
  3. Treasure hunt
    By bia_as in forum C Programming
    Replies: 2
    Last Post: 12-06-2002, 04:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21