I have recently downloaded UNO from https://www.ticalc.org/archives/files/fileinfo/430/43087.html and I have been working on it a bit, so far I have it working properly, and I have added some features so far including logging what the other players are doing (like Player 1 played a draw 2 blue). The A.I. has been shown to cheat by immediately playing a card right after drawing from the pile, the human players cannot do this. Is there any way to combat this as all the A.I. moves seem to be blocked if it were to draw
Code:
:"UNO W/ AI - owns
:"22222222222222222222222233333222222222233AAA3322222222333A33A3322222233A3A33A33222223333A3AAA33222233A3AAA3333322233A3A333A3332223333A3A3333322223A333A3A3332222233A333A333222222333A3A33322222222333A3332222222222333332222222222222222222222222222222222222222"
TextColor(BLACK
PlotsOff :FnOff :ZStandard:AxesOff:0→Xmin:0→Ymin:94→Xmax:62→Ymax:ClrHome:ClrDraw:a+b:getKey
Line(34,44,34,62,BLACK
Line(0,43,34,43,BLACK
Text(0,2,"UNO W/ AI
Text(15,10,"PLAY!
Text(30,10,"CLEAN UP
Text(2,100,"IN GAME KEYS:
Text(15,100,"ARROWS: NAVIGATE
Text(30,100,"2ND: SELECT
Text(50,0,"CLEAR/DEL: QUIT/FAST QUIT
Text(65,3,"IN GAME, USE LEFT and RIGHT
Text(80,0,"2 SWITCH FROM DRAW PILE 2
Text(95,0,"CARDS IN HAND. DOTS IN
Text(110,0,"CORNERS INSTEAD OF COLORS.
Text(125,0,"D=DRAW 2. R=REVERSE. S=SKIP
Text(140,0,"W=WILD. W (4 DOTS)=W+DRAW 4.
0→Z
Pt-On(2,53,3,BLACK
Repeat X=21 or X=105 or X=23 or X=45
Repeat X
getKey→X
End
Pt-Off(2,53-6Z,3
Z-(X=25 and Z)+(X=34 and not(Z→Z
Pt-On(2,53-6Z,3,BLACK
End
If Z or X=23 or X=45
Goto 2
ClrDraw
ClrHome
Repeat N≤8 and N≥2
Disp "HOW MANY PLAYERS
Input "(2-8)?",N
ClrHome
End
Output(4,5,"LOADING...
seq(round(X/2,0)+(X=26),X,0,26→L₆
For(X,1,3
augment(L₆,seq(round(X/2,0)+(X=26),X,0,26→L₆
End
L₆+seq(1+(X>27)+(X>54)+(X>81),X,1,108→L₆
rand(108→L₅
SortA(L₅,L₆
ClrList L₃,L₄
DelVar [J]{2N,24→dim([J]
For(X,108-7N,108-N,N
For(Y,1,N
real(L₆(X+Y→[J](2Y-1,8+(X-108)/N
imag(L₆(X+Y→[J](2Y,8+(X-108)/N
End
End
108-7N→dim(L₆
L₆(Ans→L₄(1
dim(L₆)-1→dim(L₆
1→R
1→P
While 9<real(L₆(1
rand(dim(L₆→L₅
SortA(L₅,L₆
End
2N→dim(L₅
Fill(0,L₅
ClrHome
For(X,1,N
7→L₅(X
Disp "PLAYER   IS A
Output(1,8,X
Output(2,1,"*BOT
Output(3,2,"HUMAN
2→Y
Repeat Z=21 or Z=105 or Z=23 or Z=45
Repeat Z
getKey→Z
End
Output(Y,1,"
Y-(Z=25 and Y=3)+(Z=34 and Y=2→Y
Output(Y,1,"*
End
ClrHome
If Z=23 or Z=45
Goto 2
Y-2→L₅(X+N
End
For(X,0,8,8
For(Y,0,1
54+8Y
Line(1+X,Ans,5+X,Ans,BLACK
Line(X+6Y,55,X+6Y,61,BLACK
End
End
Pt-On(3,58,3,RED
Text(1,45,"PLAYER     'S TURN
Horizontal 12,RED
Text(117,0,"NUM. OF CARDS
For(X,1,N
Text(134+15(X>4),48X-48-192(X>4),"P",X,":
End
StorePic 9
While X
If 5≥dim(L₆
Then
L₆(1→X
L₆(dim(L₆→L₆(1
dim(L₆)-1→dim(L₆
augment(L₆,L₄→L₆
rand(dim(L₆→L₄
SortA(L₄,L₆
ClrList L₄
L₆(1→L₄(1
X→L₆(1
End
If L₅(P+N
Then
RecallPic 9
real(L₆(1
If Ans>9
sub("DRSWW",Ans-9,1
Text(3,28,Ans
imag(L₆(1
If Ans=1:Pt-On(9+8fPart(Ans/2),61-6(Ans≥3),1,BLUE:If Ans=2:Pt-On(9+8fPart(Ans/2),61-6(Ans≥3),1,RED:If Ans=3:Pt-On(9+8fPart(Ans/2),61-6(Ans≥3),1,GREEN:If Ans=4:Pt-On(9+8fPart(Ans/2),61-6(Ans≥3),1,ORANGE
Text(1,96,P
For(X,1,N
Text(134+15(X>4),48X-28-192(X>4),L₅(X
End
Text(117,120,"ORDER:
If R<0
Text(117,180,"DESCENDING
If R≥0
Text(117,180,"ASCENDING
Pause
For(Z,0,15(13≤L₅(P)),15
For(X,1,(Z≠0)(L₅(P)-12)+not(Z)(L₅(P)-(L₅(P)-12)(13≤L₅(P
For(Y,0,1
8X+6Y-8
Line(8X-7,36+8Y-Z,8X-3,36+8Y-Z,BLACK
Line(Ans,37-Z,Ans,43-Z,BLACK
End
[J](2P-1,X+12(Z≠0
If Ans>9
sub("DRSWW",Ans-9,1
Text(53+40(Z≥13),22X-17+int(.5X),Ans
If 13≠[J](2P-1,X+12(Z≠0
Then
[J](P2,X+12(Z≠0
For(Y,0,4(14=[J](2P-1,X+12(Z≠0
If Ans=1
Pt-On(8fPart(Ans/2)+8X-7,42.5-Z-6(Ans≥3),1,BLUE:If Ans=2:Pt-On(8fPart(Ans/2)+8X-7,42.5-Z-6(Ans≥3),1,RED:If Ans=3:Pt-On(8fPart(Ans/2)+8X-7,42.5-Z-6(Ans≥3),1,GREEN:If Ans=4:Pt-On(8fPart(Ans/2)+8X-7,42.5-Z-6(Ans≥3),1,ORANGE:
Y+1
End
End
End
End
Pt-On(3,51,3,BLACK
0→Y
0→Z
Repeat Ans
Repeat X
getKey→X
End
If (X=24 and Y) or (X=26 and Y+12(Z≠0)<L₅(P
Then
Pt-Off(8Y+8not(Y)-5,47+4not(Y)-Z,3
Y+X-25→Y
If Y=13
Then
15→Z
1→Y
End
If Z=15 and not(Y
Then
12→Y
0→Z
End
Pt-On(8Y+8not(Y)-5,47+4not(Y)-Z,3,BLACK
End
0
If X=23
Goto 2
If X=45
Then
0→P
0→X
3
End
If X=21 and not(Y
Then
real(L₆(dim(L₆→[J](P2-1,1+L₅(P
imag(L₆(dim(L₆→[J](P2,1+L₅(P
1+L₅(P→L₅(P
dim(L₆)-1→dim(L₆
ClrDraw
Output(4,1,"PLAYER
Output(4,8,P
Output(6,1,"DREW A CARD
Pause
ClrHome
End
If Y and X=21
Then
If [J](2P-1,Y+12(Z≠0))≥13 or [J](2P,Y+12(Z≠0))=imag(L₆(1)) or [J](2P-1,Y+12(Z≠0))=real(L₆(1
Then
Y+12(Z≠0→Y
L₆(1→L₄(1+dim(L₄
[J](P2-1,Y)+[J](P2,Y→L₆(1
L₅(P)-1→L₅(P
For(X,Y+1,Ans+1
[J](P2-1,X→[J](P2-1,X-1
[J](P2,X→[J](P2,X-1
End
3
End
End
End
Y-12(Z≠0
Pt-Off(8Ans+8not(Ans)-5,47+4not(Ans)-Z,3
Else
Output(4,1,"AI   IS THINKING...
Output(4,4,P
1→dim(L₃
0→L₃(1
For(X,1,L₅(P
If [J](2P-1,X)<13 and ([J](2P-1,X)=real(L₆(1)) or [J](2P,X)=imag(L₆(1
X→L₃(1+dim(L₃
End
If 1=dim(L₃
Then
For(X,1,L₅(P
If 13≤[J](2P-1,X
X→L₃(1+dim(L₃
End
End


"This is the A.I. Draw code"
If 1=dim(L₃
Then
1+L₅(P→L₅(P
real(L₆(dim(L₆→[J](2P-1,L₅(P
imag(L₆(dim(L₆→[J](2P,L₅(P
dim(L₆)-1→dim(L₆
ClrHome
Output(4,1,"PLAYER
Output(4,8,P
Output(6,1,"DREW A CARD
Pause
ClrHome
Else
"The code has ended but it will still play the card



randInt(2,dim(L₃→X
L₆(1→L₄(1+dim(L₄
[J](2P-1,L₃(X))+[J](2P,L₃(X→L₆(1
For(Y,L₃(X)+1,L₅(P
[J](2P-1,Y→[J](2P-1,Y-1
[J](2P,Y→[J](2P,Y-1
End
L₅(P)-1→L₅(P
End
End
If P
L₅(P→X
If XY
Then
real(L₆(1
If Ans<10
Then
Output(6,1,"PLAYED A "
Output(6,10,Ans
End
If Ans=11
Then
­R→R
Output(6,1,"PLAYED A REVERSE
End
If Ans≥13
Then
If L₅(P+N
Then
For(X,0,1
46+8X
Line(17,Ans,21,Ans,BLACK
Line(6X+16,47,6X+16,53,BLACK
End
Text(25,50,"W
Text(25,75,"WHICH CORNER?
2→Y
Pt-On(17,53
Repeat X=21
Repeat X
getKey→X
End
If (X=24 and fPart(Y/2)=.5) or (X=25 and Y≥3) or (X=34 and Y≤2) or (X=26 and not(fPart(Y/2
Then
Pt-Off(17+8fPart(Y/2),53-6(Y≥3
Y+(X=24)+2(X=34)-2(X=25)-(X=26→Y
Pt-On(17+8fPart(Y/2),53-6(Y≥3
End
If X=21
Y+real(L₆(1→L₆(1
End
Else
Output(4,1,"AI   IS THINKING...
Output(4,4,P
4→dim(L₃
Fill(0,L₃
For(X,1,L₅(P
[J](2P,X
L₃(Ans)+(13>[J](2P-1,X→L₃(Ans
End
max(L₃→Y
If Y
Then
For(X,1,4
X+8(Y=L₃(X→X
End
Else
randInt(10,13→X
End
X-9+real(L₆(1→L₆(1
ClrHome
End
End
Output(4,1,"PLAYER                 
Output(4,8,P
real(L₆(1
If Ans>9 and not(fPart(Ans/2
Then
R+P-NR(P=.5(N+1+RN-R→P
real(L₆(1
Ans→θ
For(X,1,2(θ=10)+4(θ=14
real(L₆(dim(L₆→[J](P2-1,1+L₅(P
imag(L₆(dim(L₆→[J](P2,1+L₅(P
dim(L₆)-1→dim(L₆
1+L₅(P→L₅(P
Output(6,1,"PLAYED A DRAW"
Output(6,15,2+2(θ=14)
End
End
real(L₆(1
Ans→θ
If θ=13
Output(6,1,"PLAYED A WILD
If θ=12
Output(6,1,"PLAYED A SKIP
imag(L₆(1
If Ans=1:Output(7,1,"BLUE":If Ans=2:Output(7,1,"RED":If Ans=3:Output(7,1,"GREEN":If Ans=4:Output(7,1,"YELLOW
DelVar θ
Pause
ClrHome
End
If X
R+P-NR(P=.5(N+1+RN-R→P
ClrDraw
End
ClrList L₄,L₆
1→dim(L₆
Text(15,0,"PLAYER:NUM. OF CARDS:SCORE
For(X,1,N
Text(15X+15,0,X,sub(":AI:HU",3L₅(N+X)+1,3
0→L₄(X
For(Y,1,L₅(X
[J](2X-1,Y
L₄(X)+Ans(Ans≤9)+20(Ans>9)+30(Ans>12→L₄(X
End
Text(15X+15,39,L₅(X
Text(15X+15,72,L₄(X
End
If not(P
Then
min(L₄→Y
For(X,1,N
If Y=L₄(X
X→L₆(1+dim(L₆
End
If 2<dim(L₆
Then
Text(­1,0,0,"TIE:
For(X,2,dim(L₆
Text(­1,0,1+11X,L₆(X),":
End
Else
L₆(2→P
End
End
If P
Text(­1,0,0,"PLAYER ",P," WINS!
Repeat getKey
End
Lbl 2
ClrDraw
DelVar NDelVar PDelVar RDelVar XDelVar YDelVar ZDelVar Pic9DelVar [J]ClrList L₃,L₄,L₅,L₆
SetUpEditor
Output(1,1,"

I've also noticed that it always gets a card it can play afterwards

The A.I draw code specifically

Code:
If 1=dim(L₃
Then
1+L₅(P→L₅(P
real(L₆(dim(L₆→[J](2P-1,L₅(P
imag(L₆(dim(L₆→[J](2P,L₅(P
dim(L₆)-1→dim(L₆
ClrHome
Output(4,1,"PLAYER
Output(4,8,P
Output(6,1,"DREW A CARD
Pause
ClrHome
Else

̶E̶d̶i̶t̶:̶ ̶f̶o̶u̶n̶d̶ ̶t̶h̶e̶ ̶i̶s̶s̶u̶e̶,̶ ̶ ̶f̶o̶r̶ ̶w̶h̶a̶t̶e̶v̶e̶r̶ ̶r̶e̶a̶s̶o̶n̶ ̶i̶t̶ ̶w̶a̶s̶ ̶p̶r̶e̶v̶e̶n̶t̶i̶n̶g̶ ̶t̶h̶e̶ ̶n̶e̶x̶t̶ ̶p̶l̶a̶y̶e̶r̶ ̶s̶i̶g̶n̶i̶f̶i̶e̶r̶ ̶f̶r̶o̶m̶ ̶c̶o̶u̶n̶t̶i̶n̶g̶ ̶u̶p̶/̶d̶o̶w̶n̶ ̶s̶o̶ ̶i̶t̶ ̶j̶u̶s̶t̶ ̶h̶a̶d̶ ̶t̶o̶ ̶b̶e̶ ̶a̶d̶d̶e̶d̶ ̶i̶n̶t̶o̶ ̶t̶h̶e̶ ̶d̶r̶a̶w̶ ̶c̶a̶r̶d̶ ̶c̶o̶d̶e̶,̶ ̶ ̶s̶o̶m̶e̶h̶o̶w̶ ̶i̶t̶ ̶a̶l̶s̶o̶ ̶m̶a̶g̶i̶c̶a̶l̶l̶y̶ ̶r̶e̶m̶o̶v̶e̶d̶ ̶t̶h̶e̶ ̶o̶t̶h̶e̶r̶ ̶c̶h̶e̶a̶t̶ ̶t̶h̶e̶ ̶A̶.̶I̶.̶ ̶h̶a̶d̶ ̶w̶i̶t̶h̶ ̶h̶a̶v̶i̶n̶g̶ ̶a̶ ̶u̶s̶e̶f̶u̶l̶ ̶c̶a̶r̶d̶ ̶p̶o̶p̶ ̶i̶n̶t̶o̶ ̶t̶h̶e̶i̶r̶ ̶h̶a̶n̶d̶.̶

Was wrong, still a problem
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement