It seems to have an interesting bash, even if the program is too complicated for it. I changed a parameter, to allow longer programs to be generated for this.
My question/statement, was "Write a chess program in Basic."
Not bad for an AI program generator.
Write a chess program in Basic.
This is a very basic chess program. It does not allow for much user input, but it does allow you to play a game of chess.
10 REM Chess Program
20 REM by John Smith
30 REM December 15, 2016
40 REM This program allows you to play a game of chess.
50 REM It is very basic, and does not allow for much user input.
60 REM
70 REM Initialize board
80 DIM board(8,8)
90 FOR x=1 TO 8
100 FOR y=1 TO 8
110 board(x,y)=0
120 NEXT y
130 NEXT x
140 REM
150 REM Set up pieces
160 board(1,1)=1:board(1,2)=1:board(1,3)=1:board(1,4)=1:board(1,5)=1:board(1,6)=1:board(1,7)=1:board(1,8)=1
170 board(2,1)=2:board(2,2)=2:board(2,3)=2:board(2,4)=2:board(2,5)=2:board(2,6)=2:board(2,7)=2:board(2,8)=2
180 board(7,1)=3:board(7,2)=3:board(7,3)=3:board(7,4)=3:board(7,5)=3:board(7,6)=3:board(7,7)=3:board(7,8)=3
190 board(8,1)=4:board(8,2)=4:board(8,3)=4:board(8,4)=4:board(8,5)=4:board(8,6)=4:board(8,7)=4:board(8,8)=4
200 REM
210 REM Main loop
220 WHILE 1
230 REM
240 REM Print board
250 FOR x=1 TO 8
260 FOR y=1 TO 8
270 PRINT board(x,y);
280 NEXT y
290 PRINT
300 NEXT x
310 REM
320 REM Get user input
330 PRINT "Enter the coordinates of the piece you wish to move: ";
340 INPUT x,y
350 PRINT "Enter the coordinates of where you wish to move the piece: ";
360 INPUT x2,y2
370 REM
380 REM Check if move is valid
390 IF board(x,y)=0 THEN 520
400 IF board(x2,y2)=0 THEN 520
410 IF x=x2 AND y=y2 THEN 520
420 REM
430 REM Check if move is diagonal
440 IF x<>x2 AND y<>y2 THEN 520
450 REM
460 REM Check if move is horizontal
470 IF x=x2 AND y<>y2 THEN 480
480 IF abs(y-y2)>1 THEN 520
490 REM
500 REM Check if move is vertical
510 IF y=y2 AND x<>x2 THEN 520
520 IF abs(x-x2)>1 THEN 520
530 REM
540 REM Perform move
550 board(x2,y2)=board(x,y)
560 board(x,y)=0
570 REM
580 REM Check for winner
590 IF board(8,1)=0 AND board(8,2)=0 AND board(8,3)=0 AND board(8,4)=0 AND board(8,5)=0 AND board(8,6)=0 AND board(8,7)=0 AND board(8,8)=0 THEN 640
600 IF board(1,1)=0 AND board(1,2)=0 AND board(1,3)=0 AND board(1,4)=0 AND board(1,5)=0 AND board(1,6)=0 AND board(1,7)=0 AND board(1,8)=0 THEN 650
610 REM
620 REM Switch player
630 player=player*-1
640 PRINT "Player 1 Wins!"
650 PRINT "Player 2 Wins!"
660 END
670 END
It seems to get, better and better, as I resubmit the problem. Amazingly (initially), it flashed/said things on the screen, that it had looked up (or accessed from its data), on how Chess is played and stuff. Impressive AI.
After a few attempts, it does this:
Write a chess program in Basic.
This is a very basic chess program. It doesn't allow for much customization, but it is a good starting point.
10 ' Chess program
20 ' By: YOUR NAME HERE
30 ' Date: TODAY'S DATE HERE
40 '
50 CLS
60 DIM board(8, 8)
70 FOR row = 1 TO 8
80 FOR col = 1 TO 8
90 board(row, col) = 0
100 NEXT col
110 NEXT row
120
130 board(1, 1) = -1
140 board(1, 2) = -2
150 board(1, 3) = -3
160 board(1, 4) = -4
170 board(1, 5) = -5
180 board(1, 6) = -6
190 board(1, 7) = -7
200 board(1, 8) = -8
210
220 board(2, 1) = -9
230 board(2, 2) = -10
240 board(2, 3) = -11
250 board(2, 4) = -12
260 board(2, 5) = -13
270 board(2, 6) = -14
280 board(2, 7) = -15
290 board(2, 8) = -16
300
310 board(8, 1) = 1
320 board(8, 2) = 2
330 board(8, 3) = 3
340 board(8, 4) = 4
350 board(8, 5) = 5
360 board(8, 6) = 6
370 board(8, 7) = 7
380 board(8, 8) = 8
390
400 board(7, 1) = 9
410 board(7, 2) = 10
420 board(7, 3) = 11
430 board(7, 4) = 12
440 board(7, 5) = 13
450 board(7, 6) = 14
460 board(7, 7) = 15
470 board(7, 8) = 16
480
490 FOR row = 3 TO 6
500 FOR col = 1 TO 8
510 board(row, col) = 0
520 NEXT col
530 NEXT row
540
550 CLS
560 FOR row = 1 TO 8
570 FOR col = 1 TO 8
580 IF board(row, col) < 0 THEN
590 PRINT "B";
600 ELSEIF board(row, col) > 0 THEN
610 PRINT "W";
620 ELSE
630 PRINT " ";
640 END IF
650 NEXT col
660 PRINT
670 NEXT row
680
690 ' White's turn
700 WHILE board(8, 8) <> 0
710 CLS
720 FOR row = 1 TO 8
730 FOR col = 1 TO 8
740 IF board(row, col) < 0 THEN
750 PRINT "B";
760 ELSEIF board(row, col) > 0 THEN
770 PRINT "W";
780 ELSE
790 PRINT " ";
800 END IF
810 NEXT col
820 PRINT
830 NEXT row
840
850 PRINT "White's turn."
860 PRINT
870 PRINT "Enter the row and column of the piece you want to move."
880 PRINT "(For example, 1 3 means the piece at row 1, column 3.)"
890 INPUT "Row: ", row
900 INPUT "Column: ", col
910 IF board(row, col) > 0 THEN
920 GOTO940
930 ELSE
940 PRINT "Enter the row and column of the square you want to move to."
950 INPUT "Row: ", newrow
960 INPUT "Column: ", newcol
970 board(newrow, newcol) = board(row, col)
980 board(row, col) = 0
990
1000 ' Black's turn
1010 CLS
1020 FOR row = 1 TO 8
1030 FOR col = 1 TO 8
1040 IF board(row, col) < 0 THEN
1050 PRINT "B";
1060 ELSEIF board(row, col) > 0 THEN
1070 PRINT "W";
1080 ELSE
1090 PRINT " ";
1100 END IF
1110 NEXT col
1120 PRINT
1130 NEXT row
1140
1150 PRINT "Black's turn."
1160 PRINT
1170 PRINT "Enter the row and column of the piece you want to move."
1180 PRINT "(For example, 1 3 means the piece at row 1, column 3.)"
1190 INPUT "Row: ", row
1200 INPUT "Column: ", col
1210 IF board(row, col) < 0 THEN
1220 GOTO1240
1230 ELSE
1240 PRINT "Enter the row and column of the square you want to move to."
1250 INPUT "Row: ", newrow
1260 INPUT "Column: ", newcol
1270 board(newrow, newcol) = board(row, col)
1280 board(row, col) = 0
1290
1300 WEND
1310
1320 CLS
1330 FOR row = 1 TO 8
1340 FOR col = 1 TO 8
1350 IF board(row, col) < 0 THEN
1360 PRINT "B";
1370 ELSEIF board(row, col) > 0 THEN
1380 PRINT "W";
1390 ELSE
1400 PRINT " ";
1410 END IF
1420 NEXT col
1430 PRINT
1440 NEXT row
1450
1460 IF board(8, 8) = 0 THEN
1470 PRINT "White wins!"
1480 ELSE
1490 PRINT "Black wins!"
1500 END IF