Teaching Computational Thinking Using Mathematics Gamification in Computer Science Game Tournaments

  • Chee Wei TanEmail author
  • Pei-Duo Yu
  • Ling Lin
Open Access


One of the key foundations in computer science is abstract algebra. Ideas of abstract algebra can be introduced to students at middle or pre-college schools to cultivate their capacity for logical thinking and problem-solving skills as well as gaining mathematical competency required in computer science. In this book chapter, we introduce ideas of mathematics gamification and a mobile app game, Algebra Game, richly rooted in abstract algebra and first proposed by the mathematician Tao (Gamifying algebra, 2012a, Software mock-up of algebra game 2012b). The Algebra Game teaches elementary algebra seemingly on the surface, and yet the game-play design possesses interesting abstract algebra ideas and mathematics gamification potential. We define mathematics gamification as the process of embedding mathematical concepts and their logical manipulations in a puzzle game-like setting aided by computers. We describe several mathematics gamification instances to enrich the Algebra Game play. Finally, we evaluate the learning efficacy of the Algebra Game mobile app software in computer science game tournaments modeled after eSports-like computer games in order to scale up the number of students who can learn the Algebra Game mathematics.


Mathematics education Mathematics gamification Mobile app games Pedagogy Personalized learning K-12 mathematics Computer science 

10.1 Introduction

Marvin Minsky, in his 1970 Turing Award Lecture, asserted that “The computer scientist thus has a responsibility to education…how to help the children to debug their own problem-solving processes.” (Minsky 1970). Minsky pointed out that cultivating the capacity for logical thinking and problem-solving skills of students, while they are young, to learn foundational subjects such as mathematics is of the essence. The emphasis is on the tools and motivations for students to acquire problem-solving skills in lifelong learning of mathematics. Computer science and its software technologies might just offer an intriguing way for students to persist and persevere in learning mathematics. We described a preliminary pedagogical study on learning K-12 mathematics through mathematics gamification ideas and tested it at a computer science tournament in Hong Kong.

We define mathematics gamification as the process of embedding mathematical concepts into puzzle game-like instantiations that are aided by computing technologies. We focus on the software development for typical computing technologies run on a mobile device of the learner. Game playing is essentially the manipulative of mathematical objects or structures in a logical manner such to acquire useful mathematical insights that otherwise are not obvious or taught in traditional classrooms. Also, the engaging game-like nature can potentially motivate students and serve as instructional tools for regular practice to gain proficiency in mathematics and numeracy. There are several ways to implement ideas of mathematics gamification in software that can be delivered to the students. We have chosen to deliver them by mobile app software that presents potentially strong opportunities for students to learn advanced mathematics in a systematic manner and at their own pace.

Any form of personalized learning technologies should provide a way to teach for mastery, where students are allowed to progressively move on to other challenging topics only after they have fully grasped the topic at hand. This approach requires a personalized approach that caters for individual student learning pace that can also complement with traditional classroom teaching. Our mathematics gamification technology leverages the ubiquitous availability of personal computing devices such as mobile devices like smartphones and tablets, offering students the opportunity to personalize their mathematics learning experience, allowing students to learn new knowledge or perform self-assessments at their own pace, and therefore maximizing the efficiency of learning in order to “teach for mastery”. Another unique advantage of our mathematics gamification technology is its ability to offer students instant feedback as they play, which is a crucial part of “debugging” their thinking process. In traditional classroom learning, students’ answers often are graded and then returned weeks later. On the contrary, personalized learning technologies such as our mathematics games (namely, Algebra Game and Algebra Maze, which we will present in details in the following) enable students to get instant visual feedback as they play, so that they can reconsider the situation and correct their moves, which is an example of “thinking process debugging” on the go and in real time.

10.2 Algebra Gamification

Elementary algebra—the first cornerstone of K-12 mathematics—has been highlighted by the National Academy of Engineering (Lavernia & VanderGheynst, 2013) as a critical area to improve in K-12 mathematics learning (in fact, touted as an Algebra Challenge). How should the Algebra Challenge be addressed from teaching computational thinking skills with an aim to underpin the foundation of learning mathematics? Can this complement traditional classroom learning? It has been recently recognized (among them are mathematicians like Keith Devlin from Stanford University) that game-playing activities allow players to grasp mathematical concepts and foster a sense of motivation that leads to numeracy proficiency, especially when the game is designed to embed abstracted mathematical subjects (Devlin, 2011; Pope & Mangram, 2015; Shapiro, 2013; Mackay, 2013; Novotney, 2015).

Algebra gamification is a pedagogical approach to learning elementary algebra. This approach is particularly useful when used at an early stage of K-12 education to give students a heads up on learning an advanced topic that might only be encountered later in classroom teaching. In this paper, we report on how this idea of mathematics gamification can be designed as mobile game apps that are suitable for middle school students when the mobile apps are deployed in mathematics-related game tournaments and then to analyze the preliminary efficacy of learning behavior based on collected data. Put simply, this teaches students how to think (about learning mathematics) at multiple levels of abstractionthe goal of teaching computational thinking (Wing, 2006). The particular instance of gamifying algebra in this paper is due to Terence Tao, a mathematician at the University of California, Los Angeles, who remarked in his online blog article (Tao, 2012a, b) on “Gamifying Algebra” that:

The set of problem-solving skills needed to solve algebra problems (and, to some extent, calculus problems also) is somewhat similar to the set of skills needed to solve puzzle type computer games, in which a certain limited set of moves must be applied in a certain order to achieve a desired result one could then try to teach the strategy component of algebraic problem-solving via such a game, which could automate mechanical tasks such as gathering terms and performing arithmetic in order to reduce some of the more frustrating aspects of algebra… Here, the focus is not so much on being able to supply the correct answer, but on being able to select an effective problem-solving strategy.

Tao’s insightful remarks aptly highlight two key facts, namely, that (i) certain kinds of K-12 mathematics are amenable to game design that can motivate student to learn and (ii) problem-solving skills can be cultivated through this gamifying process as a means to learning the mathematical subject. In other words, there are several ways to solve elementary algebra—strategizing moves in a mathematical puzzle game is one of them. With the aid of computing technologies, this introduces novel perspectives to learn elementary algebra for young students. Also, Tao (2012a, b) developed a software mock-up of the game as shown in Fig. 10.1.
Fig. 10.1

Terence Tao’s software mock-up of his algebra game in 2012

The idea of Tao’s algebra game is to reduce a given linear algebra equation to a form with only “x” and a numerical value on the left-hand and right-hand sides, respectively, through a selection of a finite number of given clues. In the following, we give an example using a screenshot of the game as shown in Fig. 10.1. Initially, the puzzle state is the algebra equation “5x + 3 = x + 11”, and the given clues are the three possibilities “Subtract 1”, “Divide by 2”, and “Subtract x”. The player chooses one of the three possibilities by clicking on the avatar icon. Say, suppose the player chooses “Subtract 1”, the algebra equation (correspondingly, the puzzle state) then changes to “5x + 2 = x + 10” (since both sides of the original equation “5x + 3 = x + 11” get subtracted by one).

One possible “solution” to the puzzle given in Fig. 10.1 is the sequence of “Subtract 1” then “Subtract x” then “Divide by 2” then “Subtract 1” and then finally “Divide by 2” to yield “x = 2”. This requires a total of five moves to reach the desired state. It is important to note that what matters is not the final value of x, but it is rather the inquisitive problem-solving process while playing that is valuable.

The benefit to computational thinking is obvious: students learn a foundational subject (e.g., mastering algebra) while playing. With regard to the game-play design, there are several intriguing questions: first, how to engineer the difficulty level of the game automatically? Second, how does a computer (not human player) solve a given puzzle efficiently, i.e., with the fewest number of moves? And, third, how to engage the human players in an entertaining manner so that they keep on playing it and, unknowingly, develop a better number sense or mathematical intuition and that such an improvement can be measured? These questions were explored in The Algebra Game Project founded by the first author (“The Algebra Game Project”, n.d.), and detailed answers to these questions along with the software development will be published in other venues.

10.3 Mathematics Gamification of Algebra Maze

In this and the next section, we describe the mathematics gamification building on Tao (2012a, b) algebra game and the software implementation of our mobile apps called the Algebra Game and the Algebra Maze, and the mobile app software are freely available to download at the Apple iOS Store or Google Play Store (“The Algebra Game Project”, n.d.).

In Algebra Maze, we combine maze-solving elements and single-variable algebra equation solving together as shown in Fig. 10.2, which is the game-play screenshot of Algebra Maze. The goal is to move the purple avatar toward the treasure (i.e., equivalently solving the linear equation). Each movement of the avatar corresponds to a mathematical operation on the equation given below the maze. For example, the button “+1x” corresponds to the avatar moving one unit upward, and the button “+2” corresponds to the avatar moving rightward two units. Hence, the operation on x is an up–down movement, and the operation on the constant is a left–right movement of the avatar. With the rules above, we can deduce that the position of the avatar also has an algebraic meaning, i.e., each position in the maze represents a different equation having different coefficients or constant values.
Fig. 10.2

Algebra maze mobile app game with maze-like gamification design and freely available for download at iTunes app store and Google play store

In the initial levels of Algebra Maze, the treasure is made visible, and then at subsequent levels, the treasure is rendered invisible, i.e., hidden from the player as shown in the right-hand side of Fig. 10.2. Hence, the player needs to make use of the “information” in the given equation to deduce the location of the treasure. In some levels, the player has to first get a key, which is in a certain position of the maze, before opening a locked door located nearby to the treasure. This setting is equivalent to asking the player to reach to a certain equation first before they solve this equation. Finally, when the avatar locates the (potentially hidden) treasure, the algebra equation will be in the desired form “x = numerical_solution”, i.e., the puzzle is solved.

In order to make Algebra Game more challenging, such that players can learn thoroughly, we add more new features in subsequent higher levels. One of the features is “traps”, once the player steps on the trap features, the buttons for movement control will toggle, either from left–right to up–down or from up–down to left–right. For example, the player can only perform “+s” or “−t”, to the given equation initially, and after the player has stepped on the “traps”, the operation will change from or “−t” to “+ux” or “−vx” which is the operation related to the x-term where s, t, u, and v are four constants. In Fig. 10.2, there are only left–right buttons, “+2” and “−1”, in the left most screenshot. After the character steps on the trap, which are the green buttons, the left–right buttons will then be changed into up–down buttons, “+1x” and “−2x”, which is shown in the middle screenshot of Fig. 10.2.

Another way to increase the difficulty of Algebra Maze is to create “fake paths” in the maze (Figs. 10.3 and 10.4). We define a “fake path” as a path that seems to be a possible path to the treasure box, but it will, in fact, lead the player to a dead end. In the following, we give illustrative examples on how to combine the fake path and the “trap” together and to design four mazes in which their topology structures look similar but actually possess different difficulty levels. All of these four mazes are with clues {+ 2, −1, +1x, −2x}. The starting point marked as dark blue, and the treasure box marked as yellow, and the orange squares represent the walls and obstacles, respectively.
Fig. 10.3

Four different game designs of algebra maze

Fig. 10.4

Four different game designs of algebra maze with difficulty levels ordered from easy to hard: Maze 1, Maze 2, Maze 3, and Maze 4

In Maze 1, which is the easiest one, there are two possible paths (red path and green path) that the player can take in order to reach the treasure box. In Maze 2, we limit the number of paths that the player can take by adding some obstacles, which are indicated by the light blue square in the second figure, and now the player can only reach to the treasure box along the red line. In this example, the original green path in Maze 2 is a “fake path”.

This is one possible way to enhance game-play design such that the difficulty of Maze 2 is higher than that of Maze 1. In Maze 3, we have added some traps to the maze, and the difficulty level will then further increase. Players need to think carefully how to overcome obstacles in order to reach the treasure box. The circles in the third figure represent the traps (the green button in the screenshot). At the beginning, there are only two movement control buttons, namely, the go-leftward and go-rightward buttons. When the player steps on the traps, the movement control buttons will then toggle to upward and downward buttons. In Maze 4, the difficulty level can then be further increased by adding a dead end in the map. This means that, when the player reaches the dead end, he/she will be trapped in that position and cannot move further anymore. In such a case, the player either loses the game or can retry it. The dead end is highlighted in light blue in the fourth figure. By leveling up the maze gradually from Maze 1 to Maze 4, the Algebra Maze will become more challenging and requires the player to think deeply before making a move. These four examples also point out that the elements in the clue set are strongly related to the difficulty-level design. For example, we can leverage the Euclid Algorithm with the clue set design. Students can even get to know and learn important foundational computer science knowledge such as how the Euclid Algorithm works. In addition, the positions of the traps limit the players’ moves (e.g., the dead end) and also need to be considered when designing the clue set.

10.4 Mathematics Gamification of Algebra Game

In Algebra Game, unlike the Algebra Maze, we split the clues into two parts, one part is the mathematical operators, i.e., addition “+”, subtraction “−”, multiplication “*”, division “÷”, and the other part is the operand such as the x-term or the number as shown in Fig. 10.5. Hence, the combination of the clues is more general than the original design. The goal in Algebra Game is the same as Tao’s algebra game: To reduce a given linear algebra equation to “x = numerical_solution” through a selection of a finite number of given clues. As shown in the right-hand side of Fig. 10.5, if the player “drags” the division button “÷” and “drops” it on the button “2”, then the equation will be divided by two on both sides. Algebra Game is not only about solving a linear equation but it also contains other mathematical insights. For example, consider an equation “x − 23 = 2” with the clues “+, −” and “2, 3”, then this is equivalent to ask if we are able to use 2 and 3 to construct 23. The players can develop their number sense through playing this game. Let us use another example, consider an equation “24x = 48” with the clues “*, ÷” and “2, 3”, then this is equivalent to asking the players to factorize 24 by using 2 and 3 (prime numbers). Other than the factorization concept, there are many instances of mathematical manipulations that can be embedded in the Algebra Game such as the Frobenius’s problem (also known as the coin problem) in the form of making up a number from two given clues. In essence, given the available clues at each level, the player can only perform a limited number of operations, and this restriction helps to stimulate computational thinking in finding the shortest sequence of moves to solve the problem. If the player is familiar with the mathematical analysis underpinning the difficulty level design in the Algebra Game, the player can even further develop mathematical insights and intuition while playing the Algebra Game.
Fig. 10.5

A puzzle instance in the algebra game mobile app game that challenges students to find the right combinations of prime number factors for the number 105 in order to solve the puzzle. Important mathematical results such as the fundamental theorem of arithmetic can be displayed as hint to facilitate a deeper understanding of mathematics for the game players

The mathematics gamification process also requires analyzing the scoring rule at each puzzle game level that can be evaluated according to different reasonable design criteria. For example, scoring rules can be evaluated in terms of the number of moves needed or the speed to solve each level in the case of the Algebra Game and the number of “redo” on hitting obstacles or the speed to locate the hidden treasures in the case of the Algebra Maze. A well-designed scoring system can improve the design of the difficulty level at each level for improving students learning experience. Furthermore, concrete mathematics can be purposefully interleaved at certain levels of the games. For example, after a consecutive sequence of games involving factorization in the Algebra Game, the mathematical statement of The Fundamental Theorem of Arithmetic (stating that all natural numbers are uniquely composed of prime numbers) can be displayed to the player in order to highlight game features (e.g., the prime numbers as clues) with the mathematical rudiment. In this way, the players learn about fundamental mathematical knowledge (such as The Fundamental Theorem of Arithmetic in Euclid’s Elements that is not typically taught in the classroom). For example, Fig. 10.5 shows an example of the puzzle. In summary, we find that the Algebra Maze and the Algebra Game can provide players with new perspectives to gaining new mathematical insights while training their individual number sense and problem-solving skills that are critical to developing their capacity to view mathematics at multiple abstract levels.

10.5 Case Study of Computer Science Challenge Game Tournament

The Computer Science Challenge (CS Challenge) is a tournament organized by the Department of Computer Science at City University of Hong Kong starting since 2016 for both primary and secondary school students in Hong Kong (“CS Challenge”, n.d.). The CS Challenge is modeled after eSports-like computer game tournament. A pair of students forms a team, and there were altogether 32 teams from 19 primary schools, and 53 teams from 33 secondary schools, making a total of 170 students in May 2016. One of the computer game in the CS Challenge is the Algebra Game Challenge, in which the Algebra Maze and Algebra Game are used for the primary school students (as shown in Fig. 10.6) and the secondary school students (as shown in Fig. 10.7), respectively. The Algebra Game Challenge lasts for a fixed duration of 20 min. We experiment with a pedagogical initiative of teaching computational thinking to the participants as follows: a workshop for all participants was held a month before the CS Challenge, whereby participants were introduced to basic computer science knowledge and the mathematics behind the games. On the day of the CS Challenge, however, participants used the mobile app software described in Sect. 3 that allows more diverse game-playing dynamics and also enables the use of data collection and data analytics to capture the users’ game-playing behavior. The mobile apps in (“The Algebra Game Project”, n.d.) were not available to the participants beforehand as they were posted online only after the CS Challenge was over (Fig. 10.8).
Fig. 10.6

Primary school student tournament of algebra maze at the computer science challenge in May 2016

Fig. 10.7

Secondary school student tournament of algebra game at the computer science challenge in May 2016

Fig. 10.8

Percentage of the number of students versus the total number of completed levels of algebra game with an unlimited number of levels a priori designed in the algebra game during the 20-min duration for the game tournament

We describe next the learning efficacy of the first task of Algebra Game and Algebra Maze based on analysis of the data collected in the tournament. We analyze the performance evaluation of learning efficacy based on the time spent at each level, each move that a user has taken, and the number of “redo” times at each level. The difficulty at each level is calibrated based on our mathematical analysis of the game (from easy to hard), and we expect to have a reasonable difficulty curve so that players gain confidence instead of frustration at early levels. Let us evaluate Algebra Game first. In Fig. 10.10, we see that the number of students who have completed the corresponding level has observable reduction at higher levels, e.g., about 20 percent, from Level 9 to Level 10 which can also be observed in Fig. 10.9, the time spent at Level 10 almost doubled that at Level 9. In fact, the number of moves needed at Level 10 is also almost double that at Level 9 as shown in Table 10.1. We conclude that the total number of moves needed at each level is a crucial factor in the difficulty-level calibration design of the game.
Fig. 10.9

The average time a player spent at each level of the algebra game

Table 10.1

Table of average moves taken by players in each level of the algebra game








Average moves














Average moves







Interestingly, the average number of moves needed at Level 12 is around 8.8, and yet the time spent at Level 12 is the highest. This implies that the total number of moves needed is not the only factor that may affect the difficulty of the game for human players. Finally, the reason for the longer time spent at Level 1 is that students are initially warming up (as they get familiar with the game interface and rules). If we omit the information at Level 1 and proceed to compute the correlation coefficient between the time spent and the average number of moves taken, then we have a correlation coefficient that is 0.807 which reveals that they are highly correlated for the 12 levels being analyzed.

10.6 Further Discussions

From Fig. 10.9, we observe that the average time that students spent on a level in the Algebra Game increases with the level of progression (except for the first level, where students are just getting familiar with the game and learning the rules on how to play the game and thus the time spent is relatively higher). From a game design perspective, an extension is to adapt difficulty levels that are fine-tuned according to the skill or knowledge of the player. In addition, how to classify the difficulty level of the Algebra Game and to integrate that with player’s learning curve is an interesting direction that we will address in the future release versions of Algebra Game and Algebra Maze. This will allow the game-playing experience to be adaptive to the personalized learning goal of mastering arithmetical and numeracy skills in algebra manipulations (Fig. 10.10).
Fig. 10.10

Percentage of number of students versus the total number of completed levels of algebra maze with a total of 45 levels a priori designed during the 20-min duration of the game tournament

As part of classifying the difficulty level of the Algebra Game, we will address the automatic generation of games in the Algebra Game and Algebra Maze so that high-quality levels can be generated at real time. There are several ways to classify difficulty levels of the Algebra Game and Algebra Maze. One possibility is a machine learning approach to quantify automatically the difficulty level in the Algebra Game of the puzzle. We can treat this as a simple regression problem in machine learning: the input is the puzzle parameter of an Algebra Game level (initial equation, number of moves allowed, set of allowed operations, etc.), and the output is a numeric value measuring the difficulty of the given level. We can train this model by feeding it with the puzzles we used in the game tournaments, e.g., the Computer Science Challenge, and their corresponding difficulty measures derived from the average time spent by human players. After the training, we can use the generated model to predict the difficulty level of a particular generated level of Algebra Game. This can, in turn, be presented to general users in the form of automatically generated Algebra Game puzzles with increasing difficulties.

Another enhancement we are currently making to the algebra gamification system is a personalized puzzle recommendation system, where the backend server can push auto-generated personalized Algebra Game/Algebra Maze puzzles to each individual student’s device. We call it “personalized” because the system will determine a specific student’s need (e.g., a student might need more practice in factorization of numbers, which can be seen from her past playing record in the system) and push the most suitable puzzles to the student. Once we finish the difficulty level classification task, the system can also push puzzles at different difficulty levels to suitable student groups, so all students from different skill levels can find the game challenging.

10.7 Conclusions

We described preliminary ideas of mathematics gamification and their application to teach computational thinking by cultivating the capacity for logical thinking and problem-solving skills of students using mobile app game software. Through gamifying elementary algebra learning, we described how the logical manipulatives of the mathematical puzzle games, Algebra Game and Algebra Maze are embedded within puzzle game-like instantiations in a logical flow to catalyze the development of mathematical intuitions and insights related to abstract algebra. Through competitive game playing in a Computer Science Challenge tournament, we studied the learning efficacy of the algebra gamification software and also experimented with scaling up mathematics learning using mobile app software. In our future work, we are exploring the possibility of extending the ideas mentioned in this book chapter to gamification of other advanced mathematics and computer science subjects in a single mobile app—The Polymath App (“The Algebra Game Project”, n.d.).


  1. Computer Science Challenge Game Tournament in Hong Kong.
  2. Devlin, K. (2011). Mathematics education for a new era: Video games as a medium for learning (1st edn.). A. K. Peters, Ltd.: Natick, MA, USA.Google Scholar
  3. Lavernia, E. J., Vander Gheynst, J. S. (2013). The algebra challenge. The bridge (Vol. 43, No. 2). The United States of America National Academy of Engineering.
  4. Mackay, R. F. (2013, March 1). Playing to learn: Can gaming transform education? Graduate School of Education, Stanford University.
  5. Minsky, M. (1970). Form and content in computer science—1970 ACM turing award lecture. Journal of the Association for Computing Machinery, 17(2), 1970.CrossRefGoogle Scholar
  6. Novotney, A. (2015). Gaming to learn. Monitor on Psychology, 46(4), p. 46.
  7. Pope, H., & Mangram, C. (2015). Wuzzit trouble: The influence of math game on student number sense. International Journal of Serious Games, 2(4), 5.
  8. Shapiro, J. (2013, August 29). Video games are the perfect way to teach math, says Stanford Mathematician, Forbes magazine.
  9. Tao, T. (2012a). Gamifying algebra. Terence Tao’s Wordpress blog article.
  10. Tao. T. (2012b). Software mockup of algebra game. (main Page, n.d.).
  11. The Algebra Game Project.
  12. Wing, J. M. (2006). Computational thinking. Communications of the ACM, 49(3), 33–35.CrossRefGoogle Scholar

Copyright information

© The Author(s) 2019

Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.

The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.

Authors and Affiliations

  1. 1.The Institute for Pure and Applied MathematicsLos AngelesUSA
  2. 2.Nautilus Software Technologies Limited, Department of Computer ScienceCity University of Hong KongKowloon TongHong Kong
  3. 3.Department of Electrical EngineeringPrinceton UniversityPrincetonUSA

Personalised recommendations