2012-08-28

Arduino LCD: Hunt the Wumpus Conversion

This week I recreated an old text game that I remember as a kid in the '80s: Hunt the Wumpus. The game is apparently from 1971. Basically you wander around a map trying not to fall into a pit trap or get eaten by the wumpus. You win by shooting the wumpus - but don't shoot yourself!

Code: http://eturnerx.com/files/arduino/003_wumpus_hunt_eturnerx_arduino_lcd.html

The map is a squashed Dodecahedron. Arranged into three rings. The inner and outer rings have five rooms while the ring between them has ten rooms. Every room links to exactly three others; back and forth on the current ring and another to change the ring. While the interconnections in the map never change, my version of the game scrambles the room names whenever a new map is generated (on power up or when selected at game over). A new map also randomises the starting positions of the player, the pit, the bats and the wumpus.

Shots can travel up to five rooms, but can only travel into rooms that you have already visited and or have been one room away from. It is possible to shoot yourself.

The implementation uses a state machine in the main loop. It's a pretty big one but things don't seem to get out of hand. That's why I love the state machine approach; it allows the programmer to think of the overall structure but then just concentrate on the single task they were working on. For a much simpler state machine check out the previous video.

Checkout the other games I have converted

No comments:

Post a Comment