NAME THE GRAPH


This is a game of logic. You have an aim, to find the equation of the graph that is drawn on the screen. You key in numbers to represent an equation. You can see straight away whether you are getting closer to your goal as the graph of the equation you keyed in is drawn on the screen.

By making the three numbers required larger and smaller, positive and negative, you can see how it effects the graph and hopefully, you can watch your graph getting closer and closer to the target graph until you hit it.

If you give up you will be told the answer, but don't cheat.

How to play

All graphs drawn are of the type

   Y = Ax2 + Bx + C

Where A, B and C are constants (that is numbers that can be positive or negative). For example, the equation might be

   Y = -2x2 + 3x - 5

and in this case A would be equal to -2, B equal to 3 and C to -5.

You must key in three numbers all at once on the same line and separated by commas. Press RETURN only after you have keyed in all three numbers. In the example above you would key in

   -2, 3, -5 then RETURN

Then the graph of this expression is drawn and you must make another guess. If you cannot guess the answer key in

WHAT, IS, IT then RETURN

(remember to put in the commas) and you will be given the answer and the program ends.

If you guess the answer correctly then press the escape key and a new graph will be drawn.

It is more fun if you find out how to do it by trial and error, but if you want a hint to get you started then this is it. (Skip the next paragraph if you do not want to know)

If the first number (A) is positive, the graph will point upwards (u shape), and if it is negative the graph will point downwards (n shape).

Programming hints

The graphs are plotted with the origin (zero, zero point) at the middle of the screen by using the VDU statement in line 50. This saves a lot of unnecessary maths.

You could make the programs easier by reducing the range of numbers allowed. Do this by reducing the 5 in line 280 or the 9 in line 290 or both. If you wanted to make it very easy you could allow only positive numbers. To do this delete line 300.

This program is written using MODE 1 to enable the guessed graphs to be displayed in red, and the target graph in white. If you have a BBC Model A Micro then you will not have MODE 1 but if you change line 40 to MODE 4 it will work exactly the same but without colour.


   10 REM NAME THE GRAPH
   20 REM COPYRIGHT (C) G.LUDINSKI 1983
   30 ONERRORRUN
   40 MODE 1:REM Put MODE 4 if you have 
a BBC Model A Computer
   50 VDU 29,640;512;
   60 DEFFNY(XI)=(A*XI^2)/400+(A*D*XI)/1
0+C
   70 MOVE-640,0:DRAW640,0:MOVE0,512:DRA
W0,-400
   80 REM
   90 REM DRAW AXES
  100 REM
  110 XA=-30:XX=0
  120 FORI=-600 TO 600 STEP 100
  130   MOVEI,10:DRAWI,-10
  140   PRINTTAB(XX,17);XA
  150   XX=XX+3:XA=XA+5
  160   IF XA=-5 THEN XX=XX+2
  170 NEXTI
  180 YY=25:YA=-300
  190 FORI=-300 TO 500 STEP 100
  200   MOVE-10,I:DRAW10,I
  210   IF YA<>0 THEN PRINTTAB(15,YY);YA
  220   IF YA=0 THEN YY=YY-1
  230   YY=YY-3:YA=YA+100
  240 NEXTI
  250 REM
  260 REM DRAW TARGET GRAPH
  270 REM
  280 A=INT(2*RND(1)+1):D=INT(5*RND(1)+2
)
  290 C=RND(9)
  300 A=A*((-1)^RND(2)):D=D*((-1)^RND(2)
):C=C*((-1)^RND(2))
  310 A1=A:D1=D:C1=C:B1=2*A1*D1
  320 COLOUR3:GCOL0,3
  330 PROC_GRAPH(A,D,C)
  340 REM
  350 REM INPUT AND DRAW GUESSED GRAPH
  360 REM
  370 G=0
  380 G=G+1:VDU28,0,31,39,28:CLS:VDU28,0
,31,39,0:PRINTTAB(0,28)"             _  
   _   _"TAB(0,29)"This is y = +Ax^2 +Bx
 +C . Guess A,B,C";:COLOUR1
  390 PRINTTAB(0,31);STRING$(39," ");TAB
(0,31);"Guess ";G;:IF G<>1 THEN PRINT"  
   Last guess = ";A$;",";B$;",";C$;
  400 COLOUR7:PRINTTAB(0,30);
  410 VDU28,0,30,39,30:INPUTA$,B$,C$:VDU
28,0,31,39,0
  420 IF A$="WHAT" AND B$="IS" AND C$="I
T" THEN PRINTTAB(0,28);STRING$(79," ");T
AB(0,29)"Answer = ";A1;",";B1;",";C1:END
  430 GCOL0,1
  440 PROC_GRAPH(VAL(A$),VAL(B$)/(2*A),V
AL(C$))
  450 GOTO380
  460 :
  470 DEFPROC_GRAPH(A,D,C)
  480 P=0
  490 COLOUR128
  500 FOR X=-600 TO 600 STEP 30
  510   IF X=-600 THEN MOVE -640,FNY(-64
0)
  520   IF FNY(X)<650 AND FNY(X)>-450 TH
EN DRAW X,FNY(X):P=1
  530   IF P=1 AND (FNY(X)>650 OR FNY(X)
<-450) THEN GOTO550
  540 NEXT
  550 ENDPROC
  560 END