Wikijunior:What can you use math for?/Video Games
When people play a video game, they are not usually thinking about numbers. Regardless of the game, most of the thinking they are doing is logic, or trying to decide the best choice. Playing games does not have to be done so casually however. For every game, there are people interested in the best way to play; this can be found out by using math. More importantly, whenever one plays against or with "the computer" in a video game, the computer must know the rules of the game and how to win (as well has how to adjust difficulty for different players). But a computer can't do anything without being taught how to do it by a human. This is where math comes into play; math is the language computers speak, and it’s the only way to tell them how to play games.
Just like robots in science fiction, computers can only do exactly what they are told. That might make one think that we'd be better off doing their jobs ourselves, but computers can do what they are told much faster than any human ever could. They are not limited to simple tasks, either; if a person could tell a computer how to think, (which is not an easy task, but is being developed) a computer would be able to think. The process of writing instructions for a computer is called programming, and it is a very big, popular career today.
Every video game must be programmed, but nowadays not everything they write is numbers. Some is a sort of mixture between human language, logic, and math known as code, but math is still essential to the process. Developers of video games have to make music and graphics for the game, but they also have to tell the game how to work. For example, in 3D games, developers have to tell the computer how to make things be displayed when viewed from different angles and how to make objects to not go through each other. All of these are big challenges, but possibly the biggest challenge is making Artificial Intelligence, also known as AI. While AI in video games is not real intelligence like humans have, it can still seem like it is human when it plays the game.
Every game can be broken down with math and expressed somehow with numbers. To illustrate this, we can start with a simple game like checkers. The board has 8 rows and 8 columns, for a total of 64 squares. Each square could have either 0 pieces or 1 piece and that piece could be either red or black. So we might describe the board at any given moment as 64 different numbers arranged in a square (known as a matrix). For each number we could say that 0 means no pieces, 1 means a red piece, and 2 means a black piece. We could also do this be having a number for each piece: where it is on the board. This is pretty simple for checkers, but it is not always. If we were to try to define a 2D area with numbers, we would have to use many very small squares and make some things able to be in several squares at once. This way, a player could move a little bit at a time instead of in big jumps. If the world were 3D, there would need to be even more information about where something is.
Going back to checkers, the best way to define the game is to give each piece two numbers: its row and its column. To start defining moves, we could say that a piece can only move diagonally by saying that it must change rows and columns at the same time, and it can only move over one at a time. To say this with math, if you add or subtract 1 to a row, you must add or subtract 1 to a column. To keep players from going off the board, it’s important to say that a piece can never move above the row or column 8 or below the row or column 1.