Video games and mathematical concepts
Video games are a significant part of contemporary culture, blending entertainment and technology in ways that often incorporate mathematical concepts. The development of video games, which can range from simple puzzles to complex simulations, relies heavily on mathematics for graphic design, physics, and gameplay mechanics. For example, when creating visual elements, programmers use geometric shapes and mathematical principles to portray objects realistically, including the use of polygons and meshes in 3D modeling.
Additionally, color representation in games involves understanding light and pigment mixtures, utilizing primary colors of light (red, green, blue) to create a wide spectrum of colors on screens. Another essential mathematical concept used in video games is the generation of random numbers, which affects gameplay outcomes and adds unpredictability.
The educational potential of video games is increasingly recognized, with initiatives to incorporate gaming into learning environments aimed at enhancing mathematics and science skills. As such, video games not only serve as entertainment but also provide valuable opportunities for engagement with mathematical concepts in both recreational and educational contexts.
Video games and mathematical concepts
Summary: Video games use the mathematical concepts of algorithms, matrices, and random numbers as part of their programming.
Video games are pervasive in modern society, from computers to television-based systems to applications that can be downloaded easily onto cell phones. There is an ongoing debate over what should be called the first video game. The narrower definition is a game generated by a computer and displayed on a video device. Others consider it to be any electronically based game displayed with video output. The most likely candidate is a 1940s invention by physicists Thomas Goldsmith and Estle Ray Mann. Their “Cathode-Ray Tube Amusement Device” was inspired by World War II radar displays and allowed the player to shoot virtual missiles at targets. Though patented, at the time it was too costly to produce commercially and only a few prototypes were ever made. Much of the mathematics used to design and operate computers also applies to video games and the various fields and professions are closely connected. Video game design programs offered by many colleges emphasize physics and mathematics education along with computer programming, as these skills are necessary to represent the real world in increasingly realistic ways. The new generation of body-sensing game controllers uses optics to detect a player’s motion in three axes and translate it to corresponding movements within the game environment. While most people think of video games as entertainment, they are increasingly being incorporated into the classroom and other learning applications. In 2009, U.S. President Barack Obama initiated a campaign called Educate to Innovate, which seeks to use interactive games, among its other strategies, to improve the mathematical and scientific abilities of American students.
![An example of a village in Clash of Clans By Kolele22 (Own work) [CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons 94982098-91655.jpg](https://imageserver.ebscohost.com/img/embimages/ers/sp/embedded/94982098-91655.jpg?ephost1=dGJyMNHX8kSepq84xNvgOLCmsE2epq5Srqa4SK6WxWXS)
Simple Modeling Using Polygons
Any video game that has graphics needs to have a way of drawing a picture on the screen. A very basic program can take a turtle (or curser) on a screen and move it forward and rotate its direction clockwise. Many geometrical shapes are easy to draw using a turtle. For example, to tell the turtle to draw a rectangle, a simple program might tell the turtle to move 100 steps (which could be measured by pixels on the screen), turn 90 degrees, move 50 steps, turn 90 degrees, move 100 steps, turn 90 degrees, and move 50 steps. At this point, a 100×50 rectangle has been drawn, and the turtle is perpendicular to the position where it started.
A circle (or any object with a curve) would be much more difficult to draw using these commands because of the thickness of a pixel and the fact that the turtle cannot move half degrees. A user could try to tell the turtle to move one step then turn one degree. After repeating those commands 360 times, the turtle will be back where it began, and will have drawn a circle that is slightly less than 115 steps across. Technically, it did not draw a circle, but rather a polygon with 360 sides. A slight modification may be to tell the turtle to move two steps then turn one degree. After 360 repetitions, the turtle will appear where it started and the shape appears to be a circle that is twice as wide as the first shape drawn, about 229 steps wide.
There is a big gap between 115 steps and 229 steps wide. If a programmer needs a circle between those dimensions (or beyond those dimensions), the programmer can use mathematics to adjust the step length to get a circle of the desired size. The length across a circle is called the “diameter” and the distance around a circle is called the “circumference.” The relationship between these two measurements is C=πd, where C is the circumference, and d is the diameter.
Since the turtle will be tracing the outside of the circle, it will travel the length of the circumference. The turtle will also be making 360 turns during its travel. Since each step should be the same length, one can find the length of each step by taking the circumference and dividing by 360. Since π is approximately 3.14, one can estimate the length of the step by multiplying 3.14 and the desired diameter and then dividing by 360.
Depending on the video game being created, a programmer will probably desire to draw more than circles and polygons. Using the above steps for a circle but only repeating the steps 180 times will yield a half circle, which could approximate the shape of a setting sun, the top of a silo, or the ice cream in a cone. More complex shapes, like drawing a long-haired cat, could be made by the turtle but the programmer now has a time concern. The programmer creating the directions to draw the cat and the fur on the cat would require a long time to type in the programming for the cat—and even more if the cat is supposed to move—since the repeat step would be used sparingly, if at all. On the users end, a large program with a lot of steps would take a long time to draw, depending on the speed of the computer or gaming system on which it is to be played.
Although video games are displayed on a two-dimensional screen, programmers now commonly create elements of the game in three dimensions. To mimic the body of an object, programmers create the outer shell of the object using a mesh of triangles or quadrilaterals. Depending on the detail desired, more meshes could be created. Once the object is created, it needs to be displayed on the screen. This process involves using a “point-of-view camera,” which will change how the object is drawn based on where the camera is and how far away it is from the object. The triangle mesh of the object is adjusted accordingly. For example, as the object approaches the camera (gets closer to the screen), the triangles will elongate and become larger. A programmer that wants the object to get closer to the camera and rotate will use vectors and matrices (linear algebra) to adjust the size and the dimensions of each triangle in the meshes. Once the computer does the mathematical calculations to modify the triangle mesh, the point-of-view camera creates a two-dimensional image of the three-dimensional mesh in the orientation it has been set to. This two-dimensional image then gets projected to the viewing screen.
Interesting geometry is also found in the movement of objects through the game. In some cases, like the games Portal and the older PacMan, players can exit the playing field on one side of the screen and return from another side or in a different orientation. This property involves concepts like a torus and higher-dimensional analogs.
Color
When programming colors (assuming the screen is not monochrome), a programmer needs to remember that the primary colors for light are different than the primary colors for pigment. When drawing on paper, the three colors magenta (red), cyan (blue), and yellow can be combined in such a way as to create almost any other color. For example, many color printers only use three colors to print. Since most screens work based on a projection of light (whether a computer monitor or a television screen), the primary colors of light must be used. For light, the colors red, blue, and green are the primary colors; with these colors, any other color can be created. All three together make white, and no light at all makes black.
When coding colors, each of the three primary light colors is given an intensity value 0–255. This value is then converted to a two-digit hexadecimal number, where 00 is the decimal number zero and FF is the hexadecimal number 255. The hexadecimal number 12 would be an intensity level of 18. The hexadecimal number A0 would be an intensity level of 160. The programmer then takes these three intensity numbers and combines them to make a six-digit color number by placing the intensities in order for red, then green, and finally blue. For example, pure red would be FF0000 (intensity 255 for red and intensities 0 for both green and blue). Similarly, 00FF00 would be pure yellow and 0000FF would be pure blue. The color white would be represented FFFFFF (a combination of all three colors), whereas black would be 000000 (no light whatsoever).
Random Number Algorithm
Many video games that have been created offer a storyline or, at least, a progression to get from one stage or level to the next. Moving to the next level often requires a certain level of skill or collecting certain objects. On the other hand, there are video games that are created, like video poker or Tetris, where skill alone is not enough to do well. There is a certain random element that will determine the outcome. However, computers are not capable of creating random numbers. Instead, the video game console is pre-programmed with a list of pseudo random numbers. For example, every TI-84 calculator that has its memory reset will create the number 0.94359740249213 as its first “random” number. Obviously, if everyone obtains the same result, it cannot be random.
Using the TI example, every random number it produces will be a decimal between zero and one. If the game requires a number higher than one, the programmer merely multiplies the random number times the highest number they desire. For example, in Tetris, there are seven tetrominoes that could be selected for the next drop. A programmer may want a random number generated to determine the shape of the next piece. As a result, the programmer would create a random number, and then multiply it by seven to get a number between zero and seven; however, this number is still a decimal. The computer programmer can then tell the console to truncate the number, which would ignore everything beyond the decimal point giving an integer between zero and six. A final (optional) step would be to add one to this truncated integer resulting in a number between one and seven. Each block would get assigned a number, and the pseudo-random number that resulted would select the next block.
Bibliography
Dunn, Fletcher, and Ian Parberry. 3D Math Primer for Graphics and Game Development. Plano, TX: Worldware, 2002.
Egan, Jill. How Video Game Designers Use Math. New York: Chelsea Clubhouse, 2010.
Flynt, John P., and Boris Meltreager. Beginning Math Concepts for Game Developers. Boston: Thomas Course Technology, 2007.