Module wumpus

Description

Cat's Eye Technologies' Erlang Wumpus.

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:

Function Index

Exported Functions
game/0Provides the main user interface to the Hunt the Wumpus game.
start/0See game/0.
Internal Documented Functions
game/1Provides the main loop for the Hunt the Wumpus game.
get_shot/0Asks the player for three caves to shoot through.
move/1Provides the player's move-or-shoot interface as part of the game loop whenever no hazard is interfering with game-play.
random_vertex/1Picks a random vertex from the given graph.
random_vertex/2Picks any random vertex except the given one from the given graph.
shoot/1Provides the player's shoot sequence.
shoot/3Actually shoots the arrow.
vertex/1Returns a vertex given a vertex ID.
vertex_ids/2Returns a list of vertex ID's from a list of vertices in a graph().

Exported Functions

game/0

game() -> quit

Provides the main user interface to the Hunt the Wumpus game. game/0 initializes everything for the main loop, game/1.

start/0

start() -> quit

Equivalent to game().

Documented Internal Functions

game/1

game(quit | game_state()) -> quit | game_state()

Provides the main loop for the Hunt the Wumpus game.

get_shot/0

get_shot() -> [integer()]

Asks the player for three caves to shoot through. Returns the list.

move/1

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/1

random_vertex(graph()) -> vertex()

Picks a random vertex from the given graph.

random_vertex/2

random_vertex(graph(), vertex()) -> vertex()

Picks any random vertex except the given one from the given graph.

shoot/1

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/3

shoot(game_state(), [integer()], integer()) -> shoot_outcome()

Actually shoots the arrow. Returns an atom describing the consequences.

vertex/1

vertex(integer()) -> vertex()

Returns a vertex given a vertex ID.

vertex_ids/2

vertex_ids(graph(), [vertex()]) -> [integer()]

Returns a list of vertex ID's from a list of vertices in a graph().