# Spies in the Computer

Essentially, all models are wrong, some are useful.
George Box

# Article & computer game

Spies in the computer is a computer game which can be easily programmed (Basic Program)and used to help learners with problem solving, models, Cartesian coordinates, Pythagoran theorem, number value, rounding numbers, and computer coding. The article below explains it all!

Enjoy!

## BASIC Code for spies in the computer!

10 HOME : REM CLEARS THE SCREEN
20 PRINT
30 PRINT "THIS IS A GAME OF SPIES IN A COMPUTER."
40 PRINT "YOU ARE TO FIND THE SPY OR SPIES"
50 PRINT "THAT ARE HIDDEN ON A 10 X 10 GRID."
60 PRINT
70 PRINT "YOU CAN GUESS FROM 0,0 TO 10,10."
80 PRINT "ALL GUESSES SHOULD BE"
90 PRINT "TWO NUMBERS SEPARATED BY A COMMA."
100 PRINT
110 PRINT "THE FIRST NUMBER WILL BE THE "
120 PRINT "DISTANCE RIGHT OF 0,0."
130 PRINT "AND THE SECOND NUMBER WILL BE"
140 PRINT "THE DISTANCE UP FROM 0,0."
150 PRINT
160 PRINT
170 PRINT “HOW MANY SPIES DO YOU WANT?”
180 INPUT S: REM ALLOWS YOU TO ENTER THE NUMBER OF SPIES
190 DIM P(S.2)
200 PRINT
210 PRINT
220 PRINT
230 GOSUB 530
240 T = 0
250 T = T + 1
260 PRINT
270 PRINT "IT IS TURN NUMBER ”;T
280 PRINT "WHAT IS YOUR GUESS?"
290 INPUT M,N
300 REM CHECK INPUT AGAINST SPIES LOCATION
310 FOR L = 1 to S: REM LOOPS FOR S # OF SPIES
320 IF P(L,1) = -1 THEN 400: REM CHECK TO SEE IF SPY FOUND
330 IF P(L,1) < > M THEN 380: REM CHECK DISTANCE RIGHT
340 IF P(L,2) < > N THEN 380: REM CHECK DISTANCE UP
350 P(L,1) =-1. REM MARK FOUND SPY
360 PRINT “YOU HAVE FOUND SPY “ L
370 GOTO 400
380 D = SQR (P(L,1) - M) ^ 2 + (P(L,2) - N) ^2): REM THANKS PYTHAGORAS
390 PRINT “YOUR DISTANCE FROM SPY “ L “IS “ ; INT (D * 100 + .5)/100
400 NEXT L
410 REM CHECK SEE IF ALL SPIES FOUND
420 FOR J = 1 TO S
430 IF P(J,1) < > -1 GOTO 250
440 NEXT J
450 PRINT
460 PRINT "YOU HAVE FOUND ALL THE SPIES IN " ,T; “TURNS!”
520 END
530 REM PLACES SPIES ON GRID
540 FOR J= 1 TO 2
550 FOR L = 1 TO S
560 P(L,J) = I NT (10 * RND (1))
570 NEXT L
580 NEXT J
590 RETURN

Top