Last active
February 12, 2019 08:49
-
-
Save Tamakichi/8002afeeb1c76ff935d1c87eed397751 to your computer and use it in GitHub Desktop.
ArduinoBASIC_STM32 石取りゲーム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 REM 石取りゲーム | |
10 PRINT "石の数?";: INPUT n: IF n<1 THEN GOTO 10 | |
20 PRINT "1回に取れる最大の石の数?";: INPUT m: IF m<1 THEN GOTO 20 | |
30 PRINT "あなたは先手(1)、後手(2)?";: INPUT t | |
40 IF t<>1 AND t<>2 THEN GOTO 30 | |
50 ns=n: t=t-1 | |
60 GOSUB 500: REM 石の状態表示 | |
70 IF t MOD 2=1 THEN GOSUB 300: REM コンピュータ | |
80 IF t MOD 2=0 THEN GOSUB 400: REM 人間 | |
90 t=t+1: n=n-x | |
100 IF n<>0 THEN GOTO 60 | |
110 IF t MOD 2=1 THEN PRINT "あなたの負けです!" | |
120 IF t MOD 2=0 THEN PRINT "私の負けです!" | |
130 GOTO 600: REM ゲーム終了 | |
140 IF t MOD 2=0 THEN PRINT "私の負けです!" | |
150 GOTO 600: REM ゲーム終了 | |
300 REM コンピュータ | |
310 x=(n-1) MOD (m+1): IF x=0 THEN x=1 | |
320 PRINT "私は ";x;"個の石を取ります." | |
330 RETURN | |
400 REM 人間 | |
410 PRINT "何個取りますか? "; | |
420 INPUT x: IF x<=0 OR x>m OR x>n THEN GOTO 410 | |
430 RETURN | |
500 REM 石の状態表示 | |
510 PRINT "[残り";n;":"; | |
520 FOR i=1 TO ns | |
530 IF i<=n THEN PRINT "●"; | |
540 IF i>n THEN PRINT "〇"; | |
550 NEXT i | |
560 PRINT "]" | |
570 RETURN | |
600 REM ゲーム終了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment