This is an implementation of Gregory Yob's classic game of Hunt the Wumpus.
This version is not wholly faithful to the original. It is primarily intended for example purposes. Notably, the Wumpus does not move at all. Also, messages may be less than thrilling.
As an example program, Erlang Wumpus demonstrates:
random
module digraph
module case catch N
to catch errors Exported Functions | |
---|---|
game/0 | Provides the main user interface to the Hunt the Wumpus game. |
start/0 | See game/0 . |
Internal Documented Functions | |
game/1 | Provides the main loop for the Hunt the Wumpus game. |
get_shot/0 | Asks the player for three caves to shoot through. |
move/1 | Provides the player's move-or-shoot interface as part of the game loop whenever no hazard is interfering with game-play. |
random_vertex/1 | Picks a random vertex from the given graph. |
random_vertex/2 | Picks any random vertex except the given one from the given graph. |
shoot/1 | Provides the player's shoot sequence. |
shoot/3 | Actually shoots the arrow. |
vertex/1 | Returns a vertex given a vertex ID. |
vertex_ids/2 | Returns a list of vertex ID's from a list of vertices in a graph(). |
game() -> quit
Provides the main user interface to the Hunt the Wumpus game. game/0 initializes everything for the main loop, game/1.
start() -> quit
Equivalent to game()
.
game(quit | game_state()) -> quit | game_state()
Provides the main loop for the Hunt the Wumpus game.
get_shot() -> [integer()]
Asks the player for three caves to shoot through. Returns the list.
move(game_state()) -> game_state()
Provides the player's move-or-shoot interface as part of the game loop whenever no hazard is interfering with game-play.
random_vertex(graph()) -> vertex()
Picks a random vertex from the given graph.
random_vertex(graph(), vertex()) -> vertex()
Picks any random vertex except the given one from the given graph.
shoot(game_state()) -> game_state()
Provides the player's shoot sequence. This function uses get_shot/0 to ask for a list of three caves into which the Crooked Arrow(tm) will be shot, and then uses shoot/3 to determine the outcome.
shoot(game_state(), [integer()], integer()) -> shoot_outcome()
Actually shoots the arrow. Returns an atom describing the consequences.
vertex(integer()) -> vertex()
Returns a vertex given a vertex ID.
vertex_ids(graph(), [vertex()]) -> [integer()]
Returns a list of vertex ID's from a list of vertices in a graph().