Hunt the Wumpus "Python Code"

Source: Internet
Author: User

1  fromRandomImportChoice2 3Cave_numbers = Range (1,21)4Wumpus_location =Choice (cave_numbers)5Player_location =Choice (cave_numbers)6  whilePlayer_location = =wumpus_location:7Player_location =Choice (cave_numbers)8 9 Print "Welcome to Hunt the wumpus!"Ten Print "can see", Len (caves),"Caves" One Print "to play, just type the number" A Print "Of the Cave you wish to enter next" -  -  while1: the     Print "You is in cave", Player_location -     if(Player_location = = Wumpus_location-1or -Player_location = = wumpus_location + 1): -         Print "I smell a wumpus!" +  -     Print "which cave next?" +Player_input = Raw_input (">") A     if( notPlayer_input.isdigit ()or  atInt (player_input) not inchcave_numbers): -         PrintPlayer_input,"Is isn't a cave that I can see!" -  -     Else: -Player_location =Int (player_input) -         ifPlayer_location = =wumpus_location: in             Print "aargh! Got eaten by a wumpus!" -              Break

<from wikipedia>

     Hunt the wumpus is an important early computer games . He is based on a simple hidden/search form that has a mysterious monster (Wumpus), sneaking around the room's network. Players can use command-line text interface, by entering instructions to move in the room, or archery along a curved path in several adjoining rooms. There are 20 rooms, each with an additional three connected, arranged like a dodecahedron Vertex (or a icosahedron 's face). The possible dangers are: The Super Bat (which throws the player in any position) and Wumpus. When the player infers the room of the wumpus from the hint and does not enter, and shoots an arrow in the room to kill him. However, if the wrong room is fired, the Wumpus will be alerted, and he will devour the player.

The game was originally written by Gregory yob using BASIC .

A simplified version of the game has also become a classic example of the concept of a description (a computer program) in the field of Artificial intelligence . (Artificial intelligence is often used to simulate a player's character)

The first little game code that you learned today, you see the small error inside?

Come on! To is a pythoner.

Hunt the Wumpus "Python Code"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.