プレイ日記
Dalen ROARACOW16
So I am working on a rock paper scissors, like game but when I picked rock paper or scissors which were designated as 4, 5, and 6 and when I typed in 4 for rock it said 0 instead of saying win or lose like I set it to do. Does anyone know how to fix it?
0そうだね
プレイ済み
返信[1]
親投稿
Hanzo rzsense
In this case, you need only two variables, your choice and rival's choice. Could you refer to the following description? INPUT CHOICE RIVAL=RND(3)+4 '<- choose value 4-6 at random IF CHOICE==4 THEN IF RIVAL==5 THEN PRINT "WIN" IF RIVAL==6 THEN PRINT "LOSE" IF RIVAL==4 THEN PRINT "TIE" ENDIF 'write conditional branch yourself in case of CHOICE==5 and CHOICE==6
0そうだね
未プレイ
返信[2]
親投稿
Ed CPFace
Hanzo's written the code that you need to use, but I want to add this for your own understanding. The reason it was printing a 0 is in line 11. When you write "... THEN PRINT A==4", it's not making the assignment that you want it to. It's actually evaluating "A==4", deciding that the answer is FALSE (0), and PRINTing that answer.
1そうだね
プレイ済み
返信[3]
親投稿
Ed CPFace
The correct statement would be: IF CHOICE==4 THEN A=4
0そうだね
プレイ済み