1. Computing & Technology

Discuss in my forum

Techniques used in games

General Algorithms as they apply to games

By , About.com Guide

This is a collection of ideas, and algorithms that I've used over the years. If you have any that aren't listed here, please email me at cplus.guide@about.com?subject=games mechanics and I'll include them, with a link to your site, blog etc.

Game Mechanics and Algorithms

  • Recursion. For most games, recursion can be replaced by iteration which is more efficient and less resource intensive. For some puzzles, eg Eight Queens and games like Atoms (see below), it is probably the only way. It can also be used to find the size of a contiguous block of cells in a 2d grid but care has to be taken it doesn't overflow the stack. Another use is maze walking with backtracking when dead ends are found.

  • Atoms. This is a grid based game where the main mechanic is adding 1 to each cell until it hits a limit (3 in corners, 4 on edges, 5 elsewhere), at which point it resets to 0 and adds 1 to the horizontal/vertical cells around it (2 in corners, 3 along edges), 4 elsewhere and takes ownership if the cell belonged to another player. If any of those cells hit their limits then a chain reaction starts.

  • A*. This is regarded as one of the best path finding algorithms. See A* on Wikipedia for details. Simply put it keeps a list of nodes and reevaluates the path as it goes along with lower costs routes prioritized.

©2012 About.com. All rights reserved.

A part of The New York Times Company.