Bagh Chal is a strategic, two-player board game that originates in Nepal. One player controls four tigers, the other controls up to twenty goats. Tigers hunt the goats, while goats try to block the tigers' movement.
The game is played on a board consisting of 25 spots, connected by lines; those lines are the direction of valid moves between spots. Tigers capture goats by jumping over them (similar to Checkers). Otherwise, both tigers and goats may only move one space (across one line) at a time.
Player two begins with 20 goats. Until all 20 have been placed, the only move player two may make is to place a goat on an empty spot on the board. After that, player two moves a goat during their turn.
This is a two-player game, controlled by keyboard input. At each prompt, the player is to enter an alphanumeric board location; letter (horizontal) followed by number (vertical), e.g., "A1" for the top left spot, or "C3" for the center spot.
This implementation of the game does not end. In that respect, it basically acts like a 'smart board and pieces'.
If player 1 is unable to move any of their tigers, the game will get stuck in a loop, waiting for a valid tiger move. In that case, player 2 has won!
If all of the goats have been captured, the game will get stuck in a loop waiting for player 2 to make a valid goat move. In that case, player 1 has won!
Note: Some people who play this game stop after 5 (rather than all 20) goats have been captured.
I have wanted to make a Bagh Chal game (specifically, a web-based one for my Bill's Games website) since I first saw a board and pieces at local Tibetan gift shop, back in the 1990s.
To make this game, I simply reminded myself how the game works (thanks, Wikipedia), and tried an online version, and read another page's description of the game.
I decided to use the state of the screen (by using LOCATE
)
and simple rules on what directions moves can be, depending on what spot
the piece is in, and after modularizing some things, was able to cram it
into 10 lines.
This was the first game I developed for the NOMAM 2014 contest using my Linux laptop, rather working directly on my Atari 1200XL. I used some tools I put together to convert plain ASCII into a working TurboBASIC XL program, running under an emulator: linux2tbasicxl.
Fun fact: I had never actually played Bagh Chal until I tried an online version today!
10 GRAPHICS 2:DIM B$(45):B$="t- - - -t!\!/!\!/! - - - - !/!\!/!\!012321230":? #6;" A B C D E":FOR I=37 TO 45:N=(VAL(B$(I,I))*9)+1
B$
)
I
)...
N
)
20 IF I MOD 2=1:? #6;CHR$((I-37)/2+177);:ELSE :? #6;" ";:ENDIF :? #6;B$(N,N+8):NEXT I:G=20:DIM I$(2):Q=1000
G
)
I$
)
Q
) for all of the jumps to line 1000 we'll be doing
100 REPEAT :? K;" T from":GOSUB Q:UNTIL C=116:X1=X:Y1=Y:REPEAT :? "T to":GOSUB Q:DX=ABS(X1-X):DY=ABS(Y1-Y)
K
)
X1
and Y1
)
DX
) and vertical (DY
)
distances between the 'from' and 'to' locations
105 OK=(C=32 AND (DX=DY OR X1=X OR Y1=Y) AND DX<3 AND DY<3 AND (((X1+Y1) MOD 2)=0 OR X1=X OR Y1=Y))
OK
):
C=32
),
DX=DY
)
X1=X OR Y1=Y
),
((X1+Y1) MOD 2)=0
); otherwise,
you may only go left, right, up or down
(X1=X OR Y1=Y
))
110 IF DX=2 OR DY=2:GX=(X1+SGN(X-X1))*2+1:GY=(Y1+SGN(Y-Y1))*2+1:LOCATE GX,GY,C1:IF C1<>231:OK=0:ENDIF :ENDIF :UNTIL OK
GX,GY
)
C
)
OK=0
)
120 C=116:GOSUB 2000:IF G>0:REPEAT :? G;" G at":GOSUB Q:UNTIL C=32:POSITION X*2+1,Y*2+1:? #6;"g":G=G-1:ELSE
C
)
G
)
140 REPEAT :? "G from":GOSUB Q:UNTIL C=231:X1=X:Y1=Y:REPEAT :? "G to":GOSUB Q:DX=ABS(X1-X):DY=ABS(Y1-Y)
X1
and Y1
)
DX
) and vertical (DY
)
distances between the 'from' and 'to' locations
150 OK=(C=32 AND DX<2 AND DY<2 AND (((X1+Y1) MOD 2)=0 OR X1=X OR Y1=Y)):UNTIL OK:C=231:C1=0:GOSUB 2000:ENDIF :GOTO 100
OK
):
C=32
),
((X1+Y1) MOD 2)=0
); otherwise,
you may only go left, right, up or down
(X1=X OR Y1=Y
))
C
)
C1
)
1000 TRAP Q:REPEAT :INPUT I$:X=ASC(I$(1,1))-65:Y=ASC(I$(2,2))-49:UNTIL X>=0 AND X<6 AND Y>=0 AND Y<6:LOCATE X*2+1,Y*2+1,C:TRAP 32768:RETURN
I$
)
X
)
Y
)
C
)
2000 POSITION X1*2+1,Y1*2+1:? #6;" ":POSITION X*2+1,Y*2+1:? #6;CHR$(C):IF C1=231:POSITION GX,GY:? #6;" ":K=K+1:ENDIF :RETURN
X1,Y1
), erase what was there
X,Y
), draw the shape (C
)
C1
) is a goat...
GX,GY
)
K
)
DOS.SYS
, DUP.SYS
)
TBASIC.AR0
)
AUTORUN.BAS
;
except for the filename, same as BAGHCHAL.TBS
stand-alone file, above)
Bill Kendrick, 2014,
nbs@sonic.net,
New Breed Software
Other games I wrote for NOMAM 2014