Amit's Game Programming Information

- shortest paths - ai - design - tiles - scripting - hexagons - objects - adventure -

About this page: I collect links to information about topics that I find useful in my games, and not all topics related to game programming. I try to avoid topics specific to one platform, such as graphics, sound, compilers, and specific libraries. I prefer ideas to source code, because I find it easier to go from an idea to code than from code to an idea. Since I only cover a few topics, you may be wondering where to get more information. Try other game programming sites. One common thing people ask me is how do I make games? (Note that I didn't write that article, and I don't have source code for you.) If you're an absolute beginner, read the Newbie FAQ, and be aware that my own pages may not be at the right level for you.

Note: I have removed links to Gamasutra's great articles because they have become a registration-required site.

Key to the bullets (implemented with style sheets):

Shortest Paths

Determining how to walk around on a map is an interesting problem. There are many different approaches, ranging from simple (walk forward until you hit something) to the complex (path finding algorithms with heuristics). I've been writing some pages about path-finding algorithms and ideas; John Lonningdal has several pages about algorithms that are simpler to implement; and I've also saved some articles from newsgroups. These are pages about pathfinding in general, with some bias towards A*:

These pages are about specific techniques for pathfinding and object movement:

My current favorite algorithm is A*, because it can handle varying terrain costs well, and it seems to be faster than most graph searching algorithms. However, it's unclear whether A* is the best choice when there aren't terrain costs to worry about; another algorithm may be optimized for fixed movement costs. Also, A* deals with discrete steps, not with continuous movement, so other algorithms are better when you want to find a continuous path (like a spline path). You can also build hybrids, where A* is used for large scale paths (between waypoints) and other techniques are used for finding paths between waypoints. From an implementation perspective, A* may be more difficult if you aren't familiar with some forms of mathematics (graph theory, at least).

The link to my A* code is to the second version [4-Feb-1998], with bug fixes, optimizations, and parameterization for different heuristics and cost functions. The first version of my code is available on Steve Woodcock's pages, and it may be easier to read and understand.

Search for more pages on A*, pathfinding.

Tile Based Games

Although the latest games seem to use 3-D rendered worlds, tile-based (2-D or isometric) games appeal to me because they tend to have more work put into the game play and less in flashy graphics. Two recent games that use isometric displays instead of full 3-D worlds are Roller Coaster Tycoon and SimCity 3000. In these games, the artists can put in details that you may miss with 3-D polygons. You can get quite a lot of bang for the buck when using tiles -- building worlds from a few key tiles is somewhat like building hundreds of thousands of words from just a few letters. I'm fascinated whenever the whole is much greater than the sum of its parts, and tile based games are no exception.

Search for more pages on influence maps, isometric maps, line of sight.

Hexagonal Grids

Many war games use hexagonal grids instead of square grids. Squares share an edge with four neighbors but also touch another four neighbors at just one point. This often complicates movement along grids because diagonal movements are hard to weight properly with integer movement values. You either have four directions or eight directions with squares, but with hexagons, you have a compromise -- six directions. Hexagons don't touch any neighbor at only a point; they have a small perimeter-to-area ratio (and therefore used by bees); and they just look neat. Unfortunately, in our square pixel world of computers, hexagons are harder to use, so I've collected some articles that may help you turn common square-grid algorithms into hex-grid algorithms.

Search for more pages on hexagons.

Artificial Intelligence

Many times I play a game and wish that the computer opponents were written better. Sometimes the computer player is given different rules; other times it has the same rules but gets more money (or other resources) than you. The result is that the game doesn't seem balanced: it's just too obvious that the computer is not playing well, and that the game is brain vs. brawn rather than brain vs. brain. At the same time I don't want AI that's too good; if it were, then it'd always beat me and I'd be frustrated!

I've collected some articles and pointers to information about artificial intelligence in games. The first link is to Steven Woodcock's AI page, which should be your first stop when looking for AI information as it relates to games. There's a lot of interesting reading here!

Search for more pages on artificial intelligence, genetic algorithms.

Object Oriented Programming

I have found that the best places to use object oriented programming are user interfaces, operating systems, and games. It's commonly believed that objects are too slow for games, but if you use them appropriately and only where they're a benefit to your design, they should not be a major problem for speed. I've saved some articles discussing objects, games, and efficiency, and there's also a link to an object framework for tile-based games. The first listed article is especially good to read if you are concerned that object-oriented programming is slow; it analyzes the assembly code produced by C++ compilers to show how it compares to procedural code.

Below are articles related to object oriented design but not specifically about games.

Search for more pages on objects.

Adventure Games

Although I'm not a big fan of adventure games, I've found that adventure game writers often have more time to work on story and game design than people working on action games. If you're looking for story ideas or story design tips, or if you're working on a MUD (as I am), take a look at these.

Search for more pages on interactive fiction, adventure games.

Game Design

A lot of what is hard about writing a game is getting the design right. What makes a game fun? Game design is an art, not a science. I haven't seen any books I really like on this subject, but there's one that sounds promising: Game Architecture and Design. One of these days I hope to have time to read it.

Search for more pages on game design, design documents.

Scripting Languages

One of my favorite topics is scripting languages, but I don't see much discussion of them as related to games programming. I think that scripting languages give you a way to write a lot of non-speed-critical code with comparatively little effort. You can design the language to specifically deal with your game, so the amount of work you have to do is less than for a general purpose language. Also, you can write the compiler to optimize for different things (like size instead of speed), allow more features (like dynamic patching at run-time), and even user customization (for enthusiastic users!).

I think for the best results, the scripting language should be game specific. I want to be able to write scripts, not code. For example, a script for a play might look like this:

       Amit [to Steve]: Hello, friend!
       Steve [nods to Bryan]: Welcome to CGDC.
       [Amit exits left.]
      

Note that it's very high level: it doesn't specify exactly how Amit speaks or how Steve nods or even the timing. For this to work, you need to have some assumptions about how people behave, and that makes the language specific to the system you are setting up. In this particular language, the use of brackets marks actions and the colon marks speech. In another language brackets might mark optional parameters and colons mark sections. The more general purpose your language, the fewer assumptions you can make, so it becomes more verbose. For example, the conversation might look like this:

       Amit.turns_towards(Steve);
       Amit.walks_within(3);
       Amit.says_to(Steve, "Hello, friend!");
       Amit.waits(1);
       Steve.turns_towards(Bryan);
       Steve.walks_within(5);
       Steve.nods_to(Bryan);
       Steve.waits(1);
       Steve.says_to(Bryan, "Welcome to CGDC.");
       Amit.waits(3);
       Amit.face_direction(DIR_LEFT);
       Amit.exits();
      

That's a program, not a script. See the difference? The script is high level, and specifies what you want to be done, while the program is low level, and specifies exactly how to do it. It's not a great deal harder to interpret the first syntax than the second. You already have a programming language (C, C++, Pascal, Basic, etc.). You don't need another! (Unless your goal is simply to allow run-time flexibility, which can be done with dynamically loaded libraries, or by using an existing language like Python.)

Try to think differently. Your scripting language doesn't have to look just like C. Think about using an event-based structure. For example, have commands like "when X happens, do Y." Think about having many things happen at once. Amit doesn't have to stop just because Steve is saying something. Think about different styles of programming, like rule based, functional, imperative, logic, and object-oriented. Think about alternate rules of logic, like fuzzy logic (truth isn't certain) or linear logic (one truth can turn into another, making the first false). Make the language take advantage of the structure of your game, and you may find it much easier to build parts of your game world.

Search for more pages on scripting languages.

Economics

Economics is the study of human choices when it comes to managing resources (money, time, happiness, raw materials, goods, and so on). In many strategy games, economics is an important aspect of the design. Balancing the resources of your world can be a fun part of the game. Economics is also important in multi-player game dynamics: you want to reward people for making money, yet you don't want them to have so much power that new players cannot have fun. One thing I want to explore is how location influences economics. In high school economics, businesses compete by price. Whichever business sells for less will win. But if transportation cost is a factor, then both businesses can coexist, and the player has to make interesting decisions about where to place new facilities to balance all the variables (availability of labor, transportation cost of raw materials, transportation cost of product, tax rates, zoning laws, etc.).

It's hard to come up with rules for economics in an online virtual world when the underlying costs are so different. In the physical world, "objects" take resources to build, but they typically do not use resources to keep (if you don't use them), and you typically do not get those resources back when you throw the object away. Therefore our real world economy is based on buying things. In the virtual world, the "objects" take a small amount of memory and if you destroy the object, you get the memory back. At the same time, the very existence of a virtual object costs CPU time, which cannot be recovered. Therefore the virtual world economy might be based on renting things. If your world's economy reflects the underlying costs, a diamond ring may "cost" as much as a bucket of sand. Although this reflects real costs of running your server, and therefore would discourage players from overloading it, it may not make sense for your game.

In addition to the economics of objects, you have to consider the economics of living in the world. In the physical world, mere existence of a person has a cost; in the virtual world, existence is cheap. Since a player may not be "logged on" all the time, it's hard to come up with fair rules for the cost of existence without penalizing either players who play a lot (your core audience) or players who can't log on much (who are likely to leave if penalized for not being there all the time). If you require someone to work for a living, the casual players may not be able to compete, and may leave.

Rants

Sometimes I have strong opinions about particular subjects, and I want to write them down. So here goes.. I've started a section on this page with rants I have made into web pages.

Possible topics for future rants:

  1. Arrays vs. Lists
  2. C++ vs. Java
  3. Objects vs. Non-objects
  4. Templates vs. Inheritance
  5. Dynamic cast vs. Visitor
  6. Casts vs. Conversions

Miscellaneous

Some things I just can't justify classifying, but hope that they will be of interest to game programmers:

Search for more pages on terrain generation, or

Search Google:

Notices

This page and other pages I have written are Copyright © 2001, Amit J. Patel.

If I have a link to one of your pages or to a saved copy of something you posted to a public newsgroup, and you would prefer that I remove the link, please send me email.

And finally, for those who don't know me: I am not a professional game programmer. I do not do "contract" games. I am not looking for a job. This is just a hobby of mine. Please don't write to me about exchanging links, advertising, or web rings. I'll just say no.

(counter)

Last modified 22:53 Tue 27 Nov 2001, Amit J. Patel