Fog of War

By | May 6, 2020

This morning, I started to work on my implementation of the classic 4X fog of war mechanic for a prototype sci-fi game I’m working on. If you don’t know, 4X fog generally comes in two layers. The first is total darkness on those parts of the map that your units have never been to. The second is partial fog on those areas of the map you have explored, but that you are currently not within range of. Each unit and settlement generally has its own radius of observation, and outside of those ranges, you’ll see at most the tiles of the map, but not any units from other players/factions.

This probably goes without saying, but implementing this system is quite tricky. In my Javascript-powered game engine, I actually layered one canvas over another so that I could draw a fog layer over the map. I then have to keep track of where player-controlled settlements and units are located, and reveal parts of the map accordingly. This becomes especially tricky when a unit is moving, as most 4X games adjust the fog on the fly as a unit moves from tile to tile. You can see the preliminary results below:

This was hard, man.

You might have noticed the minimap in the bottom-left corner, which also has to be updated as the player navigates the game world. Needless to say, I have a long way to go with this game, but the fog of war element seems to be working.

Anyway, this all got me thinking about 4X fog of war, and where it might have come from. As far as I can recall, this two-layer fog has been present ever since the first version of Civilization, is now pretty much ubiquitous across the genre, and is even standard on real-time strategy games as well. Was Civ the first game to use it? What was, for that matter, the first video game to use any sort of fog of war implementation?

Wikipedia is as good a place as any to start searching for these kinds of answers, if only to see what sources have been cited. As it happens, there is an entire entry on the website for the fog of war concept, with a sub-section on video games. This is what it has to say:

“The earliest use of fog of war was in the 1977 game Empire by Walter Bright. Another early use of fog of war was the 1978 game Tanktics designed by Chris Crawford, which was criticized for its unreliable and ‘confusing’ fog of war system.”

The reference to Empire is an interesting one, as Empire has been cited as an inspiration for Civilization in several sources. In Benj Edwards’ history of the game on Gamastura, he says the following:

“Meier was also a big fan of an early computer game called Empire, which combined Risk-like world domination with intricate city management. ‘At one point, [Meier] asked me to make a list of 10 things I would do to Empire to make it a better game,’ says Shelley. ‘That was some of his research on Civilization.'”

In his recent work Vintage Games 2.0, Matt Barton says something similar:

“However, Meier was also a fan of the classic computer strategy game Empire, a turn-based war game created by computer programmer Walter Bright in 1971.” (p. 184)

So was Empire really the first video game to use fog of war? The Wikipedia article cites this work as the source for the claim, which comes from a small press that appears to focus on military history. That’s…okay, as far as Wikipedia sources go. But I wanted to investigate further.

As it happens, Walter Bright created an entire website devoted to his classic wargame. The history page is well worth reading in its entirety if you are into gaming history. The site also contains a wealth of other valuable information, links to reviews of various versions of the game, and, perhaps most importantly, source code for the earliest versions of the game, including the first version for the PDP-10, written in Fortran, and a later version for the PDP-11, written in assembly language. Binaries for later versions are also available.

Evidence from the first commercial versions of the game, including a review from the September 1984 issue of Creative Computing, make it clear that fog of war was in fact an important feature. But was it there from the start? The PDP versions of Empire date from the 1970s, so Wikipedia could be correct in that they were the first computer games to feature fog. But more evidence is required to make a final verdict.

Unfortunately, I don’t know Fortran or assembly well enough to decipher the available code, which is pretty long in both cases, and divided into numerous files. However, for the Fortran version, there is a help file written in plain text, which you can check out here. A couple of areas are worth highlighting. The first deals with the game map:

“THE MAP IS A RECTANGLE 600×1000 MILES ON A SIDE. THE RESOLUTION IS 10, SO THE MAP YOU SEE IS 60×100. THE MAP CONSISTS OF ‘.’: SEA, ‘+’: LAND, ‘*’: UNCONTROLLED CITIES, ‘X’: COMPUTER-CONTROLLED CITIES, ‘O’: YOUR DOMINATED CITIES.”

Note that there is no mention here of areas of the map being shrouded in fog. Compare this to a similar section in the manual for the later IBM PC version of the game, available here, which does mention “unknown territory” represented as blanks.

The second part appears later in the document, and explains a game feature called “sensor probes”:

“SENSOR PROBES ARE DONE BEFORE AND AFTER EVERY MOVE. SENSOR PROBES SHOW ONLY THE 8 SQUARES ADJACENT TO YOUR UNIT. THE MAP DISPLAYS ALL THE MOST RECENT INFORMATION.”

This text makes it clear that there is a fog of war mechanic implemented in the game, in the sense that you can only “see” live information on the map around the areas where your units are located. On the rest of the map, you’ll only see units where you last encountered them. But what about the actual terrain on the map? Is that invisible until you explore it, just as it is with modern 4X titles? That is unclear.

Returning to the IBM PC version of the game, there is a section in the manual that describes a feature very similar to sensor probes:

“The entire map is unknown (blank) until you start to explore it. Beware, however, that you cannot detect enemy pieces unless you are right next to them. The actual map that you see on the display is a summary of all the most recent information that you have about the world.”

Note that the last sentence is virtually a duplicate of the one found in the PDP-10 version’s help file. More importantly, the manual indicates that you can only see the live locations of enemy “pieces” that are adjacent to your own, just like in the PDP-10 version.

In fact, this text makes it clear that the IBM PC version of Empire implemented a two-tier fog of war system, of the sort found in Civ and other 4X games. The game map is initially “blank” – that is, covered in black tiles – until you start exploring it. Screenshots of the game, including one found in the Creative Computing review, make this clear. This is from the Amiga version:

In addition to these blank areas on the map, however, there is a second layer of fog, in that enemy units are only visible if you are beside them. Or, if you passed by them earlier in the game, they are located in those tiles where you last saw them. Again, the Amiga screenshot illustrates this.

All of this evidence points to a very interesting fact: the two-level fog of war system, used in the first version of Civ, and in virtually every other tile-based 4X game since, was actually derived from Empire. The games are thus closely connected, perhaps more so than is generally assumed.

Does this mean that Walter Bright invented this mechanic? That’s still an open question, as least as far as I can determine. The PDP versions of the game clearly had one level of fog, in that you could only see live enemy units when you were beside them. But was the game map itself shrouded in darkness before you explored it, like how the second level of 4X fog operates? Unfortunately, I don’t have a PDP machine handy to check on this, and as I said I can’t quite grasp the code. My gut feeling, however, is that the entire map was in fact visible from the outset — I just don’t see anything in the help file, or anywhere else, that indicates that you have to explore the map to uncover its terrain. Again, though, I can’t verify this right now.

It would also be worth checking out the fog mechanic from Chris Crawford’s game, as mentioned in the Wikipedia article. I will save that for another time.

This article was published on: 05/6/20 7:27 PM