[Type-in] game review: BRAHMA by Paul Blythe

General games-related topics
Post Reply
David G
Posts: 545
Joined: Thu Jul 17, 2014 7:58 am
Location: 48 North

[Type-in] game review: BRAHMA by Paul Blythe

Post by David G »

The classic puzzle game Tower of Brahma was adapted to computers even before the home computer era began in 1975


The game board is typically represented in memory by a numeric array: one dimension for the pillars, and a second dimension for the rings. BRAHMA follow this design:

Code: Select all

;DIM A(3,5)
;               values=ring-size
;ring-level 1--- 1   0   0
;           2--- 2   0   0
;           3--- 3   0   0
;           4--- 4   0   0
;           5--- 5   0   0
;
;                |   |   |
;        pillar: 1   2   3
In Blythe's version, in the interest of fitting into 1K, and in line with most early adaptations, there is no graphical display of the rings. Only the numbers are shown on the screen. This worked well for terminal based computers


BRAHMA type-in from your computer magazine April 1982 vol 2 no 4 page 77

This is a version that is very basic and with little feedback ... but it does run in 1K. And on a 1K machine it is OK, but on 16K - as normal - it is slow until the screen stabilizes

Type-in thanks to Antipontifex and Xavsnap


The magazine put a ZX-80 badge on this, but Paul says it is for the ZX-81. I tried it on the ZX80 but even after changing all the GOTO to GO TO, it didn't work
Brahma
ZX80

Paul Blythe,
Sheffield,
South Yorkshire.

This LOGIC problem is based on the project given by Brahma, the Hindu deity, to his
disciples. The object of the game is to transfer a set of rings, of different sizes, from one pillar to another but at no time can a larger ring be on top of a smaller.

The program runs on a ZX-81 1K. However, typing errors or illegal moves when playing the game stretch the memory to its limits. There are five rings; ring 1 is the smallest. If, however, you have additional memory, you can have more rings by using the alternative lines shown at the end of the program where N is the number of rings. The solution for five rings is given below.

BRAHMA
10 DIM A(3,5)
11 FOR B=1 TO 5
12 LET A(1,B)=B
13 NEXT B
14 GOTO 160
20 PRINT "FROM"
21 INPUT C
50 FOR B=1 TO 5
60 IF A(C,B)<>0 THEN GOTO 80
70 NEXT B
75 GOTO 20
80 PRINT "TO"
81 INPUT D
82 IF C=D THEN GOTO 20
90 FOR E=1 TO 5
100 IF A(D,E)=0 THEN NEXT E
125 IF E=6 THEN GOTO 190
130 IF A(C,B)>A(D,E) THEN GOTO 190
140 LET A(D,E)=A(C,B)
150 CLS
155 LET A(C,B)=0
160 FOR F=1 TO 5
170 PRINT " ";A(1,F);" ";A(2,F);" ";A(3,F)
180 GOTO 20
190 LET A(D,5)=A(C,B)
200 GOTO 150

10 DIM A (3,N)
11 FOR B=1 TO N
50 FOR B=1 TO N
90 FOR E=1 TO N
125 IF E=N+1 THEN GOTO 190
160 FOR F=1 TO N
190 LET A (D,N)=A(C,B)

SOLUTION

1-3, 1-2, 3-2, 1-3, 2-1, 2-3, 1-3, 1-2, 3-2, 3-1,
2-1, 3-2, 1-3, 1-2, 3-2, 1-3, 2-1, 2-3, 1-3, 2-1,
3-2, 3-1, 2-1, 2-3, 1-3, 1-2, 3-2, 1-3, 2-1, 2-3,
1-3
Unfortunately, the magazine listing is missing the critical line that actually draws all the rings. The listing actually has three bugs. Ah, such were the joys of the type-in era ;-)

These changes make it work:

1. To see all the rings, add

Code: Select all

175 NEXT F
2. To prevent rings from disappearing, change

Code: Select all

130 IF A(C,B)>A(D,E) THEN GOTO 190
to

Code: Select all

130 IF A(C,B)>A(D,E) THEN GOTO 20
3. To correct the ring movement, add

Code: Select all

131 LET E = E-1

Paul said:
you can have more rings by using the alternative lines shown at the end of the program where N is the number of rings
This is basically replacing the fixed '5' with the variable N. But it doesn't work. Antipontifex identified a missing line that needs to be added:

Code: Select all

5 LET N=5
This is the crucial version for me, because it let me choose LESS rings. Starting with 3 rings allows one to learn the game much easier

[edit: Added files, and revised the text]
Attachments
BrahmaN.p
Alternate version with prompt for number of rings
(688 Bytes) Downloaded 73 times
BRAHMA.bas
BASIC listing of original version, with corrections
(574 Bytes) Downloaded 72 times
Last edited by David G on Thu Nov 21, 2024 7:00 pm, edited 1 time in total.
User avatar
mrtinb
Posts: 1986
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: game review: BRAHMA by Paul Blythe

Post by mrtinb »

Back in the day many ZX80s were upgraded with the 8K ROM from the ZX81. The upgrade even included a keyboard overlay. On this hardware you were limited to FAST mode only.

So machines were not mentioned so much as ZX80 vs ZX81, but rather if it had 4k or 8k ROM.

Maybe the creator used an upgraded ZX80 with 8k ROM to create this game. :-) We will never know.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
David G
Posts: 545
Joined: Thu Jul 17, 2014 7:58 am
Location: 48 North

Re: game review: BRAHMA by Paul Blythe

Post by David G »

Oh I forgot to include the working game, and the listing was missing the alternate lines
... now revised


Paul Blythe said right off the bat
The program runs on a ZX-81 1K.
So I think the magazine made a mistake in putting the ZX-80 badge on it

yc 4-82 p77.jpg

in any case it is a serviceable version of Towers of Hanoi that fits in 1K. I wonder if more could be done with a 1K machine language version?
Post Reply