Jump to content







Photo

Telengard

Posted by DanBoris, 08 June 2008 · 222 views

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.c...Telengard.shtml




I remember Telengard from ages back on the C64. Probably mostly the same code.
  • Report
Telengard was the original inspiration for Dungeon:
http://www.atariage....;showentry=4933

Another good site (by the original author) can be found here:
http://www.aquest.com/telen.htm
Note his mention of the 400/800 being the most challenging port.
  • Report

May 2012

S M T W T F S
  12345
6789101112
13141516171819
202122 23 242526
2728293031  

Recent Entries

Recent Comments

Tags