MUD Game

How to build a MUD Game with Scheme

MUD stands for Multi-User Dungeon. In this game I have created a 4×5 maze with items such as keys, health potion, dagger and enemies in rooms. This MUD game is created with Scheme programming language, feel free to download, modify and use it in your projects.

License: MIT License

Game Play

MUD Game

MUD Game walkthrough map

Left and bottom is the starting point and top and right point is the end section, user must get the key to open locked doors, take the dagger to be able to fight and get the health potion to heal from fights.

It is possible to change the map easily by using provided association lists and hash tables. As you can see in the following image, by running game, a description of the game appears and also player’s item will be shown. A brief description about current room and available directions gives a hint to the player.

As you can see in the following image, by running game, a description of the game appears and also player’s item will be shown. A brief description about current room and available directions gives a hint to the player.

MUD Game Screenshot

Enemy can attack you and deduct 20 of your life, if players life get to 0, he will die as shown in the following picture and game ends:

MUD Game Screenshot 2

When player reaches to the destination, following message appears and game ends:

MUD Game Winning

Data Structure

In this game, there are 4 association lists and 2 hash tables. 
Since room’s data and player data are changing, I have created hash table for roomsdb and player.

Room descriptions association list:

(define descriptions '( (1 "You are in the West Jungle, Available directions are 'North' and 'East'") (2 "Jungle, Available directions are 'West' and 'East'") ….. (24 "Jail, You can found the Queen and rescued here!!!")))

In the directions list, you can set which direction is allowed from each room

(define directions '( (1 (north 5) (south 0) (west 0) (east 2))                       (2 (north 0) (south 0) (west 1) (east 3))                         …
                    (24 (north 0) (south 0) (west 23) (east 0))))

You can identify room properties to allocate keys, health potions or make it locked:

(define rooms-list '( (1 (locked #f) (key #f) (dagger #f) (enemy #f) (potion #f) (end #f))

(2 (locked #f) (key #f) (dagger #f) (enemy #f) (potion #f) (end #f))
 …                   
(24 (locked #f) (key #f) (dagger #f) (enemy #f) (potion #f) (end #t))))

This project consists of two files , data.ss which you can set description for each room and game.ss which is the program itself. You need to have DrScheme to run this script which is available at: http://plt-scheme.org/software/drscheme/

Download Link: Download MUD-game.zip

About majid

Software engineer, Web developer and IT graduate. Profile: View My Profile
This entry was posted in Scripts. Bookmark the permalink.