Zork Game Source Code

Posted on -

Got a news tip?Is there something you think we should be reporting on? Email.While Zork and its two sequels were part of a larger trend of text-adventure PC games, Zork stood out for its sophistication in the genre. So when Zork's publisher Infocom was later purchased and then shut down by Activision, it was feared the source code for Zork was lost. Until now.Zork is a classic text-adventure game developed in 1977 by four members of MIT's Laboratory for Computer Science Dynamic Modeling System. Text adventures require players to directly input their actions and hope the computer recognizes it. So, for example, the text says the player comes across a fork in the road, and the player can choose to go to either left, right, or turn back. What made Zork such a popular text adventure game was that it understood more complex inputs from the player.Now, we finally have the source code to the original Zork games thanks to digital archivist Jason Scott, who released the source codes on GitHub earlier this week.

But Scott warned interested parties who were diving into the code about one thing. 'If you don't understand ZIL, and you probably don't, read this instruction manual.' I've uploaded the entirety of source code of all Infocom text adventures/interactive fiction to Github. If you don't understand ZIL, and you probably don't, read this instruction manual. — Jason Scott (@textfiles)ZIL, or Zork Implementation Language, is the unique programming language used to make the Zork games and was based on another old coding language called MIT Design Language (MDL). Speaking to Scott said, 'ZIL is written to create adventure games in an enverionment people haven't used commercially in over 25 years.

Game

And even then, it was about 15 people.' ZIL then is a pretty niche coding language with a niche group of followers. There are actual online communities that teach and carry on ZIL, but it's not a modern coding language like C. Luckily for you, there is a guide on ZIL published on, written by Steven Eric Meretzky.Activision does technically own the source code to Zork, so don't be too surprised if it disappears from the internet one day.

In the meantime, you can see the code on.Header image courtesy of.

Remember the good old times, when it was impossible to have more than one colour on a screen, and no graphics at all? In the early 80's, a series of text-based adventure games, the where created by a company called. To play, you just have to tell orders to the game, with simple sentences like: GO NORTH, TAKE SWORD, TALK TO TROLL, CLIMB TREE. The game engine can understand a lot of verbs and actions, and with theses commands you where able to explore a place called the Great Underground Empire, a place full of mystical creatures, treasures and magic. I can understand that now, these games seem outdated.

Zork Game Source Code

Maybe or may be not. If you like to write stories, if you like to create incredible universes, adventures and characters (and if you have poor drawing knowledge like me), it can be a good idea to write an interactive fiction game. It's not very hard, only a few knowledges in programming. Different platforms can produce such games. Today, I chose to talk about the language Inform 6, by creating a small game from scratch. In the last part of my (first!) Instructable, I'll talk about other systems.

First, we'll create the game. A simple one, only a few rooms, some objects, and a character. The goal of the game will be to find a key to unlock a door.

The action will take place in a strange castle. This Instructable is divided into six steps: Design the game: we will create the map of the game, the objects list, and the global story. Setting up the development environment: we will download the compiler, the ready-made English libraries, and a program to 'play' our story (everything for free). Create the rooms: we will start programming! First, the rooms, and the first tests. Adding objects: empty rooms are sad.

Let's add some stuff! Adding a character: for not being alone Finish and play it!: add a victory end to the game.

Enjoy this Instructable! Its my first one. Please comment! And please forgive me if you find grammar mistakes, I'm not English mother-tongue. Okay, so let's start the game design.

In this example, we will have three rooms, some objects, and a dragon. The global story of the game is:.

explore the rooms, understanding that you are locked. There is a door, but she is locked. in a room, you'll find two treasure chests. A sign says that you will find the door key in one, and death in the second (if you don't want to kill the player, of course you can change the story!).

as the chests are similar, you'll need to ask someone. The dragon can helps you, you just have to solve an enigma. talk to the dragon, answer the enigma, open the chest, get the key, unlock the door. that's all!Its a quite small game, but we will see all the main aspects of game design.

Let's start by drawing the global map. In interactive fictions games, rooms directions are the main cardinal points (north, south, east, west). We will use these directions. Rooms:. Initial room, with door.

Treasure room. Dragon roomObjects:. two treasure chests. one key hidden in a chest. a doorCharacters:. a dragonIt can be a good idea to add some stuff to make the game more realistic.

We will not do it in this tutorial, but you will be able to do it by yourself. Ok, the game is created (only on paper or in your mind). Its now time to turn on the computer. I choose to talk about the Inform 6 language. Its not the only language to create this kind of games. Of course, you can create everything from scratch with your favorite language (C, VB.net, Java, Basic.).

The Inform 6 language is based on a C-based syntax. The great advantage of this language is we will focus the coding only on the game. We will use ready-made 'libraries' containing all the boring stuff: the syntax analyzer (the code that 'read' what the player wants to do, and extract the actions.) Also, we will use an English library contains a big amount of classical verbs, actions, and default messages, like 'You can't go this way'. Thanks to these libraries, it will be possible to create only the game. The main website for the Inform 6 language is. You can also get a lot of information here.

Before downloading anything, let's explain in details how we will work. 1-We will write the Inform 6 source into a plain text file.

We will use the windows notepad, but of course, you can use something else. Notepad is also a good program. 2-We will turn our source into a compiled source called 'z code' file (extension.z5).

This compiled file is the full game. It's like a PDF file. You can't launch the game by double-clicking on the file (its not an executable). You need a 'player' to run the game, as you need a software to open a pdf file. The great advantage of this is that the '.z5' file can be shared for every kind of final users: PC, Mac, Linux, mobile phones. The z5 file will stay the same, only the interpreter will be platform-dependent, like a PDF file reader.

3-So, to launch our game, we will download an 'interpreter'. I really like, as it can play a wide range of 'interactive fiction' files (from different systems), and it is easy to use. The compiler and the libraries are. The windows compiler is, last link of the page. The Inform 6 resource and help file: The (download links on the left) Lets unzip everything and create the folder structure showed in the screenshots. We will also need to create a small BATCH file to run the compiler with the following options. Open the notepad, enter the following code and save it as COMPILER.BAT in the first folder, near the 'inform-632.exe' file (watch out for the extension!) @inform-632 MyGame.inf +informlibrary611 @pause Now, open a new notepad session.

It will be the main source file of our game. Save the file as 'mygame.inf', put it in the same folder. Certainteed roof installation. Here is the main header file for our game. Copy it into the notepad.

The init section contains, now, only the initial text introduction of our game. Constant Story 'My first Inform 6 game'; Constant Headline '^A demo by Yoruk.^'; Constant Noscore; #Include 'Parser'; #Include 'VerbLib'; Initialise; print '^^This is a demo game written in Inform 6. Can you solve it?^^'; ; Include 'Grammar'; Save the file, and run the COMPILER batch file. You should get the result shown in the screenshot.

No errors, and a new file should be created in the game folder. Open Gargoyle, and select the file 'MyGame.z5'. Yepee, the core is ready! Let's add some rooms. Ok, the first room code will take place just under the init section, after the grammar include.

Here is the code for the first room (the 'Initial Room'):object InitialRoom 'Initial Room' with description 'You are alone in a strange room.' , has light; The room description is the text who will appear when the player will move in, or when he will ask for the room description, like 'look' or 'examine'. Everything in the game universe will be declared as inform 'objects', even people or rooms.

The final has statement gave some main informations about the object. Here, the keyword light means that the object is a room, full of light (you can see in it).

All the attributes are listed. Before compiling, we must add a line in the init block: location = InitialRoom; Just after the print statement. The variable location contains the name of the initial room, where the action starts.

At this time, we can compile the game and to run it. Its simple: just launch our 'compile.bat' script file. You should not have errors. Interesting, but still flat. Let's add the two other rooms (put this code after the first room): object TreasureRoom 'Treasure Room' with description 'This room is quite the same as the previous one. You can go to the initial room by walking in the south.

There is an other room on the east.' , has light; object DragonRoom 'Dragon Room' with description 'You can reach the Treasure room by walking on the west.' , has light; It will work, but we need to create the links between the rooms (following our map). Let's add some code in the room blocks: object InitialRoom 'Initial Room' with description 'You are alone in a strange room.' , nto TreasureRoom, has light; object TreasureRoom 'Treasure Room' with description 'This room is quite the same as the previous one. You can go to the initial room by walking in the south.

There is an other room on the east.' , sto InitialRoom, eto DragonRoom, has light; object DragonRoom 'Dragon Room' with description 'You can reach the Treasure room by walking on the west.' , wto TreasureRoom, has light; The nto, sto, wto, eto keywords are giving the global directions. In the InitialRoom block, the nto keyword mean that we can reach the TreasureRoom by going in the north. In the other room, the keyword sto allow the player to come back in the first room. It's always useful to tell the player what are the directions. It's sometimes boring to try every directions in a new room.

Our game have small descriptions, but it can help the player. Save the source, compile and run the new z5 file with gargoyle. You can now explore the map. You can try some basic commands: go north open door smell listen. Ok, the room design is now done, its time to add stuff into these rooms.

It's always good to add a lot of things that the player can see/touch/smell/listen, it makes the game more pleasant. Here, we will add the objects of our adventure: the door, the chests, the key. The door: A door in the Inform 6 language can be hard to implement. Here is the code.

Put it just after the ' Initial Room' block. Object - WoodenDoor 'wooden door' with description 'A big wooden door. It have a lock.' , name 'big' 'wooden' 'door', whenclosed 'You can see a big wooden door, on the south. The door is closed.'

, whenopen 'The door is now open.' , doorto ExitRoom, doordir sto, withkey goldkey, has static door openable lockable locked; the '-' arrow means that the door object is located in the previous room, here, the Initial Room description: the text who appears when asking commands like 'look at the door' name: you can put here some synonyms of the objet. Thanks to this, the game can understand sentences like 'examine the big door' whenclosed, whenopen: additional descriptions doorto: the name of the room behind the room. We will create a 'dummy' room for this right now. Doordir: here, sto. To cross the door, we will have to 'go south' withkey: hehey, our door will be locked! The key object will be a gold key.

We will create the object later. The attributes: a lot of them for a simple door.

Zork game source code in c

Static: you can't take the door with you door: yes, its a door openable: you can open and close it (yes!) lockable: you can lock it with a key locked: and it is already locked! We now need to add an other line of code in the InitialRoom block. Object InitialRoom 'Initial Room' with description 'You are alone in a strange room.'

, nto TreasureRoom, sto WoodenDoor, has light; The new sto line means that the player will cross the door by moving in the south. If the door is closed, he will not be able to reach the other room. Now, we will create two treasure chests. One made of silver, one made of gold. Of course, we will hide the golden key inside the second one. Here is the code for these three objects. Put this code at the end of the file, after the last room: object SilverChest 'Silver Chest' with description 'A beautiful silver chest.'

Hitchhiker's Guide To The Galaxy Source Code

, name 'silver' 'chest', foundin TreasureRoom, has static openable container; object GoldenChest 'Golden Chest' with description 'A beautiful Chest, made of Gold.' , name 'gold' 'golden' 'chest', foundin TreasureRoom, has static openable container; object Goldkey 'golden key' with description 'A small golden key.' , has female; The two chest are similar. The foundin statement means that both are in the Treasure Room. The attribute static means again that you can't pick up them with you, openable means that you can open and close then, and finally the container attribute means that you can hide things in it. The golden key object is simple.

Only a short description. The only attribute is female, with this the game will apply specific words when describing the object. We need to do two last things.

First, create a last dummy room, it will be the other side of the door. The player will win the game by entering in it. Here is the code: object ExitRoom 'Exit Room' with description 'You are free!' , has light; We don't have to add any directions. Put this code after the Goldkey object.

The last thing is. Hide the key!

Actually, she is not really in the game, as we don't put a location for this object. Instead of using the foundin keyword, we will use a line of code in the Init block. Just add: move GoldKey to GoldenChest; After the location line. Save and compile the file. You should not get any errors. Open the game in Gargoyle and enter the following commands: go north look at golden chest get the key open the silver chest open the golden chest get the key It should work as shown in the screenshot.

The defaults messages 'You can't see any such thing' are stored into the English library. Of course, you can change them, but for now we will use the default messages. Actually, you can open both chests without any problems. We final goal of the game will be to open only one chest, as the second one will be trapped. The real chest will be the golden one. A dragon will help the player to find the good chest.

Yes, in the next step!