Speel eenvoudig Vier-op-'n-rij tegen een menselijke tegenstander op je grafische rekenmachine!
Codes
Licentie: U mag de onderstaande broncode alleen aanpassen voor eigen gebruik. Aangepaste versies van het onderstaande programma kunnen niet worden gedistributeerd. De namen 'Jeroen van der Gun' en 'Blijbol', en de website 'www.blijbol.nl' moeten aanwezig blijven, en moeten eenvoudig vanuit het programma te weergeven zijn. Copyright © 2007 Jeroen van der Gun.
Let op spaties voor regeleinden!
prgmCONNECT4
::
:Full
:{6,7→dim([J]
:getKey
:ClrHome
:Disp "","","Blijbol","Happy business","","www.blijbol.nl
:For(G,1,180
:End
:Disp "","Connect4 v1.0","
:For(G,1,70
:End
:Output(7,1,"(C) 2007 Jeroen
:Output(8,1,"van der Gun
:Pause
:Lbl G
:ClrHome
:For(G,3,8
:Output(G,1,"!
:Output(G,16,"¡
:End
:Fill(0,[J]
:0→F
:4→X
:If rand<.5
:Then
:"{}→Str0
:Else
:"<>→Str0
:End
:Output(1,8,Str0
:Repeat 0
:getKey
:While Ans≠34
:If Ans=22 or Ans=25 or Ans=45 or Ans=105
:Menu("Game paused","Continue",C,"Restart",R,"Quit",A
:If Ans=24
:Then
:If X>1
:Then
:Output(1,2X,"
:X-1→X
:Output(1,2X,Str0
:End
:Else
:If Ans=26
:Then
:If X<7
:Then
:Output(1,2X,"
:X+1→X
:Output(1,2X,Str0
:End
:End
:End
:Lbl C
:getKey
:End
:If not([J](1,X
:Then
:Output(1,2X,"
:Output(2,2X,Str0
:For(G,1,70
:End
:Output(2,2X,"
:Output(3,2X,Str0
:1→Y
:If [J](2,X
:0
:While Ans
:For(G,1,70
:End
:Output(Y+2,2X,"
:Y+1→Y
:Output(Y+2,2X,Str0
:If Y=6
:Then
:0
:Else
:If [J](Y+1,X
:0
:End
:End
:If Str0="<>
:Then
:1→[J](Y,X
:1→C
:Else
:2→[J](Y,X
:2→C
:End
:For(N,max(1,Y-3),min(3,Y
:For(M,max(1,X-3),min(4,X
:If C=[J](N,M) and C=[J](N+1,M+1) and C=[J](N+2,M+2) and C=[J](N+3,M+3
:Then
:Repeat 0
:Output(N+2,2M,"
:Output(N+3,2M+2,"
:Output(N+4,2M+4,"
:Output(N+5,2M+6,"
:For(G,1,40
:If getKey>0
:Goto O
:End
:Output(N+2,2M,Str0
:Output(N+3,2M+2,Str0
:Output(N+4,2M+4,Str0
:Output(N+5,2M+6,Str0
:For(G,1,40
:If getKey>0
:Goto O
:End
:End
:End
:If C=[J](N,M+3) and C=[J](N+1,M+2) and C=[J](N+2,M+1) and C=[J](N+3,M
:Then
:Repeat 0
:Output(N+2,2M+6,"
:Output(N+3,2M+4,"
:Output(N+4,2M+2,"
:Output(N+5,2M,"
:For(G,1,40
:If getKey>0
:Goto O
:End
:Output(N+2,2M+6,Str0
:Output(N+3,2M+4,Str0
:Output(N+4,2M+2,Str0
:Output(N+5,2M,Str0
:For(G,1,40
:If getKey>0
:Goto O
:End
:End
:End
:End
:End
:For(N,max(1,Y-3),min(3,Y
:If C=[J](N,X) and C=[J](N+1,X) and C=[J](N+2,X) and C=[J](N+3,X
:Then
:Repeat 0
:Output(N+2,2X,"
:Output(N+3,2X,"
:Output(N+4,2X,"
:Output(N+5,2X,"
:For(G,1,40
:If getKey>0
:Goto O
:End
:Output(N+2,2X,Str0
:Output(N+3,2X,Str0
:Output(N+4,2X,Str0
:Output(N+5,2X,Str0
:For(G,1,40
:If getKey>0
:Goto O
:End
:End
:End
:End
:For(M,max(1,X-3),min(4,X
:If C=[J](Y,M) and C=[J](Y,M+1) and C=[J](Y,M+2) and C=[J](Y,M+3
:Then
:Repeat 0
:Output(Y+2,2M,"
:Output(Y+2,2M+2,"
:Output(Y+2,2M+4,"
:Output(Y+2,2M+6,"
:For(G,1,40
:If getKey>0
:Goto O
:End
:Output(Y+2,2M,Str0
:Output(Y+2,2M+2,Str0
:Output(Y+2,2M+4,Str0
:Output(Y+2,2M+6,Str0
:For(G,1,40
:If getKey>0
:Goto O
:End
:End
:End
:End
:If F=41
:Then
:Repeat 0
:Output(1,4,"Full Grid
:For(G,1,40
:If getKey>0
:Goto O
:End
:Output(1,4,"
:For(G,1,40
:If getKey>0
:Goto O
:End
:End
:End
:F+1→F
:If Str0="<>
:Then
:"{}→Str0
:Else
:"<>→Str0
:End
:Output(1,2X,Str0
:getKey
:End
:End
:Lbl R
:Menu("Restart game?","No",C,"Yes",G
:Lbl A
:Menu("Quit game?","No",C,"Yes",Q
:Lbl O
:Menu("Game over","Play again",G,"Exit to OS",Q
:Lbl Q
:ClrHome
Een stabiele versie van dit product is uitgebracht.
Het project is aangekondigd op 20 juli 2007.