## Surge: Making Math Problem Generator Text Files

Below is an example of a math problem generator. This text would be in a text file saved in the "Lessons" folder.

Warning: This gets a bit technical, so put your thinking cap on!

Warning: This gets a bit technical, so put your thinking cap on!

First problem -->
Second problem --> END keyword --> |
Find the area of the circle://Area =//x//tolmatch//0.005
The_ diameter radius <bool> [choose] _is_ <2,5,1> _units. <1> 2 1 <0> [choose] [/] 2 [^] <pi> [*] Solve for y.//y =//y//strmatch y +- <-10,10,0,nozero> = <-10,10,0> <1> <0> [-] END |

This may look like gibberish to people, but not to a computer! Every problem needs to have three lines of text, with a line break after EVERY problem. The first line states the instructions, the second line provides the problem and the third line provides the solution. You may have as many problems as you like in a single text file, just remember that each problem has an equal probability of being chosen by Surge.

## The First Line of Text

The first line of text provides the instructions for a problem. This line of text has four parts, each divided by two slashes ("//"). The first section contains the instructions for the person solving the problem.

Solve for y. // y = // y // strmatch

The second part contains the text that will sit next to where the user enters his or her answer, and the third part specifies any variables that you'll be using later on in your problem. If you are using more than one variable, just separate them with a comma and no spaces, like this: x,y.

Finally, the last part tells surge how you want to check if the user has entered the right answer. There are three options here:

Solve for y. // y = // y // strmatch

The second part contains the text that will sit next to where the user enters his or her answer, and the third part specifies any variables that you'll be using later on in your problem. If you are using more than one variable, just separate them with a comma and no spaces, like this: x,y.

Finally, the last part tells surge how you want to check if the user has entered the right answer. There are three options here:

- strmatch - "string match" - use this if you want the user to answer correctly, character for character (recommended for most math problems).
- valmatch - "value match" - use this if you want the user to give the correct value (so 5/10, 1/2, 0.5, and -1+1.5 would all be correct if the problem said "What is 1 - 0.5?
- tolmatch - "tolerance match" - use this if you are willing to accept an answer within a certain range of values. If you use this option, you'll need to add another double slash and give the tolerance. For example, if the correct answer was 2, and the instructions said, "tolmatch//0.5", any number between 1.5 and 2.5 would be correct.

## The Second and Third Lines of Text

The second line of text provides the actual problem that the user has to solve, and the third line of text provides the solution that Surge will be expecting. Keep in mind that any space character you put in either of these lines will be interpreted as an element separator, not an actual space (if you need a space use the underscore character "_"). Both lines use the same rules of postfix notation to logically process the math behind the scenes. Here's a quick example of postfix notation:

5 6 [+] = 11

As you can see, the operator is after the two numbers instead of in between them. This way of writing expressions allows for unambiguous order of operations, which is vital to a program like Surge.

To create variables, you'll need to use this format:

<-3,10,1>

This would create a random number between -3 and 10 (inclusive), rounded to 1 decimal place. If you want this number to never equal zero, you can add a "nozero" argument as well: <-3,10,1,nozero>. You may call this number up again by typing <0> (if it was the first number you made. Below is an example of some variables being used and called:

<2,10,0> + <2,10,0> =?

<0> <1> [+]

A sample output for this problem could be "3 + 5 = ?" The correct answer, as defined by Surge, would be 3 5 [+], which would evaluate to 8.

This is a very brief tutorial for creating problem generators. For a complete guide to what Surge is capable of, please refer to Surge Manual.txt, a file that is included with Surge.

5 6 [+] = 11

As you can see, the operator is after the two numbers instead of in between them. This way of writing expressions allows for unambiguous order of operations, which is vital to a program like Surge.

To create variables, you'll need to use this format:

<-3,10,1>

This would create a random number between -3 and 10 (inclusive), rounded to 1 decimal place. If you want this number to never equal zero, you can add a "nozero" argument as well: <-3,10,1,nozero>. You may call this number up again by typing <0> (if it was the first number you made. Below is an example of some variables being used and called:

<2,10,0> + <2,10,0> =?

<0> <1> [+]

A sample output for this problem could be "3 + 5 = ?" The correct answer, as defined by Surge, would be 3 5 [+], which would evaluate to 8.

This is a very brief tutorial for creating problem generators. For a complete guide to what Surge is capable of, please refer to Surge Manual.txt, a file that is included with Surge.