MathLand – A Math Game for Elementary School Students

I. Introduction

For thousands of years, humans of antiquity learned from orators and great thinkers—knowledge passed down generation to generation through story and lecture. Until the printing press, the expansion of human knowledge was limited primarily to the wealthy. Then, for centuries, text was the primary learning format for scientific inquiry. Now, recent advances in information technology have a great potential to catapult human learning in to the knowledge stratosphere. New technologies like intelligent tutoring systems and game-based learning environments have the potential to meet the grand research challenge posed by the Computing Research Association—“provide a teacher for every learner” [1].

Mathland is a game I designed for my Intelligent Game-Based Learning Environments course at North Carolina State University. The class is focused on topics like artificial intelligence, intelligent tutoring systems, pedagogical agents, student modeling, affective computing, and human-computer interaction. Most importantly, the class is designed to equip the students with the tools necessary to transform education.

My semester long task was to design a game-based learning environment. Furthermore, this game-based learning environment needed to be tailored to teach a specific curriculum of my choosing. Mathland is an intelligent game-based learning environment that takes place on an alien land under attack from enemies. The enemies can only be defeated by the player solving addition problems. 1st graders achieve simple addition mastery by quickly clicking on the addition problem attached to each enemy that matches the answer. In this report, I will discuss my pedagogical goals, the architecture of Mathland, the design choices I made, the tutoring capabilities of Mathland, and what the gameplay is like.

II. Target Audience & Pedagogical Goals

The Common Core educational standards of North Carolina suggest that it is in kindergarten when children learn to add the numbers 1-9. By 1st grade, the students learn foundational mathematics principles like the commutative property—for example, 4 + 5 = 5 + 4. By first grade, children of ages 5-7 have already experienced interaction with a computer. More than likely, they have the skills to rival that of an experienced user on a mobile device like a smartphone or tablet. These are just two of the reasons I chose 1st graders as the target audience of my application.

In addition, 1st graders generally have not yet become masters of basic addition. By this, I mean that though they may be able to solve a simple math problem, they may not be able to do it efficiently. One of my main pedagogical goals with Mathland, then, is to increase the computational speed by which 1st graders solve basic addition problems. This can be achieved through repetition and external pressure to solve a problem quickly. In Mathland, users must solve problems quickly to achieve the best score.

Another primary pedagogical goal I have is to improve the speed of memory recall of 1st graders. Much of the time, for simple addition problems, the answer to a problem like 1 + 2 does not need to be calculated, but rather, recognized. Memory recall of 1 + 2 is like accessing the flash memory of a child’s brain. The CPU, or brain, does not need to be involved; rather, access to the memory can tell the student the answer is 3.

III. Mathland 1.0

As mentioned above, Mathland is an intelligent game-based learning environment that helps 1st graders achieve simple addition mastery. The inspiration for the game came from a space invaders-style speed typing game I played as a child in a required introductory typing class. It looked similar to the game in Figure 1. In this game, enemies fall from the sky in a uniform pattern. To defeat the enemies, the player must type the word under the given enemy. For example, if I typed dads, the enemy on the left would explode. As the levels progress, the speed by which the enemies fall increases and the words the player must enter become more difficult.


Figure 1 – Space Invaders Speed Typing game

In my initial mock draft of Mathland, I created a prototype as shown in Figure 2. Enemies fall from the sky with a math problem attached to them. The user must type in the answer to the math problem to defeat the enemy. In my production version of Mathland, I made the design decision to use mouse entry (clicking) as opposed to keyboard entry (typing). In this section, I expound upon this design decision as well as numerous other challenges I faced.


Figure 2 – Prototype of Mathland

Problem & Answer

The problem and answer portion of Mathland is really the heart of the game. Because the math problems and answers are so important to gameplay, it was crucial that I got this aspect of the game correct. A poor implementation or design could have led to a boring or ineffective game. Therefore, many design decisions I made in this portion of the game significantly shaped the end result. In this section I will discuss how the math problems and answers are selected, generated, acted upon, and destroyed.

In my initial implementation of Mathland, the math problems attached to the enemies were simply generated randomly using the JavaScript function Random.Range(1, 10). This function generates a random integer value between 1 and 9, inclusive. I generated two numbers like this and placed a + symbol in the middle to make a problem like 4 + 5, for example. I soon discovered that using this method to generate problems is not sufficient. I ended up with a far greater number of incorrect problems than correct problems—in this case, an incorrect problem is simply a problem whose sum does not equal the math answer. For example, for a math answer of 3, there are only 2 different combinations that will result in a correct answer: 1+2 and 2+1. There are a total of 306 different combinations that can be chosen from, however: (9*2)! / ((9*2)-2)!. This results in a vastly outnumbered chance of only 0.65% of a correct math problem appearing.

I decided to adjust the math problem generation algorithm to ensure the likelihood of a correct problem is much higher than in a truly random setting. I achieved this by first accessing the math answer game object. I compared the math answer to the sum of the generated math problem. If they did not match, then I destroyed it if a third random variable was not greater than some arbitrary threshold value I set. The heuristic looks something like this:

var answer_int : int = get_answer();

//Generate random numbers for math problem
var randomnumber1 = Random.Range(1, 10);
var randomnumber2 = Random.Range(1, 10);
var sum = randomnumber1 + randomnumber2;

var my_rand = Random.Range(0.0, 1.0);
//Arbitrary threshold determined to work well
var threshold : float = 0.85; 

if (answer_int != sum)
    if (my_rand < threshold)

The implementation of the math answers, on the other hand, was far simpler. A simple random value is all that is needed to choose a value between 2 and 9. The low value of 2 was chosen because I wanted the students to add only nonzero values. The max value of 9 was chosen because I wanted the students to achieve simple addition mastery of single digit problems. Later in my development of Mathland I did end up modifying the selection process of the math problem to improve the student model and tutoring functionalities. The discussion for this choice comes in the appropriately labeled section, Student Modeling & Feedback.

Another problem I consistently came across during my development process was the need to parse the math problem values. For example, change 4 + 5 to 9. This is a common task for many programming problems and any programming language worth its weight has functionality to handle this. Within Unity, a common design pattern emerged. First, the math problem game object’s text must be stored to an array. Then, the values are split to exclude the + operator. Finally, the two values are summed and stored in an answer variable. Very simple, yet the mechanics of accessing a game object’s components took a while to wrap my head around as a novice unity user and game developer. The common pattern looks like this:

// Must parse the problem to separate values of "4 + 5"
var splitter : String[] = hitm.collider.gameObject.GetComponentInChildren(TextMesh).text.Split("+"[0]);
var value1 : int = parseInt(splitter[0]);
var value2 : int = parseInt(splitter[1]);
var my_answer : int = value1 + value2;
Scoring & Lives

A game based around a repetitive task of increasing difficulty is perfect for a scoring based system. Mathland uses a very simple scoring system of +1 to the score for every correct answer. Once the player reaches a score of 25, the player wins. Along the route to 25 are checkpoints that occur at values 5, 10, and 20. These checkpoints are hidden from the user and are used in the difficulty scaffolding mechanic of Mathland. I discuss this further in the next secion.

On the other side of scoring is the negative scoring, or lives game mechanic. Many games, including games focused for children, include the notion of having a fixed number of attempts or tries to finish a task. For Mathland, the player is given 3 lives each round. If the player clicks on a math problem that does not match the answer, the player loses 1 life.

By design, the scoring and lives mechanics are meant to be very simple and obvious. I believe this helps the child to focus more on increasing his score instead of left wondering how the score is calculated. Another design choice I could have pursued is a scoring system based on a time multiplier. For example, if the user correctly selects a math problem within 1 second of it appearing, a scoring bonus value of 5 is added. If the user takes 5 seconds to select the math problem, a scoring bonus of only 1 is added. However, I did not want to obscure the scoring values by some nontransparent time multiplier.

Difficulty Scaffolding

My initial design of the game, before I even started developing, was to include a difficulty level that increased as the player achieved a certain task. I decided to implement difficulty scaffolding based around the score of the game in a given round. My second design problem was to decide how to scaffold the difficulty. In this section, I discuss these challenges.

My first design problem was to decide what should trigger an increased difficulty and removal of scaffold. I considered a level-based game where the user started with a math answer of 2. Upon completion of the level 2, the user began a level with a math answer of 3. This seemed very logical. The player would be able to work toward a clearly defined goal of beating all 9 math problems to win. The problem, however, is that for a game as simple as Mathland, a level based design is far too stale. It is not exciting and engaging when there is no “boss” to defeat at each level or princess to save. I decided, then, to revolve the difficulty around the current score of the user. Three levels of scaffold are in place. Reaching a score of 5, 10, and 20 increases the difficulty level at each step. All of the logic of how this happens, when this happens, and to what degree the difficulty level increases is hidden from the player.

The player receives some subtle visual feedback, however, upon reaching these values. As each level of scaffold is removed, two variables are changed: the rate at which enemies (math problems) are generated and the speed at which they fall. The increased production and speed of enemies is noticeable during gameplay. The difficulty mechanics are handled in two different scripts. The algorithm for this is stored in a function, update_interval as such:

function update_interval ()
    var my_score : int = get_score();
    var my_time : float;
    if (my_score > 19)
        my_time = .24;
        InvokeRepeating("spawn_enemy", 0, my_time);
    if (my_score > 9)
        my_time = .28;
        InvokeRepeating("spawn_enemy", 0, my_time);
    if (my_score > 4)
        my_time = .3;
        InvokeRepeating("spawn_enemy", 0, my_time);
    if (my_score >= 0)
        my_time = .4;
        InvokeRepeating("spawn_enemy", 0, my_time);

The variable my_score is the player’s current score. The variable my_time is the number of seconds to wait before calling the spawn_enemy() function that generates enemies. If a player has a score of 10, for example, an enemy is spawn every .28 seconds. This does not mean, however, that an enemy is actually placed on the screen every .28 seconds. See my discussion of how the math problems are generated in the Problem & Answer section.

Another interesting unity-related problem that I ran in to was changing the rate at which enemies are generated. Because actions in the Update() loop are invoked once every frame, I had to rely on a pattern of CancelInvoke() and Invoke() function calls in my Update() loop to cancel the previous spawn_enemy() function call and implement the new one with a changed variable.

To change the speed at which the enemies fall, I added a new movement script to the enemy game object. In this new movement script, I check the score in the main Update() loop and if the score is at 5, 10, or 15, the movement speed of all enemies increases. Here is a sample:

movement = Vector3(speed.x * direction.x, speed.y * direction.y, 0);

if (my_score > 4)
    movement *= Time.deltaTime + .004;
if (my_score >= 0)
    movement *= Time.deltaTime;

In short, the movement variable holds all relevant information about the position of the enemy game object. This is the case for each instance of the game object. The movement is multiplied by the current time. If the user reaches the next difficulty scaffold, an arbitrary value like .004 is added to the time value that is multiplied by the variable movement.

Student Modeling & Feedback

An intelligent game-based learning environment is only intelligent if there is some type of tutoring system and/or student modeling that occurs. To complete my release of Mathland 1.0, I added a student model feature as well as a simple feedback feature. The theory behind a student model is simple: track the player’s actions and make intelligent decisions based on those actions. The implementation of a student model is far from simple, however. In this section I will discuss my implementation of a student model as well as the feedback I provide the player.

In Mathland, a student model keeps track of a few key actions the player makes; namely, each math problem the player selects, whether correct or incorrect, and each math answer the player successfully beats. To keep a record of all this information, Unity has a built-in mechanism to achieve this common task: PlayerPrefs. To use PlayerPrefs, I wrote a function, save(), that calls the following method: PlayerPrefs.SetInt(my_string, math_prob). I call this function each time I want to save a math problem the player has correctly answered. I have a similar function that saves each problem a user incorrectly answers. I have yet another similar function that saves the math answers the player has beaten. Overall, PlayerPrefs was one of the easier mechanics of Unity to learn and proved very useful.

The way the math answer is selected each round is based upon what answers the player has beaten already. This data transpires over endless iterations of Mathland. If a player has beaten easier math answers like 2 and 3, they are much less likely to appear again. If the user has beaten 4 or 5, they are less likely to appear than numbers 6-9, but more likely to appear than 2 and 3. This weighted probability is achieved through a similar heuristic to the one I used to generate the math problems. Here is a sample:

var threshold_23 : float = 0.80;
var threshold_45 : float = 0.60;
var randomnumber2 = Random.Range(0.0, 1.0);

The variable threshold_23 stores the threshold value relevant to math answers 2 and 3. Likewise, threshold_45 stores the threshold value relevant to math answers 4 and 5. I generate a poorly named random number, randomnumber2, that is compared to the threshold values. Here is how it works: if the current math answer is 2, for example, and the user has not already completed 2, then the math answer remains 2. However, if a user has completed math answer 2, then randomnumber2 is compared against threshold_23. If randomnumber2 is greater than the threshold value, then the math answer is changed.

Feedback is given to the player at the end of every round. The feedback for Mathland 1.0 is simply text that displays a list of all the math problems the player got wrong and all the math problems the player got correct. The feedback is generated in the GameOverScript.js script that is invoked once the game is over. A set of functions parses the list of PlayerPrefs values that are stored for the player and displays them like in the image below. In future work, I would like to expand the feedback feature.


Figure 3 – Feedback for the player


The sprite assets I used for Mathland come entirely from of These assets, along with many other asset packs are available for use freely by anyone. I also must thank soundcloud user Bit Child for the audio clip “Wasp” that loops in Mathland.

IV. Future Work

I left many features off of Mathland due to the time restriction to complete this project. Many of these features I hope to implement in the near future. One such feature is a better tutoring system. The current intelligent tutoring system I have is a barebones and minimalistic implementation. It looks at student model information, selects math answers based on that information, and provides feedback at the end of each round based upon the player’s progress. In a future release, I would like the system to intelligently select math problems in addition to the math answers it already selects. For example, if a player repeatedly selects 4 + 5 as the match to the answer 8, then I would like to store that relationship and leverage it in some way. One such way would be to show 4 + 5 more frequently when 8 arises, as well as when 9 arises. The hope is that the player would figure out what the sum of 4 + 5 is without explicitly told the answer.

Another potential improvement to the intelligent tutoring system of Mathland would be the addition of a pedagogical agent. A pedagogical agent is an intelligent virtual agent that behaves and appears as a real human tutor. Research as early as the late 1990s demonstrated their effectiveness [2]. By including a friendly, helpful tutor that can offer hints and suggest quicker ways to solve basic addition problems, the player would benefit. If the pedagogical agent is encouraging as well, the player would potentially be more engaged in Mathland. This feature is complex and likely will not be implemented any time soon.

Something that happens fairly often in Mathland is the player may miss a correct problem. That is, the correct math problem may float all the way to the bottom and off the screen before the user clicks it. This should result in -1 lives. For Mathland 1.0, this feature is not enabled. Given more development time, I would like to implement this feature. Perhaps even a “fly trap” would catch all the correct flies (enemy) the player misses. If the fly trap becomes overloaded, the defenses fail and the player loses the game.

V. Conclusion

Intelligent tutoring systems and game-based learning environments are the educational technology of the future. They are the path to “provide a teacher for every learner” [1]. My own path to aid in this effort was shaped greatly by my positive experience designing and developing Mathland. I gained a fundamental understanding of many of the concepts that drive game design with a twist of educational psychology.

Through my studies in this Intelligent Game-Based Learning course, I have learned that some of the world’s top computer scientists are working on the problem of education. I believe it is paramount that expert computer scientists propel humanity in to a new age of education. The potential benefits of the uneducated and undereducated children of the world receiving an affordable and accessible quality education cannot be understated [3]. A new age of equal education for all is upon us—in the form of intelligent tutoring systems and game-based learning environments.

VI. References

[1] Computing Research Association. Grand Research Challenges in Information Systems.
Washington, DC: CRA Press (2003)

[2] Person, N. K., Graesser, A. C., Bautista, L., Mathews, E. C., the Tutoring Research Group.
Evaluating Student Learning Gains in Two Versions of AutoTutor. J. D. Moore, C. L. Redfield, &
W. L. Johnson (Eds.), Artificial Intelligence in Education: AI-ED in the Wired and Wireless Future,
286–293 (2001)

[3] Heckman, J.J. Skill Formation and the Economics of Investing in Disadvantaged Children.
Science 312, 1900–1902 (2006)

To see the full source code to MathLand:

Leave a Reply

Your email address will not be published.