====== CONNECT FOUR ====== {{ :otros:Connect_four_p1.jpg?600 |}} ===== Info ===== ^ Author | Wayne Gordon | ^ Computer | Amstrad PCW 8256 / 8512 / 9512 | ^ Year | 1987 | ^ Gender | Board | ^ Controls | Keyboard | ^ Languages | English | ^ State | [[preserved|Preserved]] | ===== Screenshots ===== {{:otros:Connect_four_screenshot01.png?220}} {{:otros:Connect_four_screenshot02.png?220}} {{:otros:Connect_four_screenshot03.png?220}} {{:otros:Connect_four_screenshot04.png?220}} ===== Description ===== This is a PCW implementation of the classic two player game, which you can play against the computer or a friend. It is possible to play any number of games at one of two levels: easy or hard. When your name appears in reverse video it's your turn to play. Use the T and Y keys to move the marker along the top of the board, press the space bar to drop a tile and try to connect a line of four to win the game. You are informed when someone has won and situations where no one can win are checked and a draw is announced. Be careful: your Amstrad isn't easy to beat, especially at level two, and hours of careful planning can be wiped out in one move. On the contrary, a little thought and strategy can get you out of the most difficult situations. ===== Listing ===== * **__Listing - CONNECTF.BAS__** 10 REM Connect Four 20 REM By Wayne Gordon 30 REM (c) Computing with the Amstrad 40 REM ------------ PCW ------------- 50 GOSUB 1150:GOSUB 1320 60 REM Scan keyboard 70 PRINT FNpo$(0,5,"One or Two Players ¯1/2® ");:INPUT"",pl 80 IF pl=1 THEN pL1$="Amstrad":GOTO 100 90 PRINT FNpo$(0,5,"Player1 enter your name:" );:INPUT pL1$ 100 PRINT e$+"A";e$+"K";"Player 2 enter your name:";:INPUT pL2$ 110 PRINT e$+"A";e$+"K";"Out of how many game/s "; 120 INPUT ga:IF ga/2=INT(ga/2) THEN PRINT e$+"A";e$+"K":GOTO 110 130 IF pl=1 THEN PRINT e$+"A";e$+"K";"Level ¯1/2® ";:INPUT level 140 PRINT e$+"A";e$+"K"; 150 IF level=1 THEN level=4 ELSE level=5000 160 pL1$=MID$(pL1$,1,7):pL2$=MID$(pL2$,1,7) 170 REM Who's go (even no.=player2) 180 PRINT FN po$(19,28,"T = Left Y = Right Space Bar = Drop") 190 PRINT e$+"r";FNpo$(0,6,"Out of");ga;"games:";e$+"u" 200 GOSUB 1230 210 x=30:count=1+count2 220 p1L=count/2:p2L=INT(count/2):IF p1L<>p2L THEN p1L=1 ELSE p1L=0 230 IF p1L THEN te$=STRING$(2,188):PRINT e$+"p";FNpo$(21,11,pL1$);e$+"q";FNpo$(64,11,pL2$):ELSE te$=STRING$(2,187):PRINT FNpo$(21,11,pL1$);e$+"p";FNpo$(64,11,pL2$);e$+"q"" 240 PRINT FNpo$(x,9,"");e$+"e"; 250 IF pl=1 THEN IF p1L THEN GOSUB 970:a$=CHR$(32):GOTO 290 260 a$=INKEY$:IF a$="" THEN 250 270 IF LOWER$(a$)="t" THEN IF x>32 THEN x=x-5 280 IF LOWER$(a$)="y" THEN IF x<58 THEN x=x+5 290 PRINT FNpo$(x,9,"");e$+"e"; 300 IF a$=CHR$(32) THEN PRINT e$+"f":GOSUB 490:GOTO 320 310 GOTO 260 320 REM Move 330 count=count+1 340 valid=1:edd=0:y=2 350 WHILE valid 360 y=y+1 370 IF y>10 OR FNst$<>"" THEN PRINT STRING$(2,7):count=count-1:IF p1L<>p2L THEN cont1=cont1+1:whe=whe-1:GOTO 240:ELSE cont2=cont2+1:whe=whe-1:GOTO 240 380 IF state$(x,y)="" THEN 430 390 IF edd THEN state$(x,y)=te$:valid=0:IF test=0 THEN PRINT CHR$(7) 400 WEND 410 IF count>=6 GOTO 550 420 GOTO 220 430 REM Drop coin 440 PRINT FNpo$(x,(y-4)*2+9," ");FNpo$(x,(y-3)*2+9,te$) 450 IF y=10 THEN edd=1:GOTO 390 460 IF state$(x,y+1)<>"" THEN edd=1:GOTO 390 470 GOTO 360 480 REM Pick up coin 490 IF INT(count/17)=count/17 THEN xco=xco+4 500 IF yco>24 THEN yco=17 510 IF p1L THEN PRINT FNpo$(xco,yco," "):cont1=cont1-1:PRINT FNpo$(4,26,"");cont1 ELSE PRINT FNpo$(xco+78,yco," "):cont2=cont2-1:PRINT FNpo$(82,26,"");cont2 520 IF count=33 THEN PRINT FNpo$(10,17," ") ELSE IF count=17 THEN PRINT FNpo$(2,24," ");FNpo$(6,24,te$) 530 whe=whe+1:IF whe=2 THEN whe=0:yco=yco+1 540 RETURN 550 REM check1 560 gam=0:game=0 570 IF test=1 THEN te$=STRING$(2,188) ELSE IF test=2 THEN te$=STRING$(2,187) 580 g=1:FOR f=x+5 TO x+15 STEP 5:xc(g)=f:yc(g)=y-g:g=g+1:NEXT:GOSUB 750 590 FOR f=1 TO 3:yc(f)=y+f:NEXT:GOSUB 750 600 FOR f=1 TO 3:yc(f)=y:NEXT:GOSUB 750 610 g=1:FOR f=x-5 TO x-15 STEP -5:xc(g)=f:yc(g)=y+g:g=g+1:NEXT:GOSUB 750 620 FOR f=1 TO 3:yc(f)=y-f:NEXT:GOSUB 750 630 FOR f=1 TO 3:yc(f)=y:NEXT:GOSUB 750 640 g=1:FOR f=x+5 TO x+10 STEP 5:xc(g)=f:yc(g)=y-g:g=g+1:NEXT:yc(3)=y+1:xc(3)=x-5:GOSUB 750 650 FOR f=1 TO 2:yc(f)=y+f:NEXT:yc(3)=y-1:GOSUB 750 660 FOR f=1 TO 3:yc(f)=y:NEXT:GOSUB 750 670 g=1:FOR f=x-10 TO x-5 STEP 5:xc(g)=f:yc(g)=y+3-g:g=g+1:NEXT:xc(3)=x+5:yc(3)=y-1:GOSUB 750 680 FOR f=1 TO 2:yc(f)=y-3+f:NEXT:yc(3)=y+1:GOSUB 750 690 FOR f=1 TO 3:yc(f)=y:NEXT:GOSUB 750 700 FOR f=1 TO 3:yc(f)=y+f:xc(f)=x:NEXT:GOSUB 750 710 IF test THEN 1110 720 IF game THEN 800 730 IF count>=49 THEN PRINT FNpo$(36,5,"Draw::"):FOR f=1 TO 3000:NEXT:GOTO 860 740 GOTO 220 750 gam=0:f=1:REM Check2 760 WHILE (NOT game AND f<4) 770 IF state$(xc(f),yc(f))=te$ THEN gam=gam+1 ELSE f=4 780 IF gam=3 THEN game=1 790 f=f+1:WEND:RETURN 800 REM Game=Won 810 game1=game1+1 820 IF game1/2<>INT(game1/2) THEN count2=1 ELSE count2=0 830 IF p1L THEN pL1=pL1+1 ELSE pL2=pL2+1 840 IF pL1=ROUND(ga/2) OR pL2=ROUND(ga/2) THEN 900 850 PRINT FNpo$(21,9,"GAME:");pL1;FNpo$(65,9,"GAME:");pL2 860 PRINT FNpo$(31,5,"Press any key to continue !") 870 WHILE INKEY$="":WEND:PRINT e$+"A"+e$+"K" 880 FOR f=30 TO 66 STEP 5:FOR g=1 TO 10:state$(f,g)="":PRINT FNpo$(f,g*2+9," ":NEXT g,f 890 GOTO 200 900 REM Who Won Overall ? 910 IF p1L THEN te$=pL1$ ELSE te$=pL2$ 920 PRINT FNpo$(37,4,te$);" you WON !" 930 PRINT STRING$(1,7):FOR f=1 TO 1000:NEXT:PRINT STRING$(7,7) 940 PRINT: INPUT"Y====RUN again";a$:IF UPPER$(a$)="Y" THEN PRINT e$+"e":RUN 950 PRINT c$;"Don't give up !!!!!!";e$+"e" 960 END 970 REM Amstrad's Move 980 temp=y:temp$=te$:PRINT e$+"f"; 990 IF count<6 THEN 1040 1000 test=1:GOSUB 1070:IF game THEN 1050 1010 test=2:GOSUB 1070:IF game THEN 1030 1020 GOTO 1040 1030 RANDOMIZE PEEK(64504!):k=INT(RND*level)+1:IF k=3 THEN 1040 ELSE 1050 1040 RANDOMIZE PEEK(64504!):x=datt(INT(RND*7)+1) 1050 IF FNst$<>"" THEN 1040 1060 te$=temp$:y=temp:test=0:RETURN 1070 x=25 1080 x=x+5:IF FNst$<>"" THEN 1080 1090 IF x>60 THEN RETURN 1100 te$="":GOTO 340 1110 IF game THEN IF test=1 THEN RETURN 1120 IF game THEN IF test=2 THEN RETURN 1130 IF x<61 THEN 1080 1140 RETURN 1150 REM init- 1160 e$=CHR$(27):c$=e$+"H"+e$+"E":PRINT c$ 1170 DEF FNpo$(x,y,t$)=e$+"Y"+CHR$(32+y)+CHR$(32+x)+t$ 1180 DEF FNst$=state$(x,4) 1190 DIM state$(80,14) 1200 FOR f=1 TO 7:READ datt(f):NEXT 1210 DATA 30,35,40,45,50,55,60 1220 RETURN 1230 REM Draw Coins 1240 yco=17:xco=2:cont1=24:cont2=24:whe=0 1250 FOR x=2 TO 11 STEP 4:FOR y=17 TO 24 1260 PRINT FNpo$(x,y,STRING$(2,188)) 1270 NEXT y,x 1280 FOR x=88 TO 77 STEP -4:FOR y=17 TO 24 1290 PRINT FNpo$(x,y,STRING$(2,187)) 1300 NEXT y,x 1310 RETURN 1320 REM screen 1330 t1$=STRING$(7,138):t2$=STRING$(4,138)+CHR$(142):t4$=STRING$(7,32)+CHR$(133) 1340 t5$=STRING$(4,32)+CHR$(133):t6$=STRING$(4,138)+CHR$(143):FOR f=1 TO 7:t7$=t7$+t2$:NEXT 1350 FOR f=1 TO 7:t8$=t8$+t5$:NEXT:t9$=STRING$(4,138)+CHR$(139):FOR f=1 TO 7:t10$=t10$+t9$:NEXT 1360 FOR f=1 TO 7:t11$=t11$+t6$:NEXT:x=20:y=10 1370 PRINT TAB(39);e$+"p";" CONNECT 4";e$+"q" 1380 PRINT FNpo$(x,y,CHR$(134)+t1$+CHR$(142)+t7$+t1$+CHR$(140)):y=y+1 1390 PRINT FNpo$(x,y,CHR$(133)+t4$+t8$+t4$):y=y+1 1400 PRINT FNpo$(x,y,CHR$(131)+t1$+CHR$(143)+t11$+t1$+CHR$(137)):y=y-1:x=28 1410 FOR f=1 TO 6:y=y+2 1420 PRINT FNpo$(x,y,CHR$(133)+t8$) 1430 PRINT FNpo$(x,y+1,CHR$(135)+t11$);FNpo$(63,y+1,CHR$(141)) 1440 NEXT 1450 PRINT FNpo$(x,y,CHR$(133)+t8$) 1460 x=19:PRINT FN po$(x,y+1,STRING$(2,138)+t1$+CHR$(139)+t10$+t1$+STRING$(2,138)) 1470 RETURN ===== Controls ===== T = LEFT Y = RIGHT SPACE = DROP ===== Loading the program ===== 1.- Insert the CP/M disc on side 2 2.- Write BASIC and wait for it to load 3.- Remove the CP/M disk and insert the disk containing the Connect four game 4.- Type run "Connectf" and press the "ENTER" key" ===== Extras ===== * Listing of the program in a large-circulation magazine of the time {{:otros:Connect_four_01.jpg?180}} {{:otros:Connect_four_02.jpg?175}} ===== Download ===== * {{:otros:Connect_four.zip|Connect four}}(game in dsk format, compressed with zip)