Problems with Adventure Game Design Team Pimp Squeak
Problems with Adventure Game Design Team Pimp. Squeak
Several Problems • Code assumes one player • No telnet interface • Web interface assumes only one person will connect to it • Can’t restart a game. • Limited language support
Several Problems • Current method is difficult to program cleanly • Problems with objects being both a container AND a surface: table when: [: player : me : world | me sent: (world object: 'knife')] “Was it a container or a surface? ” • Some behaviors not well-defined: table when: [: player : me : world | me sent: (world object: 'knife')] do: [world print ‘hey’]. “did this accept or reject? ”
Single Player vs. Multiplayer implies several changes: • • Daemons should now be time-based instead of command-based. Makes no sense to count down each user command if there are 500 users. Web interface needs way to push data to a web player when an event occurs, like another player entering a room. Messages like “world print: ” need to know which player to print to. More like MUD than Adventure Game
Single Player vs. Multiplayer Single player has several advantages to make up for its lack of multiplayer support: • • Infinite time to think between commands Less complex code, easier to write games For an adventure game, it makes more sense. Imagine Zork with multiplayer! Milestone 5 already supports it!
Single Player vs. Multiplayer Single player has several advantages to make up for its lack of multiplayer support: • • Infinite time to think between commands Less complex code, easier to write games For an adventure game, it makes more sense. Imagine Zork with multiplayer! Milestone 5 already supports it!
Our Solution
Our Solution Event Driven Adventure Game
Event Driven Adventure Game • • • All objects have events associated with their various actions. No more crazy when: [sent: this] do: [that accept: me]. Instead: table on. Object. Put. On: [: object : player : world| (object name = ‘kitten’) if. True: [world print ‘The kitten drops off. ’ ^false. ] ^true. Legible and easy to understand write!
Events Objects: Characters on. Put. On: on. Talk: on. Put. In: on. Pick. Up: on. Drop: on. Look: on. Object. Put. In: on. Object. Put. On: on. Verb: do: on. Turn: Rooms on. Player. Enters: on. Player. Leaves: on. Look:
Reimplementation of House World table on. Object. Put. On: [: object : player : world | (object name = ‘kitten’) if. True: [world print ‘The kitten jumps off the table. ’. ^AGObject. DROP]. ^AGObject SUCCESS. ] knife on. Verb: ‘use’ do: [: self : player : world | (room contains: (world object: ‘ogre’)) if. True: [world print ‘The knife flies through the air and the troll is killed. ’. ] self drop. ] world print ‘I don’’t see any apples in here!’]
Reimplementation of House World The biggest reason to consider the new strategy is the troll code. Observe the original troll code. troll when: [: player : me : world | me container = player container and: [(me flag: 'attacking') is. Nil] ] do: [: player : me : world | world print: 'The troll starts to come toward you, with fangs bared and claws outstretched'. me flag: 'attacking' value: 1]. troll when: [: player : me : world| (me flag: 'attacking') is. Nil not and: [(me flag: 'attacking') < 5]] do: [: player : me : world |me flag: 'attacking' value: 1 + (me flag: 'attacking')]. troll when: [: player : me : world | (me flag: 'attacking') is. Nil not and: [(me flag: 'attacking') >= 5]] do: [: player : me : world |world print: 'The troll has you! You die!'. world quit. ].
Reimplementation of House World Here’s the code with the new system troll on. Turn: [: self : player : world | val : = (self flag: ‘attacking’) val is. Nil if. True: [self flag ‘attacking’ value: 0. world print ‘The troll starts to come towards you, with’, ‘fangs bared and claws outstretched’. val : = 0]. val >= 5 if. True: [world print ‘The troll has you! You die!’. world quit. ]. self flag: ‘attacking’ value: (val + 1). ]
Other nifty things Event-driven code allows for all sorts of easy to implement possibilities. Let’s say you want the character to die if he tries to walk out of the dark room and he doesn’t have a torch. It could be done in the old system with flags and daemons and such, but this is easy. dark. Room on. Player. Exits: [: self : player : world | (player contains: (world object: ‘torch’)) if. False: [world print ‘Oh, no! You have walked into the’, ‘slavering fangs of a lurking grue!’ world quit. ^true]. ^true. ]
Final Improvement List • Switch to event-driven code • Implement telnet interface, so the game will be playable from a UNIX prompt. (if time allows) • Keep the game single player. A MUD is a different sort of game that, while neat, is not what we are building. • Allow the game to be restarted. • Leave input system as is, without implementing a fancy parser. (It’s cool, but it takes way too much time for relatively small gain).
This Presentation Brought to You by Team Pimp. Squeak
- Slides: 16