[Tutor] Hands-on beginner's project?
bhaaluu
bhaaluu at gmail.com
Wed Jun 25 16:17:36 CEST 2008
Brian Wisti has a very nice tutorial for Python beginners that uses Interactive
Fiction as the basis of a tutorial:
http://coolnamehere.com/geekery/python/ifiction/index.html
http://coolnamehere.com/geekery/python/ifiction/single-round.html
http://coolnamehere.com/geekery/python/ifiction/multiple-scenes.html
http://coolnamehere.com/geekery/python/ifiction/multiple-turns.html
Paul McGuire made an example adventure game using pyparsing:
http://wiki.python.org/moin/PyCon2006/Talks#4
http://www.geocities.com/ptmcg/python/pycon06/adventureEngine.py.txt
(you'll need the pyparsing package for it to work)
http://pyparsing.wikispaces.com/
Python Universe Builder (PUB) is an Interactive Fiction module for
Python. It provides a
programming environment similar to that of Inform or TADS but runs
under any Python
interpreter.
http://py-universe.sourceforge.net/
Here's a link to the Interactive Fiction archive containing a huge
array of text adventure
games and other adventure development tools.
http://www.ifarchive.org/
And finally, another link to TAGs based on Creating Adventure Games On
Your Computer.
http://www.geocities.com/ek.bhaaluu/python/index.html
Happy Programming!
--
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!
On Wed, Jun 25, 2008 at 9:39 AM, Jacqui <jacqui.russell at gmail.com> wrote:
> LOL You rock! That's definitely better than my example. I can't wait to
> get better at this!
>
> :-D
>
> On Wed, 2008-06-25 at 09:22 -0400, bob gailer wrote:
>> >
>>
>> Even better is to define a Chapter class, with the various properties
>> and methods pertinent thereto, then make each chapter an instance of
>> that class.
>>
>> class Chapter:
>>
>> def __init__(self, desc, ques=None, **actions):
>> self.desc = desc
>> self.ques = ques
>> self.actions = actions
>> self.prompt = ", ".join(actions.keys())
>>
>> def describe(self):
>> print self.desc
>>
>> def ask(self):
>> if self.ques:
>> print self.ques
>> for i in range(10):
>> ans = raw_input(self.prompt).lower()
>> next = self.actions.get(ans, None)
>> if next:
>> return next
>> else:
>> print "Invalid response"
>> else:
>> print "Too many failed attempts"
>>
>> def main():
>> chapters = [None]*11 # allow for 10 chapters starting with 1
>> chapters[1] = Chapter("Ahead of you, you see a chasm.", "Attempt to
>> jump over it?", y=2, n=3)
>> chapters[2] = Chapter("Oops - that anvil is heavy. You die.")
>> chapters[3] = Chapter("Good choice.", "Pick a direction", n=4, s=5)
>> chapters[4] = Chapter("It's cold in here.", "Pick a direction", e=1, w=2)
>> chapters[5] = Chapter("It's hot in here.", "Pick a direction", u=6, d=3)
>> chapters[6] = Chapter("Congratulations - you found the gold.")
>> next = 1
>> while True:
>> chapter = chapters[next]
>> chapter.describe()
>> next = chapter.ask()
>> if not next:
>> print "Game over"
>> break
>>
>> main()
>>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list