Jump to content
IGNORED

DanBoris' Tech Blog - Telengard


RSS Bot

Recommended Posts

One of the games I remember from the good old days with my Atari 800 computer is the dungeon crawler Telengard by Avalon Hill. The game was written in Basic so I thought it would be interesting to take a look at the code for the game. One of the most interesting parts is the way the maze if generated. The dungeon in the game is very large, it has 50 level and each level is 200 by 200 rooms. The dungeon is also the same every time you play so you can map it out as you go along. I was really curious how the achieved this.

 

The programmer did it by using a pseudo-random algorithm to generate the map. This results in a map that is complex enough to be interesting, but not so complex that it's unplayable.

 

This is the formula that is used to determine the appearance of each room:

 

XO = 1.6915
YO = 1.4278
ZO = 1.2462

q = x * XO + y * YO + z * ZO + x * YO + y * ZO + z * XO
hi = q And &HFF
q = x * y * ZO + y * z * XO + z * x * YO

If (q And 3) = 0 Then

q = (q / 4) And &HF
If q > 9 Then q = q - 9
hi = hi + q * 256

End If

 

XO, YO, and ZO are constants

z = dungeon level

x,y = room position in level

 

This formula is run for each room that is displayed and the result, hi, is interpreted as follows:

 

bits 0,1: Upper wall: 0,1 = nothing, 2 = door, 3 = wall

bits 2,3: Left wall: 0,1 = nothing, 2 = door, 3 = wall

bits 8-11: If not 0 then there is something special in the room

 

1 = Inn

2 = Pit

3 = Teleporter

4 = Stairway

5 = Alter

6 = Fountain

7 = Cube

8 = Throne

9 = Box

 

The bottom wall and right wall of a room come from the left and top wall of adjacent rooms. There is also code that knows to cap the right side and bottoms of the rooms at the edge of the maze.

 

You can take a look at the full commented Basic code for Telengard on my web site along with a VB.NET program that allows you to browse the maze.

 

http://www.atarihq.com/danb/Telengard.shtml

 

http://www.atariage.com/forums/index.php?a...;showentry=4957

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...