Age of Discovery and more about complexity

I’ve completed the touch-table version of Age of Discovery and this article compares this project to my previous project which was Medici.

ageofdiscoveryboardFor both being touch-table conversions of board games, they were very different projects. Medici was small and took less time than I expected it to. Age of Discovery was a large project, and it ended up being even longer than expected.

 

Age of Discovery is a worker placement game set in the colonial period. Players take on the role of a colonial power trying to establish the best empire by discovering and settling the new world.

Age of Discovery is a recent re-print of a game that we own called Age of Empires III: Age of Discovery. We’ve played our version regularly (though not frequently for many years). The new version includes pieces for a sixth player, new buildings and a new worker type.

I’ve been hesitant to computerize this game because it is fairly large and we don’t play it that often. However, it does play six and doesn’t have any hidden information. It also takes quite a while to setup and it can be hard to quickly see the state of the new world and how each player is doing.

Complexity

Unlike Medici, this conversion took quite a bit longer than I expected. Part of the difficulty was that the buildings in the expansion ended up being more complex than I was expecting. But there were also a lot more graphics to collect than I thought, and the game flow ended up being messier than I expected.

ageall

Art assets

Medici had fifteen new images that I pulled from asset packs or the internet. Age of discovery had 48. It also had three times as much audio. All the audio in Medici was pulled from old projects, while Age of Discovery has seven new sound effects. I am not an artist or good with creating audio effects, so I use thenounproject.com and a variety of free audio websites to find art and sounds that I can use in my games.

Unique buildings

I underestimated how many of the buildings in Age of Discovery would need special code. A common feature of some board games are assets that you can acquire during the game that grant a benefit or let you break the normal rules in some way. My previous conversion of Le Havre is another example of a game with lots of buildings the players can acquire. When I started this project, I assumed there would be about ten “types” of buildings and there ended up being 20. What was worse; 13 of those needed a dialog for player interaction (more on that later).

Something that can be non-intuitive is that the number of buildings doesn’t really matter. Age of Discovery has a bunch of buildings that all provide a benefit (a type of worker, some money, etc) each turn. All those buildings use the same code and count as one “type” or “class” of building. It took less time to write the code to handle those 15 or so buildings than it did to handle a single building that gives the player a one-time choice of two specialists.

Game flow and state

Another factor that makes a game difficult to computerize is complex game flow. In a simple game like Medici or most card games, players take turns doing something and then there is some end of round or end of hand cleanup. Age of Discovery has many stages of action. First, players take turns placing their workers in the action areas. Then each action area is executed for each worker in that area. These actions usually involve player input. Then there are end of round and end of age actions.

Here is a much simplified view of the game flow in Age of Discovery. The details aren’t really important, what I want to show is the number of loops:

for three ages
  for two or three rounds
    Place workers in turn order skipping players who are out of workers
    Execute actions
      for each colonist slot with a worker
         ask the player where to send the worker
           possibly give player a trade good
      for each trade slot with a worker
         ask the player which trade good
      for each building slot with a worker
         ask the player which building
            perform the building ability (showing Papal Edict)
              ask player which other player will place workers
                ask first player for territory
                ask second player for territory
      for each warfare slot with a worker
         ask the player if war or battle
           if war declared
             for each territory
               ask attacker for casualties
               ask defender for casualties
           else pick territory
              pick casualties
    Trade Income
    Buildings
  Score regions

At the inner-most levels of the nesting, the game is holding lots of state to keep track of where we are in all the higher level loops. All of these levels and loops adds complexity, but the real problems happen when the game needs to ask the player something. Then the software has to break out of all these loops, get the player input and then resume where it left off.

I used our standard event system to perform the actions in this game. The event system is still great, but doesn’t really help with managing game state. The next time I do a game with this level of complexity, I’m going to add a state machine, or at least a state class and a stack of states, to the model of the game. Without a formal state model, I ended up adding a lot of member variables to the player and game classes to hold state. This is frowned upon in object oriented programming, but more importantly, it creates a lot of opportunities for error. Either by forgetting to reset these variables at the right times or by making it hard for the GUI code to tell what state the game is in and therefore what to draw on the screen.

At 93 hours, Age of Discovery took about five times as long as Medici. The following table compares the relative time that I spent on each type of task in the two projects.

Task Time Percent Percent in Medici
Asset creation 11 hr 12% 17%
GUI layout 22 hr 24% 28%
Coding 41 hr 44% 44%
Testing 19 hr 20% 11%

To get an estimate for the lines of code created by Unity for GUI layout, I estimated that each hour of coding created 90 lines of new code (15 less than in Medici). At that rate, the time I spent on the GUI would be 1982 lines of code. So the GUI layout and Coding tasks are further broken down by what type of code they create:

Task Lines Percent Percent in Medici
GUI layout 1982 33% 32%
Graphics/Animation 1419 24% 27%
Game model 795 13% 6%
Game flow 1447 25% 14%
Full reuse 217 4% 12%
Partial reuse 66 1% 9%

Age of Discovery is a large game, but it isn’t the the largest that I have done. Both Caverna and Terra Mystica are bigger games that I made in the Unity engine. It is harder to compare Unity projects with older Torque projects (especially since I didn’t keep track of hours for my early projects). But I think that Le Havre was about the same size, Fire Platoon, Power Grid and Hansa Teutonica were a bit bigger.

Game LOC Raw lines Hours
Caverna 7800 16000 200
Terra Mystica 6900 13000 120
Hansa Teutonica ? 12000 ?
Le Havre ? 6278 150
Age Of Discovery 5926 9876 93
Medici 1631 ? 18

 

One thought on “Age of Discovery and more about complexity”

Leave a Reply