Classic Computer Magazine Archive COMPUTE! ISSUE 76 / SEPTEMBER 1986 / PAGE 31

Beehive

Steve Michel

To avoid getting stung in this delightful strategy game, you'll need to plan ahead. The original version of "Beehive" was written for the 512K Amiga. We've added fresh translations for the Commodore 64 (and 128 in 64 mode), Apple II series, IBM PC/PCjr, and Atari 400, 800, XL, and XE. The IBM PC/PCjr game requires a color/graphics card and BASICA for the PC, and Cartridge BASIC for the PCjr. The Atari version requires at least 32K of memory and a joystick. The Commodore version requires a joystick. The Apple II version requires a joystick and color monitor, and runs on any Apple II-series computer with either ProDOS or DOS 3.3.


"Beehive" is a two-player strategy game that requires you to concentrate fully and develop long-range planning skills. The game board consists of 121 hexagons arranged in a sloping 11x11 matrix. The name derives from the playing field's resemblance to the geometric precision of a honeycomb. The first player is assigned the left and right borders of the honeycomb, while the second player is assigned the top and bottom edges.

The object of the game is deceptively simple. Each player tries to connect a continuous line from one of his or her borders to the other. If you are player 1, for instance, you need to connect the left border with the right. The players alternate turns, filling in cells of the honeycomb one at a time. While attempting to complete your own course, you must also try to block your opponent's way, and this requires strategic thinking. The first player to connect both borders wins the game. As a reward, tiny bee faces appear along the line of connection, clearly marking the path to victory.

Entering The Game

Type in the program listing for your computer, referring to the special notes below. When you have saved a copy of the game, type RUN and press RETURN. Beehive begins by asking for the name of each player. After both players have entered their names, the beehive grid is drawn and play begins. In the Amiga and IBM PC/PCjr versions, the computer determines randomly which player should take the first turn; in other versions, player 1 always goes first. In the Amiga version, each player takes a turn by moving the mouse pointer to the desired cell and pressing the left mouse button once. Other versions substitute joystick or keyboard controls for the mouse (see below).

When you choose a cell, it is filled with a solid circle and your turn ends. While connecting your own borders, you should also be trying to prevent the other player from making a connection. Play continues until one player or the other completes a continuous line from one border to the other. At this point a victor is declared, and bee faces replace the circles along the entire winning route.

Winning Strategies

Like most two-player games, Beehive adjusts itself to the skill of the players. The basic concept is simple enough that even small children can enjoy playing. But when two knowledgeable players are matched, play proceeds at a much higher level. The flexibility of the game allows many different strategies.

Here are some important points for beginners to keep in mind. To begin with, your first move does not have to occur in one of your border rows. In fact, you can often establish a better strategic position by starting somewhere near the middle of the playing field. In a typical game you will have to swing back and forth between an expanding, offensive posture and a defensive, blocking posture. The middle areas accommodate both strategies well.

Second, it is not necessary that all of your cells be connected. That is, a new cell doesn't necessarily have to touch one of your existing cells. Any empty cell in the hive is fair game for either player, and it's often advantageous to space out your cells to allow multiple paths between borders. Starting multiple pathways makes it harder for an opponent to block your progress completely.

Finally, keep in mind that the hexagonal shape of each cell permits you to move in six different directions. Try not to get locked into a strict, straight-line strategy too often. Any pathway that connects both borders is legal, and in many cases the winning path will be quite roundabout.

Amiga Version

Before you begin typing in the Amiga version (Program 1), notice the small arrows marking the end of the line. They are not intended to be typed (in fact, we deliberately chose a character that's not available from the Amiga's keyboard). Instead, wherever you see an arrow in the listing, press RETURN or move the cursor off the line to enter it into memory.

The Amiga version of Beehive includes synthesized speech. Either player can toggle the speech effects on or off at any time. Press the left button once: A small box appears, indicating the current speech status. If speech was turned on, it is now turned off, and vice versa. Press the left button again to erase the speech box and resume the game.

Commodore 64/128 Version

The Commodore version (Program 2) runs on a Commodore 64 or Commodore 128 in 64 mode; it requires a joystick. Plug the joystick into port I and use it to move the bee-shaped pointer onto the desired cell. To select a cell, press the fire button.

Atari Version

Atari Beehive (Program 3) requires a joystick and runs on any Atari 400, 800, XL, or XE computer with at least 32K of memory. Plug the joystick into port 1. Move the pointer over the cell you wish to occupy, then press the fire button to select it.

Apple II Version

The Apple II version of Beehive (Program 4) runs on any Apple II-series computer, under DOS 3.3 or ProDOS. A color monitor and joystick are required. To select a cell, move the pointer onto it, then press the button.

IBM PC/PCjr Version

IBM Beehive (Program 5) requires a color/graphics card and BASICA for the IBM PC, and Cartridge BASIC for the PCjr. Keyboard controls are used to move the bee-shaped pointer around the playing field and to select a cell. Use the arrow keys to move left, right, up or down. When the pointer is above the desired cell, press the space bar to select it.


Program 1: Beehive For Amiga

Please refer to the typing instructions in the article before entering this listing.

CLS
talk$="": GOSUB talk
GOSUB init
GOSUB getnames
start:
CLS: RANDOMIZE TIMER
markers = 0: winner = 0: prev.player = 0
player = INT(2*RND(1)+1)
FOR j=1 TO 11: FOR k=1 TO 31: hive%(j,k)=0: NEXT k: NEXT j
FOR j=1 TO 20: pathlen(j) = 0: NEXT j
FOR j=1 TO 65: path%(j) = 0: used%(j) = 0: node%(j) = 0: NEXT j
GOSUB drawscreen
BREAK ON: ON BREAK GOSUB closeup

main:
IF prev.player <> player THEN
COLOR 4
LOCATE 1,2: PRINT "Player:"
LOCATE 1,2: PRINT "Player: ";
COLOR colr(player): PRINT LEFT$(player$ (player), 15)
talk$=player$(player): GOSUB talk
prev.player = player
END IF
WHILE MOUSE (0) = 0
x = MOUSE (0)
a$=INKEY$:IF a$=" " THEN GOSUB readkey
WEND
GOSUB checkmouse
IF used THEN main
GOSUB checkline
IF possible = 1 THEN GOSUB checkwinner
LOCATE 3,2: PRINT "            "
IF winner = 1 THEN drawpath
IF player = 1 THEN
player = 2
ELSE
player = 1
END IF
GOTO main

init:
CLS:colr(1) = 2:colr (2) = 3
DIM colcor%(11):FOR j = 1 TO 11:READ colcor%(j):NEXT j
DATA 5,4,4,3,3,2,2,1,1,0,0
DIM row.inc%(6),col.inc%(6)
FOR j= 1 TO 6:READ row.inc%(j),col.inc%(j):NEXT j
DATA -1,-1,0,1,1,1,1,0,0,-1,-1,-1
DIM hive%(11,31)
DIM used%(65), node%(65), path%(65), pathlen(20)
SCREEN 1,640,200,3,2
WINDOW 1,"BEE HIVE",,16,1
GOSUB setcolor
DIM hexa(100),ball1(100),ball2(100),eyes1(100),eyes2(100)
LINE (30,10)-(12,15),7: LINE - STEP (0,10) ,7: LINE - STEP (18,5),7
LINE- STEP (18,-5),7: LINE - STEP (0,-10) ,7: LINE - STEP (-18,-5), 7
LINE (30,11)-(13,15),6: LINE - STEP (0,9),6: LINE - STEP (17,5),6
LINE - STEP (16,-4),6:LINE - STEP (0,-10),6:LINE - STEP (-17,-4),6
GET(12,10)-(48,30),hexa
CLS:CIRCLE(30,20),11,colr(1):PAINT(30, 20),colr(1):GET(20,9)-(40,31),ball1
GOSUB parts:GET(18, 12)-(42,30),eyes1
CLS: CIRCLE(30,20),11,colr(2):PAINT(30,20),colr(2):GET (20,9)-(40,31),ball2
GOSUB parts:GET(18,12)-(42,30),eyes2:CLS
RETURN

parts:
CIRCLE(25,19),4,1:CIRCLE(35,19),4,1
PAINT(25,19),1:PAINT(35,19),1
PSET (29,17):LINE - STEP (-5,-5):LINE - STEP (-5,3)
PSET (31,17):LINE - STEP (5,-5):LINE - STEP (5,3)
CIRCLE(30,24),2,1:PAINT(30,24),1
RETURN

getnames:
COLOR 4
CLS: talk$="WELCOME TO BEEE HIVE": GOSUB talk
a$ = "What is the name of player 1 ": PRINT
PRINT a$;: talk$=a$: GOSUB talk:INPUT player$(1)
a$ = "What is the name of player 2 ": PRINT
PRINT a$;: talk$=a$: GOSUB talk:INPUT player$(2)
talk$="Press space bar to turn speech off or on during game."
LOCATE 15,14:PRINT talk$
GOSUB talk:CLS:RETURN

drawscreen:
CLS: y = 7
FOR r =1 TO 11
x = 180 - r * 18
FOR c =1 TO 11
x = x+ 36
PUT (x,y),hexa,OR
NEXT c
y=y+15
NEXT r
PSET (595,12),2: GOSUB upndown:LINE -STEP (0,10),2
PSET (596,12),2: GOSUB upndown:LINE -STEP (0,10),2
PSET (597,12),2: GOSUB upndown:LINE -STEP (0,10),2
PSET (194,12),2: GOSUB upndown:LINE -STEP (0,10),2
PSET (195,12),2: GOSUB upndown:LINE -STEP (0,10),2
PSET (196,12),2: GOSUB upndown:LINE -STEP (0,10),2
y1=-5: y2=5: PSET (198,9),3: GOSUB across
PSET (198,10),3: GOSUB across
PSET (199,11),3: GOSUB across
y1=5: y2=-5: PSET (19,173),3: GOSUB across
PSET (19,174),3: GOSUB across
PSET (19,175),3: GOSUB across
RETURN

upndown:
FOR j = 1 TO 10
LINE -STEP (0, 10),colr(1)
LINE -STEP (-18,5),colr(1)
NEXT j
RETURN

across:
FOR j =1 TO 11
LINE -STEP (18,y1),colr(2)
LINE -STEP (18,y2),colr(2)
NEXT j
RETURN

checkmouse:
x = MOUSE(3): y = MOUSE(4)
offset = 0: used = 0
yr = INT(y/15+.5): row = yr: yr= yr * 15
IF INT(yr/2) = yr/2 THEN offset= 18
xr = INT ((x-offset)/36+.5): col= xr: xr = xr * 36+ offset
IF row < 1 OR row > 11 THEN
used = 1
RETURN
END IF
col = col - colcor%(row)
IF  col < 1 OR col > 11 THEN
used = 1
RETURN
END IF
rowhive = row: colhive = 10+2*col-row
IF hive%(row, colhive) <> 0 THEN
used =1
RETURN
END IF
markers = markers + 1
hive%(row,colhive) = player
IF player = 1 THEN
PUT (xr-10,yr-9),ball1,OR
ELSE
PUT (xr-10,yr-9),ball2,OR
END IF
RETURN

checkline:
possible=1
IF player = 2 THEN
FOR row = 1 TO 6: ff=0: fb=0
FOR col = 1 TO 11: colhive-10+2*col-row
IF hive%(row,colhive)=player THEN ff=1
colhive = 10+2*(col)-(12-row)
IF hive%(12-row,colhive)=player THEN fb=1
NEXT col
IF ff=0 OR fb=0 THEN
possible = 0
row = 1E+09
END IF
NEXT row
ELSE
FOR col =1 TO 6: ff=0: fb=0
FOR row =1 TO 11: colhive=10+2*col-row
IF hive%(row, colhive)=player THEN ff=1
colhive = 10+2*(12-col)-row
IF hive%(row, colhive)=player THEN fb=1
NEXT row
IF ff=0 OR fb=0 THEN
possible = 0
col = 1E+09
END IF
NEXT col
END IF
RETURN

checkwinner:
LOCATE 3,2: COLOR 4: PRINT "Checking..."
used.cntr = 0: winner = 0: node.cntr = 0: node.total = 0: counter = 0
IF player = 1 THEN check1
FOR col =1 TO 11: row = 1
IF hive%(row,10+2*col-row) <> player THEN skip2
noderow= row:nodecol = col: G0SUB usedlookup
IF used.flag = 1 THEN skip2
node.total = 1: path.total = 1:counter = 1
path%(1) = 100 * noderow + nodecol
GOSUB checkpath
IF winner = 1 THEN col = 1E+09
skip2:
NEXT col
RETURN

check1:
FOR row = 1 TO 11: col = 1
IF hive%(row,10+2*col-row) <> player THEN skip1
noderow = row: nodecol = col: GOSUB usedlookup
IF used.flag = 1 THEN skip1
node.total = 1: path.total = 1:counter = 1
path%(1) = 100 * noderow + nodecol
GOSUB checkpath
IF winner = 1 THEN row = 1E+09
skip1:
NEXT row
RETURN

usedlookup:
used.flag = 0: search = 100 * noderow + nodecol
lk = 0: IF used.cntr = 0 THEN skipsearch
FOR lk = 1 TO used.cntr
IF search = used%(lk) THEN
used.flag = 1
lk = 1E+09
END IF
NEXT lk
skipsearch:
IF used.flag = 0 THEN
used.cntr = used.cntr+1
used%(used.cntr) = search
END IF
RETURN

checkpath:
node.cntr = 0
FOR nc = 1 TO 6
noderow = noderow + row.inc%(nc): nodecol = nodecol + col.inc%(nc)
IF noderow < 1 OR noderow > 11 0R nodecol < 1 OR nodecol > 11 THEN skipnode
IF hive%(noderow,10+2*nodecol-noderow) <> player THEN skipnode
GOSUB usedlookup: IF used.flag =1 THEN skipnode
node.cntr = node.cntr + 1
node.total = node.total + 1 : node%(node.total) = 100 * noderow +nodecol
IF (player = 2 AND noderow = 11) OR (player = 1 AND nodecol = 11) THEN
winner = 1
path.total = path.total + 1
path%(path.total) = 100 * noderow + nodecol
nc = 1E+09
END IF
skipnode:
NEXT nc
IF winner = 1 THEN RETURN
IF node.cntr = 0  AND node.total= 0 THEN RETURN
IF node.cntr = 0 THEN
path.total = path.total - pathlen(counter)
pathlen(counter) = 0
counter = counter - 1
END IF
IF node.cntr > 1 THEN counter =counter + node.cntr - 1
noderow = INT(node%(node.total)/100)
nodecol = node%(node.total) - 100 * noderow
path.total = path.total + 1
pathlen(counter) = pathlen(counter) + 1
path%(path.total) = node%(node.total)
node.total = node.total - 1
GOTO checkpath

drawpath:
LOCATE 1,1: PRINT "                         ":COLOR 4
LOCATE 1,1: PRINT "THE WINNER: ";: COLOR colr(player):PRINT player$(player);
a$ = "THE WINNER IS " + player$(player): talk$=a$: GOSUB talk
FOR j = 1 TO path.total : offset= 0
row = INT (path%(j)/100): col = path%(j) - 100*row + colcor% (row)
IF row/2 = INT(row/2) THEN offset = 18
xr = col * 36 + offset: yr = row* 15
IF player = 1 THEN
PUT (xr-10,yr-9),ball1,XOR
PUT (xr-12,yr-5),eyes1,OR
ELSE
PUT (xr-10,yr-9),ball2,XOR
PUT (xr-12,yr-5),eyes2,OR
END IF
NEXT j

goagain:
LINE (419,139)-(625,186),7,b: LINE (420,140)-(624,185),7,b
LINE (421,141)-(623,184),4,bf: COLOR 6
LOCATE 19,55: a$ = " WANT TO PLAY AGAIN ? ": PRINT  a$;
LINE (431,162)-(487,180),7,bf: LOCATE 22,56: PRINT " YES ";
LINE (567,162)-(615,180),7,bf: LOCATE 22,73: PRINT " NO ";
talk$=a$: GOSUB talk

waiter:
WHILE MOUSE(0) <> 1
WEND
x » MOUSE(3): y = MOUSE(4)
IF y < 162 OR y > 180 THEN waiter
IF x > 430 AND x < 488 THEN start
IF x > 566 AND x < 616 THEN closeup
GOTO waiter

setcolor:
PALETTE 0,.3,.3,.3   'grey
PALETTE 1,0,0,0      'black
PALETTE 2,0,1,0      'green
PALETTE 3,0,0,1      'blue
PALETTE 4,1,1,1      'white
PALETTE 5,0,1,1      'aqua
PALETTE 6,1,1,0      'yellow
PALETTE 7,.8,.2,0    'red
RETURN

closeup:
PALETTE 0,.1,.1,.1   'blue
PALETTE 1,1,1,1      'white
PALETTE 2,0,0,0      'black
PALETTE 3,.85,.2,0   'red
WINDOW CLOSE 1
SCREEN CLOSE 1
STOP

readkey:
WINDOW 4,"Speech",(250,70)-(390,110),16,1
IF TalkFlag=1 THEN
talk$="Now I can talk."
PRINT talk$
TalkFlag=1-TalkFlag
GOSUB talk
GOTO clearmouse
END IF
IF TalkFlag=0 THEN
talk$="OK, I'll be quiet."
PRINT talk$
GOSUB talk
TalkFlag=1-TalkFlag
END IF

clearmouse:
WHILE MOUSE(0)<>0:WEND
PRINT "Press button once"
PRINT "to continue..."
WHILE MOUSE(0)<>1:WEND
WHILE INKEY$<>"":WEND
WINDOW CLOSE 4
RETURN

talk:
IF TalkFlag=0 THEN SAY TRANSLATE$(talk$)
RETURN

Program 2: Commodore 64/128 Beehive

Version by Kevin Mykytyn, Editorial Programmer

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.

EF 10 POKE 56,48:CLR:GOTO 80
RK 20 GOSUB 560
QK 30 JV=15-(PEEK(56321)AND15)-128*((PEEK(56321)AND16)<>16):
      IFJV>127THENRETURN
AX 40 IF JV=0 THEN 30
FF 50 TX=X:TY=Y:TX=TX+X(JV):TY=TY+Y(JV)
HK 60 IF TX<1 OR TX>11 OR TY<1 OR TY>11 THEN 30
BQ 70 X=TX:Y=TY:GOSUB 560:GOTO 30
XQ 80 GOSUB 170:GOSUB 530
RM 90 POKE 53280,5:POKE 53281,5:PRINT"{CLR}{6 DOWN}{6 RIGHT}";:GOSUB 470:POKE 53269,1
SC 100 INPUT"{BLK}{3 DOWN}{2 RIGHT}ENTER YOUR NAME PLAYER ONE";PN$(1)
SR 110 INPUT "{DOWN}{2 RIGHT}ENTER YOUR NAME PLAYER TWO";PN$(2):POKE 53269,0
QC 120 GOSUB 400:FOR A=1 TO 2:PN$(A)=LEFT$(PN$(A),15):NEXT:X=1:P=1:UN=1:Y=1
HM 130 B$="YOUR TURN ":GOSUB 1160
RM 140 GOSUB 20:SP=1397+40*Y+X*2-Y
MM 150 IF PEEK(SP)<>32 THEN F=10:GOSUB 580:GOTO 140
AK 160 BD(X,Y)=UN:POKE SP,81:POKE SP+54272,7*(P-1):GOSUB590:GOSUB610:P=3-P:GOTO130
KF 170 ML$="[<I>]"+CHR$(8)+"[<X>]<"+CHR$(3)+"[<2>]XJ"+CHR$(16)+
       CHR$(248)+"L[<B>][<T>]":POKE 835,0
SK 180 POKE 836,208:POKE 830,0:POKE 831,216:POKE 828,0:POKE 829,56:POKE 56334,0
SP 190 POKE 1,51:ML$=ML$:SYS(PEEK(51)+256*PEEK(52)):POKE 1,55:POKE 56334,1
GF 200 FOR I=12568 TO 12631:READ J:POKE I,J:NEXT:POKE 53272,28
AP 210 FOR A=0 TO 10:READ X(A),Y(A):NEXT A:FOR A=832 TO 895:READ B:POKE A,B:NEXT
JE 220 POKE 53276,1:POKE 2040,13:POKE 53287,7:POKE 53285,0:RETURN
ER 230 DATA 231,126,24,24,24,24,126,231
RC 240 DATA 0,0,0,0,0,0,126,231
SC 250 DATA 231,126,0,0,0,0,0,0
HR 260 DATA 7,30,24,24,24,24,126,231
DA 270 DATA 7,30,24,24,24,24,30,7
MF 280 DATA 224,120,24,24,24,24,120,224
RA 290 DATA 231,126,24,24,24,24,120,224
JA 300 DATA 195,36,126,219,255,126,36,24
PH 310 DATA 0,0,0,-1,0,1,0,0,-1,0,0,0,0,0,0,0,1,0,0,0,0,0
CQ 320 DATA 0,0,0,0,0,0,0,16
CS 330 DATA 0,0,65,80,0,65,164,20
JR 340 DATA 70,100,1,150,100,1,165,144
JM 350 DATA 0,106,64,5,105,0,26,170
GB 360 DATA 64,21,153,144,26,86,80,5
SE 370 DATA 5,144,0,2,96,0,1,160
SH 380 DATA 0,0,0,0,0,0,0,0
JG 390 DATA 0,0,0,0,0,0,0,53
GH 400 PRINT"{CLR}{8 DOWN}"SPC(13)"{RVS}{BLK}£{YEL}[<J>]{23 SPACES}
       {BLK}£"
CB 410 PRINT SPC(12)"{BLK}{RVS}£{OFF}£";:FOR A=1 TO 11:
       PRINT "{WHT}$ ";:NEXT A:PRINT" {BLK}{RVS}£{OFF}£"
BC 420 FOR A=1 TO 11
QA 430 PRINTSPC(12-A)"{BLK}{RVS}£{OFF}£{WHT}& ";:
       FOR B=1 TO 10:PRINT"# ";:NEXT:PRINT"){RVS}{BLK}£{OFF}£":NEXTA
GP 440 PRINT "{BLK}{RVS}£{OFF}£{2 SPACES}";:FOR A=1 TO 11:
       PRINT"{WHT}% ";:NEXT:PRINT "{LEFT}{BLK}{RVS}£{OFF}£"
FM 450 PRINT "{BLK}£{YEL}{RVS}{23 SPACES}{OFF}[<H>]{BLK}£":PRINT "{HOME}{7 SPACES}";
XJ 460 POKE 1827,39:POKE 56099,1:POKE 1459,40:POKE 55731,1
GH 470 PRINT "{BLK}{RVS}[<K>]{2 SPACES}{OFF}{9 SPACES}{RVS}[<K>]{OFF}[<K>]
       {RVS}[<K>]{OFF}[<K>]{BLK}"SPC(24)"{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>]"
       SPC(8)"{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>]"SPC(24);
MJ 480 PRINT "{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>]{RVS}[<K>][<D>][<I>]{OFF}[<V>]
       {RVS}[<K>][<D>][<I>]{OFF}[<V>]{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>] {RVS}
       [<F>][<D>]{OFF} {RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]
       [<D>][<I>]{OFF}[<V>]"SPC(12)"{RVS}[<K>]{2 SPACES}{OFF} {RVS}[<K>][<C>]";
PP 490 PRINT "{OFF}[<F>] {RVS}[<K>][<C>]{OFF}[<F>] {RVS}[<K>]
       {2 SPACES}{OFF}[<K>] {RVS}[<K>]{OFF}[<K>] {RVS}[<K>]{OFF}[<K>]{RVS}[<K>]
       {OFF}[<K>]{RVS}[<K>][<C>]{OFF}[<F>]{YEL}"SPC(13)"
       {RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]
       {OFF}[<K>]{2 SPACES}{RVS}[<K>]{OFF}[<K>]{2 SPACES}{RVS}[<K>]";
HD 500 PRINT "{OFF}[<K>]{RVS}[<K>]{OFF}[<K>] {RVS}[<K>]{OFF}
       [<K>] [<C>]{RVS}[<C>][<V>]{OFF}[<V>]{RVS}[<K>]{OFF}[<K>]
       {BLK}"SPC(14)"{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}
       [<K>][<C>]{RVS}[<2 I>]{OFF}[<V>][<C>]{RVS}[<2 I>]{OFF}
       [<V>]{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>] {RVS}
       [<2 I>]{OFF} ";
FC 510 PRINT " [<C>][<V>] [<C>]{RVS}[<2 I>]{OFF}[<V>]"SPC(12)"{RVS}[<K>]
       {2 SPACES}{OFF}"SPC(9)"{RVS}[<K>]{OFF}[<K>]{RVS}[<K>]{OFF}[<K>]":
SH 520 POKE 53248,30:POKE 53264,1:POKE 53249,150:RETURN
JF 530 FOR A=54272 TO 54295:POKE A,0:NEXT:POKE 54296,15:POKE 54277,25
MX 540 DIM TA(11,11,2),EH(61),EV(61)
SE 550 DIM BD(11,11),SH(50),SV(50):SP$="{RVS}":FOR A=1 TO 20:SP$=SP$+" ":
       NEXT:RETURN
KM 560 POKE 53249,0:TX=X*16+(11-Y)*8+36:POKE 53248,TX AND 255
PS 570 POKE 53264,-(TX>255):POKE 53249,Y*8+120:POKE 53269,1:RETURN
BM 580 POKE 54273,F:POKE 54276,16:POKE 54276,17:RETURN
XQ 590 POKE54273,10:POKE54276,64:POKE54276,65:FORZZ=15TO1STEP-.3:
       POKE54275,ZZ:NEXT
HP 600 RETURN
PG 610 CH=X:CV=Y:LC=0:RC=0:FOR X=-1 TO 1:TH=CH+X
JK 620 TV=CV-1-(X=1):GOSUB 780
JG 630 TV=CV-(X>-1):GOSUB 780
BK 640 NEXT
PM 650 IF P=1 AND CH=1 OR P=2 AND CV=1 THEN LC=1
EK 660 IF P=1 AND CH=11 OR P=2 AND CV=11 THEN RC=2
QJ 670 CC=LC+RC:IF CC=3 THEN BD(CH,CV)=UN+1:GOTO 850
JA 680 IF CC=0 THEN 770
BS 690 SP=0:SH(0)=CH:SV(0)=CV
AM 700 IF SP=-1 THEN 770
RC 710 DH=SH(SP):DV=SV(SP):SP=SP-1
CH 720 BD(DH,DV)=UN+CC
EP 730 FOR X=-1 TO 1:TH=DH+X
FJ 740 TV=DV-1-(X=1):GOSUB 820
JH 750 TV=DV-(X>-1):GOSUB 820
MC 760 NEXT:GOTO 700
ED 770 X=CH:Y=CV:UN=5-UN:RETURN
DD 780 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
DP 790 IF BD(TH,TV)=UN+1 THEN LC=1
PS 800 IF BD(TH,TV)=UN+2 THEN RC=2
SK 810 RETURN
SA 820 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
FP 830 IF BD(TH,TV)=UN THEN SP=SP+1:SH(SP)=TH:SV(SP)=TV
CM 840 RETURN
PM 850 POKE 53248,33:POKE 53264,1:POKE 53249,195
PS 860 FOR ZZ=1 TO 20:POKE 646,ZZ:B$=" YOU WIN ":GOSUB 1170:NEXT:GOSUB 1160
CQ 870 FOR CC=1 TO 2:FE=1:LE=1:EH(1)=CH:EV(1)=CV:EF=0:L=1
HA 880 CD=CH:IF P=2 THEN CD=CV
KF 890 IF CC=1 AND CD=1 OR CC=2 AND CD=11 THEN HH(CC)=0:GOTO 990
HB 900 NE=LE:E=FE
RA 910 DH=EH(E):DV=EV(E)
JQ 920 FOR X=-1 TO 1:TH=DH+X:TV=DV-1-(X=1):GOSUB 1090:TV=DV-(X>-1):GOSUB 1090:NEXT
GM 930 IF EF=1 THEN 990
XS 940 IF (E=LE) THEN 970
EK 950 E=E+1:IF E=61 THEN E=1
XA 960 GOTO 910
CM 970 FE=LE+1:LE=NE:IF FE=61 THEN FE=1
EC 980 L=L+1:GOTO 900
AE 990 NEXT:FOR CC=1 TO 2:DH=HH(CC):DV=VV(CC):L=TA(DH,DV,CC):IF DH=0 THEN 1040
BF 1000 POKE781,DV+9:POKE782,DH*2-DV+13:POKE783,0:SYS 65520:
        PRINT"{OFF}[<6>]*":GOSUB 590
ED 1010 IF L=1 THEN 1040
QQ 1020 FORX=-1 TO 1:TH=DH+X:TV=DV-1-(X=1):GOSUB1060:TV=DV-(X>-1):GOSUB1060:NEXT
KM 1030 L=L-1:DH=AH:DV=AV:GOTO 1000
EA 1040 NEXT:POKE781,CV+9:POKE782,CH*2-CV+13:POKE783,0:SYS65520:
        PRINT"[<6>]*":GOSUB590
HH 1050 GOTO 1190
AC 1060 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
MF 1070 IF TA(TH,TV,CC)=L-1 THEN AH=TH:AV=TV
XF 1080 RETURN
KB 1090 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
QJ 1100 IF BD(TH,TV)<>UN+CC OR TA(TH,TV,CC)<>0 THEN RETURN
FB 1110 TA(TH,TV,CC)=L:NE=NE+1:IF NE=61 THEN NE=1
FF 1120 EH(NE)=TH:EV(NE)=TV
SD 1130 CD=TH:IF P=2 THEN CD=TV
DP 1140 IF CC=1 AND CD=1 OR CC=2 AND CD=11 THEN EF=1:HH(CC)=TH:VV(CC)=TV
SK 1150 RETURN
KH 1160 POKE 646,7*(P-1)
FR 1170 POKE 214,23:PRINT:A$=LEFT$(SP$,(16-LEN(PN$(P))/2))+B$+PN$(P)
JA 1180 PRINT " "A$;LEFT$(SP$,40-LEN(A$));:RETURN
CQ 1190 POKE 214,23:PRINT:PRINT "{WHT}{13 SPACES}{RVS}PRESS FIREBUTTON{OFF}{10 SPACES}";
PE 1200 WAIT 56321,16,16:POKE 214,23:PRINT:PRINT SPC(12)"{OFF}{20 SPACES}";
AR 1210 FOR A=1 TO 11:FOR B=1 TO 11:FOR C=1 TO 2:TA(A,B,C)=0:BD(A,B)=0
XA 1220 NEXT C,B,A:POKE 53269,0:GOTO 120

Program 3: Atari Beehive

Version by Kevin Mykytyn, Editorial Programmer

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.

BI 10 POKE 106,95:GOSUB 2000:GOTO 80
LG 20 FL=0:GOSUB 560
NK 30 JV=15-STICK(0)+128*(STRIG(0)=0):IF JV>127 THEN RETURN
JC 40 IF JV=0 THEN 30
NP 50 POKE 77,0:TX=X:TY=Y:TX=TX+X(JV):TY=TY+Y(JV)
DG 60 IF TX<1 OR TX>11 OR TY<1 OR TY>11 THEN 30
IJ 70 X=TX:Y=TY:FL=0:GOSUB 560:GOTO 30
FK 80 GOSUB 530:GOSUB 170:PRINT "{CLEAR}"
OC 90 DIM T$(30),TM$(30),NAME$(40),LENGTH(2):FOR A=1 TO 40:NAME$(A,A)="":NEXT A:
      POSITION 17,10:PRINT "BEEHIVE"
HE 100 FOR A=1 TO 2:PRINT "{2 DOWN}ENTER YOUR NAME PLAYER ";A;" ";:INPUT T$
EC 101 IF T$="" THEN T$=" "
OB 105 IF LEN(T$)>15 THEN T$=T$(1,15)
NA 106 LENGTH(A)=LEN(T$)
EC 110 NAME$((A-1)*15+1,(A-1)*15+LEN(T$))=T$:NEXT A:OY=1
OL 120 GOSUB 400:X=1:P=1:UN=1:Y=1
EB 140 T$="YOUR TURN ":GOSUB 4000:POKE 712,150-98*(P=2)
AG 145 GOSUB 20:LOCATE X*2-Y+14,Y+5,SP:POSITION X*2-Y+14,Y+5:PRINT CHR$(SP)
LO 150 IF SP<>32 THEN SOUND 1,100,12,15:FOR TD=1 TO 50:NEXT TD:SOUND 1,0,0,0:GOTO 140
NL 160 BD(X,Y)=UN:POSITION X*2-Y+14,Y+5:PRINT CHR$(42+P):GOSUB 590
CP 162 GOSUB 610:P=3-P:GOTO 140
EC 170 FOR A=0 TO 1023:POKE 24576+A,PEEK(57344+A):NEXT A
GM 175 FOR A=25600 TO 25856:POKE A,0:NEXT A
CP 180 FOR I=24600 TO 24703:READ J:POKE I,J:NEXT I
IN 210 FOR A=0 TO 10:READ X,Y:X(A)=X:Y(A)=Y:NEXT A
KP 220 POKE 54279,64:POKE 53277,3:POKE 559,62:POKE 623,1:POKE 704,0:RETURN
NJ 230 DATA 231,126,24,24,24,24,126,231
DD 240 DATA 0,0,0,0,0,0,126,231
DE 250 DATA 231,126,0,0,0,0,0,0
EH 260 DATA 7,30,24,24,24,24,126,231
LD 270 DATA 7,30,24,24,24,24,30,7
NG 280 DATA 224,120,24,24,24,24,120,224
NL 290 DATA 231,126,24,24,24,24,120,224
CC 300 DATA 195,36,126,219,255,126,36,24
GK 301 DATA 0,40,170,170,170,170,40,0
LL 302 DATA 0,20,85,85,85,85,20,0
LI 303 DATA 2,2,8,8,32,32,128,128
KC 304 DATA 85,0,0,0,0,0,0,0
KD 305 DATA 0,0,0,0,0,0,0,85
MI 310 DATA 0,0,0,-1,0,1,0,0,-1,0,0,0,0,0,0,0,1,0,0,0,0,0
KE 400 GOSUB 2000:POKE 756,96:POKE 752,1:DL=PEEK(560)+256*PEEK(561):
       POKE DL+6,7:POKE DL+3,71
NO 405 POSITION 5,0:PRINT "* BEEHIVE *":POSITION 15,4:PRINT "////////////////////////"
FF 410 PRINT SPC$(1,12);"-";:FOR A=1 TO 11:PRINT "$ ";:NEXT A:PRINT " -"
DB 420 FOR A=1 TO 11
MO 430 PRINT SPC$(1,12-A);"-& ";:FOR B=1 TO 10:PRINT "# ";:NEXT B:PRINT ")-":NEXT A
CB 440 PRINT "-  ";:FOR A=1 TO 11:PRINT "% ";:NEXT A:PRINT "{LEFT}-"
CJ 450 PRINT "........................":POSITION 4,16:PRINT "'":
       POSITION 36,6:PRINT "(":RETURN
DH 530 DIM TA(11,35),EH(61),EV(61),BD(11,11),SH(50),SV(50),SP$(20),X(10),Y(10),
       SPC$(20),HH(15),VV(15)
GC 535 POKE 752,1:POSITION 14,10:PRINT "PLEASE WAIT"
PH 540 GOSUB 3000:FOR A=1 TO 20:SP$(A,A)="-":SPC$(A,A)=" ":NEXT A:RETURN
EM 560 LB=PEEK(88):HB=PEEK(89):POKE 752,1:POKE 89,100:POKE 88,OY*8+99:POSITION 0,0:
       PRINT "{8 SPACES}":IF FL THEN 575
ID 570 POKE 53248,X*8+(11-Y)*4+61:POKE 88,Y*8+99:POSITION 0,0:PRINT "x{.}P8,&# "
BM 575 POKE 88,LB:POKE 89,HB:OY=Y:RETURN
OP 590 FOR T=15 TO 0 STEP -0.4:SOUND 1,100,10,T:NEXT T:RETURN
JL 610 CH=X:CV=Y:LC=0:RC=0:FOR X=-1 TO 1:TH=CH+X
BB 620 TV=CV-1+(X=1):GOSUB 780
OC 630 TV=CV+(X>-1):GOSUB 780
DB 640 NEXT X
BK 650 IF P=1 AND CH=1 OR P=2 AND CV=1 THEN LC=1
IE 660 IF P=1 AND CH=11 OR P=2 AND CV=11 THEN RC=2
BA 670 CC=LC+RC:IF CC=3 THEN BD(CH,CV)=UN+1:GOTO 850
ON 680 IF CC=0 THEN 770
AH 690 SP=0:SH(0)=CH:SV(0)=CV
DB 700 IF SP=-1 THEN 770
LJ 710 DH=SH(SP):DV=SV(SP):SP=SP-1
FD 720 BD(DH,DV)=UN+CC
GK 730 FOR X=-1 TO 1:TH=DH+X
BA 740 TV=DV-1+(X=1):GOSUB 820
OB 750 TV=DV+(X>-1):GOSUB 820
DO 760 NEXT X:GOTO 700
GA 770 X=CH:Y=CV:UN=5-UN:RETURN
MG 780 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
OA 790 IF BD(TH,TV)=UN+1 THEN LC=1
OA 800 IF BD(TH,TV)=UN+2 THEN RC=2
HJ 810 RETURN
MB 820 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
MB 830 IF BD(TH,TV)=UN THEN SP=SP+1:SH(SP)=TH:SV(SP)=TV
HM 840 RETURN
GA 850 FL=1:GOSUB 560:T$="YOU WIN ":GOSUB 4000:FOR A=255 TO 0 STEP -1:POKE 712,A:NEXT A
HA 860 POSITION 0,20:PRINT "{15 SPACES}SEARCHING{13 SPACES}"
BP 870 FOR CC=1 TO 2:FE=1:LE=1:EH(1)=CH:EV(1)=CV:EF=0:L=1
AD 880 CD=CH:IF P=2 THEN CD=CV
JD 890 IF CC=1 AND CD=1 OR CC=2 AND CD=11 THEN HH(CC)=0:GOTO 990
EB 900 NE=LE:E=FE
MI 910 DH=EH(E):DV=EV(E)
MK 920 FOR X=-1 TO 1:TH=DH+X:TV=DV-1+(X=1):GOSUB 1090:TV=DV+(X>-1):GOSUB 1090:NEXT X
PF 930 IF EF=1 THEN 990
FP 940 IF (E=LE) THEN 970
FF 950 E=E+1:IF E=61 THEN E=1
HC 960 GOTO 910
BA 970 FE=LE+1:LE=NE:IF FE=61 THEN FE=1
NO 980 L=L+1:GOTO 900
AO 990 NEXT CC:FOR CC=1 TO 2:DH=HH(CC):DV=VV(CC):L=TA(DH,DV*3+CC):IF DH=0 THEN 1040
CI 1000 POSITION DH*2-DV+14,DV+5:PRINT "*":GOSUB 590
PP 1010 IF L=1 THEN 1040
OM 1020 FOR X=-1 TO 1:TH=DH+X:TV=DV-1+(X=1):GOSUB 1060:TV=DV+(X>-1):GOSUB 1060:NEXT X
FP 1030 L=L-1:DH=AH:DV=AV:GOTO 1000
CI 1040 NEXT CC:POSITION CH*2-CV+14,CV+5:PRINT "*":GOSUB 590
MH 1050 GOTO 1160
OO 1060 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
ON 1070 IF TA(TH,TV*3+CC)=L-1 THEN AH=TH:AV=TV
KJ 1080 RETURN
PB 1090 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
CI 1100 IF BD(TH,TV)<>UN+CC OR TA(TH,TV*3+CC)<>0 THEN RETURN
NL 1110 TA(TH,TV*3+CC)=L:NE=NE+1:IF NE=61 THEN NE=1
KO 1120 EH(NE)=TH:EV(NE)=TV
EK 1130 CD=TH:IF P=2 THEN CD=TV
OG 1140 IF CC=1 AND CD=1 OR CC=2 AND CD=11 THEN EF=1:HH(CC)=TH:VV(CC)=TV
KH 1150 RETURN
JF 1160 POSITION 0,20:PRINT "{12 SPACES}PRESS FIREBUTTON{8 SPACES}"
AM 1165 IF STRIG(0)<>0 THEN 1165
IK 1170 POSITION 0,20:PRINT "{36 SPACES}":GOSUB 3000:GOTO 120
GE 2000 GRAPHICS 0:POKE 710,15:POKE 709,0:POKE 708,45:POKE 54279,96:
        POKE 559,62:POKE 704,102:RETURN
DI 3000 FOR A=1 TO 11:FOR B=1 TO 35:TA(A,B)=0:NEXT B:NEXT A:
        FOR A=1 TO 11:FOR B=1 TO 11:BD(A,B)=0:NEXT B:NEXT A
KE 3010 RETURN
PL 4000 TM$=T$:TM$(LEN(T$)+1,LEN(T$)+LENGTH(P))=NAME$((P-1)*15+1,(P-1)*15+LENGTH(P))
AJ 4005 POSITION 2,20:PRINT "{33 SPACES}"
FL 4010 POSITION 19-LEN(TM$)/2,20:PRINT TM$:RETURN

Note: As originally listed in the magazine, the game board interior would not be display properly. In line 10, the original code did a "POKE 106,96" which sets the top area of RAM. The author proceeded to use the space above that for the new character set used to draw the board. However, both clearing the screen or setting the graphics mode clears the frist 64 bytes above the top area, so part of the character set was erased. I've altered the line and checksum to account for this.

Also note that this program uses artifacting to generate the colors of the chosen cells. If you are running this in an emulator, you may have to turn artifacting on to see the colors properly.


Program 4: Apple II Beehive

Version by Tim Victor, Editorial Programmer

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs' in this issue of COMPUTE!.

0D 100 LOMEM:16384:DIM BD(11,11),SH(50),SV(50),TA(11,11,2),EH(61),EV(61)
6F 110 FOR A=768 TO A+88:READ D:POKE A,D:NEXT:READ D:IF D<>-1 THEN 1070
A6 120 FOR A=35328 TO A+7:POKE A,0:NEXT
38 130 FOR A=35840 TO A+79:READ D:POKE A,D:NEXT:READ D:IF D<>-1 THEN 1070
44 140 TEXT:HOME:FOR I=1 TO 2
3D 150 PRINT "PLAYER "I"'S NAME:";:INPUT "";A$:NN$(I)=LEFT$(A$,24):NEXT
87 160 POKE 6,0:POKE 7,138:IF PEEK(190*256)<>76 THEN POKE 54,0:POKE 55,3:
       CALL 1002:GOTO 180
B6 170 PRINT CHR$(4);"PR#A$300"
59 180 GOSUB 850
FD 190 P=1:UN=1:NH=6:NV=6:CH=6:CV=6:GOSUB 930
7A 200 HTAB 1:VTAB 21:CALL -868:PRINT NN$(P)"'";:S=ASC(RIGHT$(NN$(P),1)):
       IF S-32*(S>96)<>83 THEN PRINT "S";
C9 210 PRINT " TURN":VTAB 20:HTAB 1:PRINT CHR$(96+P)
99 220 IF PEEK(49249)>127 THEN 290
A3 230 IF PDL(0)<90 THEN NH=NH-1:IF NH<1 THEN NH=1
23 240 IF PDL(0)>165 THEN NH=NH+1:IF NH>11 THEN NH=11
21 250 IF PDL(1)<90 THEN NV=NV-1:IF NV<1 THEN NV=1
9B 260 IF PDL(1)>165 THEN NV=NV+1:IF NV>11 THEN NV=11
EC 270 IF CH<>NH OR CV<>NV THEN GOSUB 960:CH=NH:CV=NV:GOSUB 930
1E 280 GOTO 220
FE 290 IF BD(CH,CV)<>0 THEN PRINT CHR$(7);:GOTO 230
CB 300 BD(CH,CV)=UN
07 310 GOSUB 960:GOSUB 930
8D 320 IF PEEK(49249)>127 THEN 320
D7 330 LC=0:RC=0:FOR X=-1 TO 1:TH=CH+X
E7 340 TV=CV-1+(X=1):GOSUB 500
06 350 TV=CV+(X>-1):GOSUB 500
07 360 NEXT
5B 370 IF P=1 AND CH=1 OR P=2 AND CV=1 THEN LC=1
9C 380 IF P=1 AND CH=11 OR P=2 AND CV=11 THEN RC=2
7E 390 CC=LC+RC:IF CC=3 THEN 570
D1 400 IF CC=0 THEN 490
68 410 SP=0:SH(0)=CH:SV(0)=CV
C0 420 IF SP=-1 THEN 490
2D 430 DH=SH(SP):DV=SV(SP):SP=SP-1
38 440 BD(DH,DV)=UN+CC
C9 450 FOR X=-1 TO 1:TH=DH+X
2F 460 TV=DV-1+(X=1):GOSUB 540
4C 470 TV=DV+(X>-1):GOSUB 540
70 480 NEXT:GOTO 420
1D 490 P=3-P:UN=5-UN:GOTO 200
FE 500 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
2A 510 IF BD(TH,TV)=UN+1 THEN LC=1
37 520 IF BD(TH,TV)=UN+2 THEN RC=2
1B 530 RETURN
07 540 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
D5 550 IF BD(TH,TV)=UN THEN SP=SP+1:SH(SP)=TH:SV(SP)=TV
21 560 RETURN
80 570 GOSUB 960:VTAB 21:HTAB 1:CALL - 868:PRINT NN$(P)" WINS!":
       PRINT "CHECKING BOARD"
1E 580 FOR CC=1 TO 2:FE=1:LE=1:EH(1)=CH:EV(1)=CV:EF=0:L=1
C1 590 CD=CH:IF P=2 THEN CD=CV
CD 600 IF CC=1 AND CD=1 OR CC=2 AND CD=11 THEN HH(CC)=0:GOTO 700
4D 610 NE=LE:E=FE
D5 620 DH=EH(E):DV=EV(E)
D9 630 FOR X =-1 TO 1:TH=DH+X:TV=DV-1+(X=1):GOSUB 780:TV=DV+(X>-1):
       GOSUB 780:NEXT
FB 640 IF EF=1 THEN 700
19 650 IF (E=LE) THEN 680
5E 660 E=E+1:IF E=61 THEN E=1
22 670 GOTO 620
F1 680 FE=LE+1:LE=NE:IF FE=61 THEN FE=1
55 690 L=L+1:GOTO 610
0B 700 NEXT:FOR CC=1 TO 2:DH=HH(CC):DV=VV(CC):L=TA(DH,DV,CC):IF DH=0 THEN 740
B0 710 HTAB DH*2-DV+14:VTAB DV+5:PRINT CHR$(105);:IF L=1 THEN 740
C9 720 FOR X=-1 TO 1:TH=DH+X:TV=DV-1+(X=1):GOSUB 750:TV=DV+(X>-1):GOSUB 750:NEXT
3C 730 L=L-1:DH=AH:DV=AV:GOTO 710
1C 740 NEXT:HTAB CH*2-CV+14:VTAB CV+5:PRINT CHR$(105);:GOSUB 1010:GOTO 180
0B 750 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
DD 760 IF TA(TH,TV,CC)=L-1 THEN AH=TH:AV=TV
25 770 RETURN
11 780 IF TH<1 OR TH>11 OR TV<1 OR TV>11 THEN RETURN
9F 790 IF BD(TH,TV)<>UN+CC OR TA(TH,TV,CC)<>0 THEN RETURN
76 800 TA(TH,TV,CC)=L:NE=NE+1:IF NE=61 THEN NE=1
89 810 EH(NE)=TH:EV(NE)=TV
1D 820 CD=TH:IF P=2 THEN CD=TV
11 830 IF CC=1 AND CD=1 OR CC=2 AND CD=11 THEN EF=1:HH(CC)=TH:VV(CC)=TV
20 840 RETURN
F9 850 HGR:HOME:FOR I=6 TO 16:VTAB I:HTAB 20-I
95 860 FOR J=1 TO 11:PRINT CHR$(96);CHR$(32);:NEXT:PRINT CHR$(96);
B0 870 FOR J=0 TO 1:HTAB 18-I+J:PRINT CHR$(99+J+2*(I<>2*INT(I/2)));:
       HTAB 43-I+J:PRINT CHR$(99+J+2*(I=2*INT(I/2)));:NEXT
6A 880 NEXT:HCOLOR=4:FOR I=0 TO 4:HPLOT 92+I,38 TO 14+I,127:
       HPLOT 255+I,38 TO 177+I,127:NEXT
08 890 VTAB 5:HTAB 13:PRINT CHR$(101);
E6 900 FOR J=1 TO 12:PRINT CHR$(103);CHR$(104);:NEXT:PRINT CHR$(99);
22 910 VTAB 17:HTAB 2:PRINT CHR$(102);
0E 920 FOR J=1 TO 12:PRINT CHR$(104);CHR$(103);:NEXT:PRINT CHR$(100);:RETURN
A8 930 HCOLOR=7
F4 940 GV=CV*8+32:GH=92+7*(CH*2-CV)
8F 950 HPLOT GH,GV TO GH+4,GV TO GH+7,GV+4 TO GH+4,GV+7 TO GH,GV+7 TO
       GH-3,GV+3 TO GH,GV:RETURN
5D 960 HCOLOR=4:GOSUB 940
5A 970 VTAB CV+5:HTAB 14+CH*2-CV:A$=CHR$(32)
F2 980 IF BD(CH, CV)>3 THEN A$=CHR$(97+(CV<>2*INT(CV/2))):GOTO 1000
E2 990 IF BD(CH,CV)>0 THEN A$=CHR$(98-(CV<>2*INT(CV/2)))
FD 1000 PRINT A$;:RETURN
85 1010 VTAB 22:HTAB 1:PRINT "PRESS KEY TO QUIT, BUTTON TO PLAY AGAIN"
ED 1020 IF PEEK(49249)>127 THEN 1050
82 1030 IF PEEK(49152)<128 THEN 1020
5F 1040 POKE 49168,0:NORMAL:END
EA 1050 HGR:FOR I=1 TO 11:FOR J=1 TO 11:BD(I,J)=0:TA(I,J,1)=0:
        TA(I,J,2)=0:NEXT:NEXT
E9 1060 RETURN
2F 1070 PRINT "ERROR IN DATA STATEMENTS":END
B2 1080 DATA 216,120,133,69,134,70,132,71,166,7,10
FA 1090 DATA 10,176,4,16,62,48,4,16,1,232,232
F6 1100 DATA 10,134,27,24,101,6,133,26,144,2,230
93 1110 DATA 27,165,40,133,8,165,41,41,3,5,230
BA 1120 DATA 133,9,162,8,160,0,177,26,36,50,48
31 1130 DATA 2,73,127,164,36,145,8,230,26,208,2
C2 1140 DATA 230,27,165,9,24,105,4,133,9,202,208
69 1150 DATA 226,165,69,166,70,164,71,88,76,240,253
05 1160 DATA 255
25 1170 DATA -1
CE 1180 DATA 193,182,156,156,156,156,182,193,128,136,170
0A 1190 DATA 170,170,170,136,128,128,148,213,213,213,213
FC 1200 DATA 148,128,128,128,192,192,192,208,208,148,138
A4 1210 DATA 138,130,130,128,128,128,128,128,128,128,128
EA 1220 DATA 160,160,168,168,148,133,133,129,129,129,128
BB 1230 DATA 128,128,128,170,170,170,170,128,128,128,128
C7 1240 DATA 213,213,213,213,128,128,193,162,156,201,201
25 1250 DATA 190,156,136
23 1260 DATA -1

Program 5: IBM PC/PCjr Beehive

Version by Patrick Parrish, Programming Supervisor

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.

MI 10 KEY OFF:DEF SEG=0:POKE 1047,PEEK (1047) OR 64:GOTO 20
JD 20 GOSUB 350
LC 30 GOSUB 650
NP 40 REM START
QL 50 RANDOMIZE TIMER
HB 60 WINNER=0:PREV.PLAYER=0:ROW=6:COL=6:CB=146:RB=89
MC 70 PLAYER=INT(2*RND+1)
JG 80 LOCATE 12,11:PRINT "Please wait a moment"
KJ 90 FOR J=1 TO 11:FOR K=1 TO 11:HIVE%(J,K)=0:NEXT K:NEXTJ
HG 100 FOR J=1 TO 20:PATHLEN(J)=0:NEXT J
AA 110 FOR J=1 TO 65:PATH%(J)=0:USED%(J)=0:NODE%(J)=0:NEXT J
II 120 GOSUB 700:LOCATE 24,1:PRINT "Player:";
AE 130 REM MAIN
PC 140 IF PREV.PLAYER=PLAYER THEN 170
EP 150 LOCATE 24,8:PRINT "{15 SPACES}";:LOCATE 24,8:PRINT PLAYER$(PLAYER);:
       IF PLAYER=1 THEN PUT(270,130),EYES1,PSET ELSE PUT(270,130),EYES2,PSET
NH 160 PREV.PLAYER=PLAYER
MN 170 PUT(CB,RB),BEE
DN 180 DEF SEG=0:POKE 1050,PEEK(1052)
OK 190 A$=RIGHT$(INKEY$,1):IF LEN(A$)=0 THEN 190
PO 200 PUT(CB,RB),BEE:OCOL=COL:OROW=ROW
MN 210 IF A$=CHR$(77) THEN ROW=ROW+1:COL=COL+1:
       IF ROW>11 OR COL>11 THEN ROW=OROW:COL=OCOL ELSE RB=RB+15:CB=CB+9
CB 220 IF A$=CHR$(75) THEN ROW=ROW-1:COL=COL-1:
       IF ROW<1 OR COL<1 THEN ROW=OROW:COL=OCOL ELSE RB=RB-15:CB=CB-9
CH 230 IF A$=CHR$(72) THEN ROW=ROW-1-(ROW=1):IF ROW<>OROW THEN CB=CB+9:RB=RB-15
HD 240 IF A$=CHR$(80) THEN ROW=ROW+1+(ROW=11):IF ROW<>OROW THEN CB=CB-9:RB=RB+15
MK 250 PUT (CB,RB),BEE
PA 260 IF A$=" " THEN GOSUB 1050 ELSE 180
BB 270 IF USED THEN PUT(CB,RB),BEE:GOTO 140
OG 280 OROW=ROW:OCOL=COL:GOSUB 1110
NG 290 IF POSSIBLE=1 THEN GOSUB 1290
IH 300 IF WINNER=1 THEN 1880
PD 310 LOCATE 24,1:PRINT "Player:";
CC 320 IF PLAYER=1 THEN PLAYER=2 ELSE PLAYER=1
BC 330 ROW=OROW:COL=OCOL:GOTO 140
LO 340 REM INIT
AC 350 CLS:COLR(1)=2:COLR(2)=3
EA 360 DIM ROW.INC%(6),COL.INC%(6)
DH 370 FOR J=1 TO 6:READ ROW.INC%(J),COL.INC%(J):NEXT J
NK 380 DATA -1,-1,0,1,1,1,1,0,0,-1,-1,-1
GP 390 DIM HIVE%(11,11)
EA 400 DIM USED%(65),NODE%(65),PATH%(65),PATHLEN(20)
HK 410 SCREEN 1:COLOR 1,2:DEFINT B
IN 420 DIM HEXA(100),BALL1(100),BALL2(100),EYES1(100),EYES2(100)
NH 430 LINE (30,10)-(21,15),3:LINE-STEP (0,10),3:LINE-STEP (9,5),3
PB 440 LINE-STEP (9,-5),3:LINE-STEP (0,-10),3:LINE-STEP (-9,-5),3
NI 450 LINE (30, 11)-(22,16),2:LINE-STEP (0,9),2:LINE-STEP(8,4),2
JB 460 LINE-STEP (7,-4),6:LINE-STEP(0,-10),6:LINE-STEP (-7,-4),6
FP 470 GET (21,10)-(39,30),HEXA
HE 480 CLS:CIRCLE(30,20),5,COLR(1):PAINT(30,20),COLR(1):GET(25,16)-(35,24),BALL1
HG 490 GOSUB 580:GET (23,12)-(37,25),EYES1
BJ 500 CLS:CIRCLE(30,20),5,COLR(2):PAINT(30,20),COLR(2):GET(25,16)-(35,24),BALL2
MC 510 GOSUB 580:GET(23,12)-(37,25),EYES2:CLS
OA 520 READ X,Y:E=(4+INT((X+7)/8)*Y)/2:DIM BEE(E):BEE(0)=X:BEE(1)=Y:
       FOR I=2 TO E:READ A$:BEE(I)=VAL("&H"+A$):NEXT
JL 530 DATA 26,6,828,A,5AA,802A,95AA,80AA
HK 540 DATA 952A,AA,8002,A0,1500,0,0,0
NP 550 DATA 500,0,0
NL 560 RETURN
BN 570 REM PARTS
KF 560 CIRCLE(26,19),2,1:CIRCLE(34,19),2,1
EF 590 PAINT(26,19),1:PAINT(34,19),1
IE 600 PSET(29,17):LINE-STEP(-2.5,-5):LINE-STEP (-2.5,3)
OC 610 PSET(31,17):LINE-STEP(2.5,-5):LINE-STEP (2.5,3)
AA 620 CIRCLE(30,24),1,1:PAINT(30,24),1
MG 630 RETURN
DE 640 REM GETNAMES
GB 650 LOCATE 12,16:PRINT "BeeHive":PUT (84,84),EYES1:PUT(192,86),EYES2
HC 660 FOR I=1 TO 2:LOCATE 19+I*2-1,6:PRINT "Player"I"'s name";
MI 670 INPUT PLAYER$(I):PLAYER$(I)=LEFT$(PLAYER$(I),15):NEXT I
IM 660 CLS:RETURN
JC 690 REM DRAWSCREEN
LD 700 CLS:Y=7
MF 710 FOR R=1 TO 11
CD 720 X=90-R*9
EC 730 FOR C=1 TO 11
IO 740 X=X+18
BM 750 PUT(X,Y),HEXA,OR
KN 760 NEXT C
HC 770 Y=Y+15
DH 760 NEXT R
GL 790 PSET (297,12),2:GOSUB 930:LINE-STEP (0,10),2
FH 800 PSET (298,12),2:GOSUB 950:LINE-STEP (0,10),2
GG 810 PSET (299,12),2:GOSUB 930:LINE-STEP (0,10),2
NJ 820 PSET (96,12),2:GOSUB 930:LINE-STEP (0,10),2
NH 830 PSET (97,12),2:GOSUB 950:LINE-STEP (0 10),2
OF 840 PSET (98,12),2:GOSUB 930:LINE-STEP (0 10),2
CB 850 Y1=-5:Y2=5:PSET (99,9),3:GOSUB 990
NL 860 PSET (99,10),3:GOSUB 990
CK 870 PSET (100, 11),3:GOSUB 990
CO 880 Y1=5:Y2=-5:PSET (9,173),3:GOSUB 990
AG 890 PSET (9,174),3:GOSUB 990
AE 900 PSET (9,175),3:GOSUB 990
MF 910 RETURN
QO 920 REM UPNDOWN
HC 930 FOR J=1 TO 10
HC 940 LINE-STEP (0, 10),COLR(1)
CG 950 LINE-STEP (-9,5),COLR(1)
OF 960 NEXT J
NB 970 RETURN
PO 980 REM ACROSS
GF 990 FOR J=1 TO 11
KA 1000 LINE-STEP (9,Y1),COLR(2)
LH 1010 LINE-STEP (9,Y2),COLR(2)
GA 1020 NEXT J
IE 1030 RETURN
PN 1040 REM SET PIECE
NB 1050 USED=0
LF 1060 IF HIVE%(ROW,COL)<>0 THEN USED=1:RETURN
LL 1070 HIVE%(ROW,COL)=PLAYER
FA 1080 PUT (CB,RB),BEE:IF PLAYER=1 THEN PUT(CB+1,RB-1),BALL1 ELSE
        PUT(CB+1,RB-1),BALL2
JG 1090 RETURN
GJ 1100 REM CHECKLINE
BI 1110 POSSIBLE=1
CJ 1120 IF PLAYER=1 THEN 1200
EL 1130 FOR ROW=1 TO 6:FF=0:FB=0
IM 1140 FOR COL=1 TO 11
GJ 1150 IF HIVE%(ROW,COL)=PLAYER THEN FF=1
JC 1160 IF HIVE%(12-ROW,COL)=PLAYER THEN FB=1
LE 1170 NEXT COL
HM 1180 IF FF=0 OR FB=0 THEN POSSIBLE=0:ROW=6
PE 1190 NEXT ROW:RETURN
CK 1200 FOR COL=1 TO 6:FF=0:FB=0
JP 1210 FOR ROW=1 TO 11
FC 1220 IF HIVE%(ROW,COL)=PLAYER THEN FF=1
GP 1230 IF HIVE%(ROW,12-COL)=PLAYER THEN FB=1
OB 1240 NEXT ROW
HD 1250 IF FF=0 OR FB=0 THEN POSSIBLE=0:COL=6
LD 1260 NEXT COL
JE 1270 RETURN
EB 1280 REM CHECKWINNER
OA 1290 LOCATE 24,1:PRINT "Checking...{11 SPACES}";
ED 1300 USED.CNTR=0:WINNER=0:NODE.CNTR=0:NODE.TOTAL=0:COUNTER=0
LO 1310 IF PLAYER=1 THEN 1440
II 1320 FOR COL=1 TO 11:ROW=1
JF 1330 IF HIVE%(ROW,COL)<>PLAYER THEN 1410
NO 1340 NODEROW=ROW:NODECOL=COL:GOSUB 1560
GD 1350 IF USED.FLAG=1 THEN 1410
EG 1360 NODE.TOTAL=1:PATH.TOTAL=1:COUNTER=1
OL 1370 PATH%(1)=100*NODEROW+NODECOL
ML 1380 GOSUB 1650
FJ 1390 IF WINNER=1 THEN COL=11
JP 1400 REM SKIP2
LI 1410 NEXT COL
JJ 1420 RETURN
EL 1430 REM CHECK1
FI 1440 FOR ROW=1 TO 11:COL=1
BB 1450 IF HIVE%(ROW, COL)<>PLAYER THEN 1530
NG 1460 NODEROW=ROW:NODECOL=COL:GOSUB 1560
MO 1470 IF USED.FLAG=1 THEN 1530
FO 1480 NODE.TOTAL=1:PATH.TOTAL=1:COUNTER=1
OD 1490 PATH%(1)=100*NODEROW+NODECOL
KH 1500 GOSUB 1650
KB 1510 IF WINNER=1 THEN ROW=11
JJ 1520 REM SKIP1
OE 1530 NEXT ROW
JB 1540 RETURN
CC 1550 REM USEDLOOKUP
QK 1560 USED.FLAG=0:SEARCH=100*NODEROW+NODECOL
NO 1570 LK=0:IF USED.CNTR=0 THEN 1620
FC 1580 FOR LK=1 TO USED.CNTR
KL 1590 IF SEARCH=USED%(LK) THEN USED.FLAG=1:LK=USED.CNTR
AA 1600 NEXT LK
QP 1610 REM SKIPSEARCH
OA 1620 IF USED.FLAG=0 THEN USED.CNTR=USED.CNTR+1:USED%(USED.CNTR)=SEARCH
JA 1630 RETURN
MH 1640 REM CHECKPATH
NO 1650 NODE.CNTR=0
PK 1660 FOR NC=1 TO 6
AD 1670 NODEROW=NODEROW+ROW.INC%(NC):NODECOL=NODECOL+COL.INC%(NC)
PI 1680 IF NODEROW<1 OR NODEROW>11 OR NODECOL<1 OR NODECOL>11 THEN 1750
JL 1690 IF HIVE%(NODEROW,NODECOL)<>PLAYER THEN 1750
OA 1700 GOSUB 1560:IF USED.FLAG=1 THEN 1750
QO 1710 NODE.CNTR=NODE.CNTR+1
OM 1720 NODE.TOTAL=NODE.TOTAL+1:NODE%(NODE.TOTAL)=100*NODEROW+NODECOL
JA 1730 IF (PLAYER=2 AND NODEROW=11) OR (PLAYER=1 AND NODECOL=11) THEN
        WINNER=1:PATH.TOTAL=PATH.TOTAL+1:PATH%(PATH.TOTAL)=100*NODEROW+NODECOL:
        NC=6
KP 1740 REM SKIPNODE
MH 1750 NEXT NC
JA 1760 IF WINNER=1 THEN RETURN
QO 1770 IF NODE.CNTR=0 AND NODE.TOTAL=0 THEN RETURN
MK 1780 IF NODE.CNTR=0 THEN PATH.TOTAL=PATH.TOTAL-PATHLEN(COUNTER):
        PATHLEN(COUNTER)=0:COUNTER=COUNTER-1
AG 1790 IF NODE.CNTR>1 THEN COUNTER=COUNTER+NODE.CNTR-1
KP 1800 NODEROW=INT(NODE%(NODE.TOTAL)/100)
EM 1810 NODECOL=NODE%(NODE.TOTAL)-100*NODEROW
ED 1820 PATH.TOTAL=PATH.TOTAL+1
GA 1830 PATHLEN(COUNTER)=PATHLEN(COUNTER)+1
GA 1840 PATH%(PATH.TOTAL)=NODE%(NODE.TOTAL)
LL 1850 NODE.TOTAL=NODE.TOTAL-1
BB 1860 GOTO 1650
OJ 1870 REM DRAWPATH
MF 1880 LOCATE 1,1:PRINT "THE WINNER: ";:PRINT PLAYER$(PLAYER);
JH 1890 FOR J=1 TO PATH.TOTAL
MF 1900 ROW=INT(PATH%(J)/100):COL=PATH%(J)-100*ROW:CB=COL*18+38+(6-ROW)*9:
        RB=ROW*15-1
FI 1910 IF PLAYER=1 THEN PUT(CB+1,RB-1),BALL1,XOR:PUT(CB,RB-3),EYES1,OR
        ELSE PUT(CB+1,RB-1),BALL2,XOR:PUT(CB,RB-3),EYES2,OR
HC 1920 NEXT J
IK 1930 REM  GOAGAIN
JM 1940 LOCATE 24,1:PRINT "Want to play again (Y/N)?";
NE 1950 A$=INKEY$:IF A$<>"Y" AND A$<>"N" THEN 1950
LO 1960 IF A$="N" THEN SCREEN 0,0,0:WIDTH 80:END ELSE CLS:GOTO 50