oreilly.comSafari Books Online.Conferences.


Building Freeciv: An Open Source Strategy Game

by Howard Wen

If imitation is the sincerest form of flattery, then Freeciv is clearly a labor of love among its many volunteers. Since the code for this open source version of Civilization was released in 1995, hundreds of volunteers have added to it and improved it, even though the original developers haven't been heavily involved in years.

Freeciv runs on Linux, Windows, OS/2, and Amiga, and features online and network multiplayer capability. Initially, fixing the networking and multiplay proved to be the biggest challenges for the Freeciv team. Nowadays, the toughest jobs remaining include sprucing up the game's graphics and re-doing the artificial intelligence (AI). Continued efforts like these have become goals not unlike the strategy behind Freeciv's gameplay -- building and improving upon things over time.

Freeciv's Roots in Openciv

As it turns out, Freeciv is not the first open source version of Civilization. The idea for Freeciv came about one day when three Danish students were in their university's computer science lab, playing Openciv, a free multiplayer Civilization clone written in Python using Tk/Tcl. "We soon gave up on the game, as it performed terribly. At that point, the idea was born to write our own version in C," says Peter Unold, now a 30-year-old graduate student in Aarhus, Denmark. Along with two other fellow students, Claus Leth Gregersen and Allan Ove Kjeldbjerg, he created Freeciv while studying computer science at Aarhus University.

Making their own knock-off of Civilization, which would work better than Openciv, was not necessarily their sole motivation. The project was seen as a good way for all three to gain some skills in X11 programming and client/server game development. Because their goal was to learn these things as quickly as possible, a basic working version of Freeciv was finished in only three weeks.

While Freeciv was more stable than Openciv, it was not an entirely complete game. It was playable, just not very fun because there were a couple of technical problems that needed to be addressed. But Unold and the other two authors of the game moved on to other projects and responsibilities. Fortunately, with its source code made available to the public, Freeciv quickly gained a following, and a succession of administrators and volunteers picked up where Unold and his colleagues left off.

Client-Server Issues

One thing that proved especially challenging to fix up was the game's client and server system. The problem was deciding what should be done in the client and what in the server. "If the client had to query the server for information, you would incur extra latency from the network that would annoy the user," says Trent Piepho, a 25-year-old computer scientist from Seattle, Washington, who contributed lots of fixes and improvements to the Freeciv code in 1998. "But if you did something in the client, you had to worry about people modifying the clients to cheat."

"I also remember how we tried to limit network traffic by having the clients do as much [of the] calculation as possible -- thick server/thick client," Unold says. "We later gave up and went with a thick server/thin client solution."

"Some don't agree, but I think the strict client-server separation in Freeciv is elegant," says Thue Kristensen, a 22-year-old university student from Copenhagen, Denmark, who was once one of the administrators maintaining Freeciv. "It is my feeling that in all the commercial titles with multiplayer, each client has a complete copy of the game world. Having the strict separation in Freeciv means that cheating is impossible [because it] eliminates unintentional cases of revealing too much information."

Related Reading

Physics for Game DevelopersPhysics for Game Developers
By David M. Bourg
Table of Contents
Sample Chapter
Full Description

The client cannot make changes on its own; all it can do is ask the server to make changes. An example during gameplay would be the way a diplomatic action against a city is executed. The player does this by moving a diplomat into the city and then choosing an action from a pop-up menu. This actually works by sending the move request from the client to the server, which then sees it is a diplomat moving into a city and tells the client to pop up the menu. When the player chooses from this menu, the choice is sent to the server, where it is executed, and the results manifest themselves in the client.

"Letting the server tell the client to make the pop-up (and not letting the client act on the order itself) is smart because the server, when executing a goto, will move the unit without interaction," says Kristensen.

Pages: 1, 2

Next Pagearrow

Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: