473,842 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I have problems with creating the classic game Wumpus. the file:

Im trying to create a version of the game Wumpus. Mine is called
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
some one help me??
here is the file:
http://esnips.com/webfolder/b71bfe95...d-39999a9e36d0

What i have the biggest problems with now is between line 8 and 23.
How i can move the character trough the game. Other parts of the game
that have with the movement to do is between line 83-114 and 123-143.

This is part of the spec:
"The player walks around in the hallways, finds and tries to kill
Wumpus (Belzebub). The game finishes when the player or Belzebub dies.
The player has bombs which he can shoot. When he shoots he can
controll th ebombs for three moves, north, south, east or west three
times. If he is not careful he can shoot himself, ex first move:
north. second move south.
Let every room be represented by the object room. In the object,
information of what exists in the room is stored. (Belzebub,
teleporters, fire traps, acid traps or nothing). and where the
halways leads. (north hallway leads to room 17, the east to room 2
etc.). Create a list of room objects to represent the hallways (every
room have has a number).
The content of the rooms shall be randomized in the beginning of
the program. Aproximatly 20% of the rooms should contain traps, 30%
should contain teleporters and in one of the rooms is Belzebub. One
room can not contain more than one danger, no traps and teleporters
together etc.
Teleporters transports the player from one room to another
random room. If the player encounters a trap o Belzebub he is killed
and GAME OVER.
The halways should also be randomized in the beginning of the
program. Like this:

* Create a list with all the room numbers and shuffle it so all of
the rooms is in a mixed order. ex. [5 2 12 18 9 1 3 6 14 19 11 7 17 4
20 16 10 15 8 13]

* Connect the rooms in east-west direction so that the east hallway
from room 5 leads to room 2 and the west hallway from room to leads
back to room 5 etc. The last room in the lest should be connected
with the first.

* Shuffle a new list and do the same thing in north-south direction.

Once again the file: http://esnips.com/webfolder/b71bfe95-d363-4dd3-
bfad-39999a9e36d0

Apr 25 '06 #1
10 2102

connyledin wrote:
Im trying to create a version of the game Wumpus. Mine is called
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
some one help me??
here is the file:
http://esnips.com/webfolder/b71bfe95...d-39999a9e36d0

What i have the biggest problems with now is between line 8 and 23.
How i can move the character trough the game. Other parts of the game
that have with the movement to do is between line 83-114 and 123-143.

This is part of the spec:
"The player walks around in the hallways, finds and tries to kill
Wumpus (Belzebub). The game finishes when the player or Belzebub dies.
The player has bombs which he can shoot. When he shoots he can
controll th ebombs for three moves, north, south, east or west three
times. If he is not careful he can shoot himself, ex first move:
north. second move south.
Let every room be represented by the object room. In the object,
information of what exists in the room is stored. (Belzebub,
teleporters, fire traps, acid traps or nothing). and where the
halways leads. (north hallway leads to room 17, the east to room 2
etc.). Create a list of room objects to represent the hallways (every
room have has a number).
The content of the rooms shall be randomized in the beginning of
the program. Aproximatly 20% of the rooms should contain traps, 30%
should contain teleporters and in one of the rooms is Belzebub. One
room can not contain more than one danger, no traps and teleporters
together etc.
Teleporters transports the player from one room to another
random room. If the player encounters a trap o Belzebub he is killed
and GAME OVER.
The halways should also be randomized in the beginning of the
program. Like this:

* Create a list with all the room numbers and shuffle it so all of
the rooms is in a mixed order. ex. [5 2 12 18 9 1 3 6 14 19 11 7 17 4
20 16 10 15 8 13]

* Connect the rooms in east-west direction so that the east hallway
from room 5 leads to room 2 and the west hallway from room to leads
back to room 5 etc. The last room in the lest should be connected
with the first.

* Shuffle a new list and do the same thing in north-south direction.

Once again the file: http://esnips.com/webfolder/b71bfe95-d363-4dd3-
bfad-39999a9e36d0


Once again, that's not a file. And enclose your URLs in <>, that way
Google won't split them.

Apr 25 '06 #2
the file is on that side. But apparently you have to register to
download it.. =( But i can send it to anone who is willing to look
trough it. just send me an email co*********@tel ia.com

Apr 25 '06 #3

co*********@gma il.com wrote:
the file is on that side. But apparently you have to register to
download it.. =( But i can send it to anone who is willing to look
trough it. just send me an email co*********@tel ia.com


Ok, e-mail it to me.

But I cannot guarantee anything. I'll peruse it at my leisure.

Apr 26 '06 #4
I have sent it to you now. Thanks for looking at it.

Apr 26 '06 #5
i just mailed it to you. Thanks for looking at it.

Apr 26 '06 #6
connyledin wrote:
Im trying to create a version of the game Wumpus. Mine is called
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
some one help me??
here is the file:
http://esnips.com/webfolder/b71bfe95...d-39999a9e36d0

What i have the biggest problems with now is between line 8 and 23.


Perhaps you could post those lines so we get an idea of what's going
wrong. You also really need to explain what exactly you are hoping to
achieve, and in what way it isn't working. I don't think anybody is
likely to give you a full solution because that would defeat the
object.

--
Ben Sizer

Apr 26 '06 #7
Ben Sizer wrote:
connyledin wrote:
Im trying to create a version of the game Wumpus. Mine is called
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
some one help me??
here is the file:
http://esnips.com/webfolder/b71bfe95...d-39999a9e36d0

What i have the biggest problems with now is between line 8 and 23.

Perhaps you could post those lines so we get an idea of what's going
wrong. You also really need to explain what exactly you are hoping to
achieve, and in what way it isn't working. I don't think anybody is
likely to give you a full solution because that would defeat the
object.

I have trouble to get rid of the impression, that the (hidden from
direct detection) goal of the original posting is some kind of promotion.

Claudio
Apr 26 '06 #8
the thing is that im too much of a beginner to oint exactly to whats my
problem is... =( I need help by someone looking at the program and
presenting the solution... Im lousy, i should have choosen an easier
assignment.

Apr 26 '06 #9

co*********@gma il.com wrote:
i just mailed it to you. Thanks for looking at it.


Returning.

Comments added by me start #m.

I tried to keep all your original lines commented out and
added my fixes with #m on either side, but there were
so many errors I had to give up. I tried to preserve the
code of the first mistake and simply deleted multiple
repetitions of the same mistake.

Note I made a couple structural changes, move some
variables and deleted others. This in addition to fixing
the goofy errors you made trying to move to the
next room.

Movement now works correctly (I think, did not verify
the map, it doesn't allow you to go back the way you
came). In addition to now correctly printing the room
number, I added the room contents in square brackets.
You'll need to know that in order to handle the traps.

You've got a lot of code still commented out, better
get moving.

# -*- coding: cp1252 -*-
#Belzebub
#Conny Ledin

import random
from Tkinter import *

#creates a room class
class room(object):#, trap):
def __init__(self, trap):
self.trap = trap
#inserts content in rooms
#m
#m why do you need get_trap()?
#m room_list[current_room].trap will return the trap content
#m
def get_trap():
return trap

#creates a room list with content
room_list = []
#0=Nothing, 1=fire trap, 2=acid trap, 3=teleporter, 4=belzebub
trap_list = [0,0,0,0,0,0,0,0 ,0,1,1,2,2,3,3, 3,3,3,3,4]
random.shuffle( trap_list)
for i in range(0,20):
r = room(trap_list[i]) #crates a room object whith content (trap)
room_list.appen d(r)

#creates a list with rooms
nextto_list1 = range(0,20)

#shuffles the list with rooms for movement in east/west direction
random.shuffle( nextto_list1)

#shuffles another list with rooms for movement in north/south direction
#m
#m this line doesn't work, nextt0_list2==N one
#m nextto_list2 = random.shuffle (nextto_list1)
#m
nextto_list2 = range(0,20)
random.shuffle( nextto_list2)
#m
#m placed here, current_room is a global variable
current_room = 0
#m

root = Tk()

#creates GUI
class application(Fra me):

def __init__(self, master):
#creates frame
Frame.__init__( self, master)
self.grid()
self.create_wid gets()

def create_widgets( self):
Label(self,text = "Whats your next move?").grid(ro w = 0, column
= 0, sticky = W)
Label(self, text = "Choose one: ").grid(row = 1, column = 0,
sticky = W)
self.choice = StringVar()
#creates text box
self.results_tx t = Text(self, width = 60, height = 10, wrap =
WORD)
self.results_tx t.grid(row = 7, column = 0, columnspan = 4)
#creates radiobutton for north
Radiobutton(sel f, text = "Go North",
variable = self.choice,
value = "north",
command = self.move
).grid(row = 2, column = 0, sticky = W)
#creates radiobutton for east
Radiobutton(sel f, text = "Go East",
variable = self.choice,
value = "east",
command = self.move
).grid(row = 3, column = 0, sticky = W)
#creates radiobutton for south
Radiobutton(sel f, text = "Go South",
variable = self.choice,
value = "south",
command = self.move
).grid(row = 4, column = 0, sticky = W)
#creates radiobutton for west
Radiobutton(sel f, text = "Go West",
variable = self.choice,
value = "west",
command = self.move
).grid(row = 5, column = 0, sticky = W)
#creates radiobutton for shooting
Radiobutton(sel f, text = "Deploy bomb",
variable = self.choice,
value = "shoot",
command = self.shoot
).grid(row = 6, column = 0, sticky = W)

#creates a function for movement
def move(self):
#m tell move() that current_room is a global and not local
#m to this block
global current_room
#m
message = ""
message += self.choice.get ()
print message
if message == "north":
#m I modified next_room to pass the direction, you don't need it saved
#m direction = 2
#m
#m next_room() returns the new room index, but you aren't saving it,
#m so it's being lost
#m next_room()
#m
#m ok, that's better, you're trying to save it, but what you
#m forgot the (), so you're saving the location of the function,
#m not calling it. note we can't make that mistake if we have to pass
#m parameters to the function
#m current_room = next_room
current_room = next_room(curre nt_room,2)
#m
message = "You enter the next room to the north "
message += str(current_roo m)
#m show what's in the room
message += ' [' + str(room_list[current_room].trap) + ']'
#m
if message == "south":
#m
current_room = next_room(curre nt_room,-2)
#m
message = "You enter the next room to the south "
message += str(current_roo m)
#m show what's in the room
message += ' [' + str(room_list[current_room].trap) + ']'
#m
elif message == "east":
#m
current_room = next_room(curre nt_room,1)
#m
message = "You enter the next room to the east "
message += str(current_roo m)
#m show what's in the room
message += ' [' + str(room_list[current_room].trap) + ']'
#m
elif message == "west":
#m
current_room = next_room(curre nt_room,-1)
#m
message = "You enter the next room to the west "
message += str(current_roo m)
#m show what's in the room
message += ' [' + str(room_list[current_room].trap) + ']'
#m
self.results_tx t.delete(0.0, END)
self.results_tx t.insert(0.0, message)
root.title("Cha sing Belzebub")
#creates a function for shooting
def shoot(self):
message = ""
message += self.choice.get ()
print message
## if message == "shoot":
## belzebub.die()

#creates a randomized grid with rooms that the player can move trough
#m
#m changed to pass function current_room and desired direction
#m
def next_room(cr,d) :#direction, current_room):
#east/west
#m these need to be global?
#m current_room = 1
#m direction = 1 # no need for this at all
#m
#m
if cr == 0 and d == -1:
#m next_room is the name of the function, use a different name for
variable
#m otherwise you're returning the function address, not the result
#m if current_room == 0 and direction == -1:
#m next_room = nextto_list1[19]
nr = nextto_list1[19]
elif cr == 19 and d == 1:
nr = nextto_list1[0]
elif d == 1 or d == -1:
nr = nextto_list1[cr + d]
#north/south
elif cr == 0 and d == -2:
nr = nextto_list2[19]
elif cr == 19 and d == 2:
nr = nextto_list2[0]
elif d == 2:
nr = nextto_list2[cr + 1]
elif d == -2:
nr = nextto_list2[cr - 1]
# return next_room
return nr

###creates a player class
##class player(object):
## def __init__(self):
##
## #all the ways the player can die and GAME OVER displays
## def die(self, fire_trap, acid_trap, belzebub):
## if acid_trap.kill:
## print "Im sorry to say that you have melted./n"
## "Better luck next time/n"
## "GAME OVER!"
## elif fire_trap.kill:
## print "Oh my! Your hair is on fire./n"
## "GAME OVER!"
## elif belzebub.kill:
## print "Belzebub got you, have a lovely time in HELL!/n"
## "GAME OVER"
##
###creates a fire trap class
##class fire_trap(objec t):
## def __init__(self):
## #ser till att spelaren dör
## def kill(self, player):
## player.die()
##
###creates a fire trap class
##class acid_trap(objec t):
## def __init__(self):
## #ser till att spelaren dör
## def kill(self, player):
## player.die()
##
###creates a Belzebub class
##class belzebub(object ):
## def __init__(self):
## #ser till att spelaren dör
## def kill(self, player):
## player.die()
## ##ser till att belzebub dör
## def die(self, player):
## if bomb
####
def main():

app = application(roo t)
root.mainloop()

## for i in nextto_list1 or nextto_list2:
## #skapa ett rum

main()

Apr 27 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2250
by: Suzie | last post by:
Hello, I'm only new at this so please bear with me! I am creating an ontology for a color game and i am using the pizza tutorial as a basis for it. I did everything and when I went to save the file I get a message saying save project errors with these error messages: java.lang.RuntimeException: horrible http://www.owl-ontologies.com/unnamed.owl#0000 at com.hp.hpl.jena.shared.impl.PrefixMappingImpl.checkProper
6
1890
by: Keith | last post by:
I have been using ASP in it's VBScript form for some time, but I only tend to learn what I need to know as I need to know it, so I am by no means an expert and spend a lot of time on here asking quesitons of all you helpful people. However, I have decided it's probably time to actually take teh time to properly learn ASP. Now ASP.net is out, what would everyone suggest I lean towards - Classic or ..net?
4
1624
by: Gonzalo Aguirre | last post by:
i have a classes diagram like this ------------ * ---------- | Vehicles | ------------------------- | Parking| ------------ vehicles ---------- ^ | +--+--------+ | | -------- ---------
3
1805
by: Eric Lilja | last post by:
Hello, I'm creating a small utility for an online game. It involves parsing a text file of "tradesskill recipes" and inserting these recipes in a gui tree widget (similar to gui file browsers if you know what I mean). Here's an example of a recipe as it appears in the text file: * Cashew Pie (lvl 39, 5h 3 min, + max power) - Candied Cashew (level 30) -- Cashew -- Refined Honey (level 30) --- Raw Honey
21
2988
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have updated this system and changed the pages that are saved to the server as aspx - everything works fine and pages can be served - but Its not impossible for a single client to request 100 plus pages in one session - as each page is requested it is...
9
4665
by: Niels Jensen | last post by:
Hi All, I'm desperately looking for help regarding the following: I need to make a hexmap in it's own scrollable window on a form, when I say hex map I mean a graphical hexagon surrounded by other hexagons the same size. The program I'm writing imports region information i.e 10,13 would be a hexagon, 10 hex columns to the right and 13 hex rows down from hex 1,1.
3
2658
by: Newbie | last post by:
Hi All Trying to create a mini-ASP web dev with a couple of PCs at school. When the teachers are happy with the site on the LAN then going to upload it to the school site. Problem is having real problems with the ASP side of things. Timeline of events is as follows: 1) Added IIS (via Add/Remove Windows Components) on WinXP Pro machine (6
2
2615
by: vertozia | last post by:
Hey there, ive been having difficulty placing an image, this is my screenshot, and what ive done so far: http://img341.imageshack.us/img341/9894/gridwg2.jpg /** * ConnectFourGUI * Provide the GUI for the Connect Four game */ import javax.swing.*; import javax.swing.border.*;
8
3747
by: tidiz | last post by:
Hi, I'm trying to make a hangman game that should look like this: Welcome to Hangman ______ Your guess: c Success! __cc__ Your guess: b
0
9876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9717
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10617
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7862
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7045
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5886
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4506
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.