A basic MUD system. RE: [Tutor] my newbie program

Simon Wittber (Maptek) Simon.Wittber@perth.maptek.com.au
Thu Nov 21 00:55:02 2002


This is a multi-part message in MIME format.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C29122.6E4C779E"

------_=_NextPart_001_01C29122.6E4C779E
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi there,
=20
I wrote a basic MUD system to teach myself Python and sockets
programming at the same time!
=20
I recently rewrote the entire thing, it has lots of cryptic commands for
creating rooms and objects while the game is playing..
=20
I had a World object which contained a list of Locations. Each Locations
contained a dictionary of current Objects and Users in the Location.
=20
To join rooms together, I created a Portal object, which linked one room
to another in a specified direction. I.e. the room had a dictionary of
Portals, with the dictionary key being the desired direction.=20
=20
This meant that the Portal was one way... so get around this I created
another Portal coming in the opposite direction from the opposite room.
I wrapped both Portals in a Gate object, which controlled the state of
both Portals, eg (locked, visible, open, closed etc)
=20
Another cool feature is you can attach python code to objects. Eg attach
a 'kick' verb to the 'rabbit' object which executes code. Its fairly
basic as MUD systems go, but its 100% Python and uses asynchronous
sockets, and should work 'out of the box' on any system...
=20
If anyone wants this code, drop me an email.
=20
sw.
-----Original Message-----
From: sheri [mailto:din22@cox.net]=20
Sent: Tuesday, 19 November 2002 9:26 PM
To: tutor@python.org
Subject: [Tutor] my newbie program



	hello and thanks for the help on my program
	so far. what i am wondering is how hard would
	it be to implement a dig command that would
	create room objects while the game is running.
	also the appropriate exits. so something like
	dig(north) would create a new exit to a new room
	with an exit back to the room you dug from.
	i am guessing pretty hard but then, i am a=20
	rank beginner so maybe its easy. or are=20
	vague questions like this off topic here?
	i havent written any code for this because=20
	i wouldnt know where to start.
	=20


------_=_NextPart_001_01C29122.6E4C779E
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>Hi=20
there,</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>I=20
wrote a basic MUD system to teach myself Python and sockets programming =
at the=20
same time!</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>I=20
recently rewrote the entire thing, it has lots of cryptic commands for =
creating=20
rooms and objects while the game is playing..</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>I had=20
a World object which contained a list of Locations. Each Locations =
contained a=20
dictionary of current Objects and Users in the =
Location.</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>To=20
join rooms together, I created a Portal object, which linked one room to =
another=20
in a specified direction. I.e. the room had a dictionary of Portals, =
with the=20
dictionary key being the desired direction. </FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>This=20
meant that the Portal was one way... so get around this I created =
another Portal=20
coming in the opposite direction from the opposite room. I wrapped both =
Portals=20
in a Gate object, which controlled the state of both Portals, eg =
(locked,=20
visible, open, closed etc)</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2>Another cool feature is you can attach python code to objects. =
Eg attach=20
a 'kick' verb to the 'rabbit' object which executes code. Its fairly =
basic as=20
MUD systems go, but its 100% Python and uses asynchronous sockets, and =
should=20
work 'out of the box' on any system...</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =
size=3D2>If=20
anyone wants this code, drop me an email.</FONT></SPAN></DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D468252205-21112002><FONT face=3DArial color=3D#0000ff =

size=3D2>sw.</FONT></SPAN></DIV>
<DIV></DIV>
<DIV><FONT face=3DTahoma size=3D2>-----Original =
Message-----<BR><B>From:</B> sheri=20
[mailto:din22@cox.net] <BR><B>Sent:</B> Tuesday, 19 November 2002 9:26=20
PM<BR><B>To:</B> tutor@python.org<BR><B>Subject:</B> [Tutor] my newbie=20
program<BR><BR></DIV></FONT>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV><FONT face=3DArial size=3D2>hello and thanks for the help on my=20
  program</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>so far. what i am wondering is how =
hard=20
  would</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>it be to implement a dig command that =

  would</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>create room objects while the game is =

  running.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>also the appropriate exits. so =
something=20
  like</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>dig(north) would create a new exit to =
a new=20
  room</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>with an exit back to the room you dug =

  from.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>i am guessing pretty hard but then, i =
am a=20
  </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>rank beginner so maybe its easy. =
</FONT><FONT=20
  face=3DArial size=3D2>or are </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>vague questions like this off topic=20
  here?</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>i havent <FONT face=3DArial =
size=3D2>written any code=20
  for this because </FONT></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2><FONT face=3DArial size=3D2>i =
wouldnt</FONT><FONT=20
  face=3DArial size=3D2> know where to start.</FONT></FONT></DIV>
  <DIV><FONT face=3DArial =
size=3D2>&nbsp;</DIV></BLOCKQUOTE></FONT></BODY></HTML>
=00
------_=_NextPart_001_01C29122.6E4C779E--

--------------InterScan_NT_MIME_Boundary--