CARLETON UNIVERSITY Software Development of the Board Game Agricola COMP4905 Computer Science Honours Project Robert Souter Jean-Pierre Corriveau Ph.D., Associate Professor, School of Computer Science 4/19/2013
Abstract Agricola is a popular board game based around players expanding their farms to their maximum potential using pastures, fields, and a growing family. This report details the coding of the farm based game in Java for easy to use gaming of Agricola. Featuring 1-5 players, this code uses a model-viewcontroller approach for organization and a grid bag layout for farmyard display. My program features a simplified game interface that eases users into the normally cluttered board and abstract pieces of Agricola. The incorporated AI uses a utility-based agent approach to make decision on their actions to enhance their farm over their opponents. The game plays for 14 turns, and the winner is decided based on the quality of everyone s farms. Table of Contents Introduction.3 Design..3 Results....5 References...6 1
List of Figures FIGURE 1 [BoardGameGeek, 2013] FIGURE 2 2
Introduction Agricola is a strategy board game created by German game designer Uwe Rosenberg, and published in 2007 [BoardGameGeek, 2013]. The game involves taking the role of a farmer building their farm, but this is much more interesting than it sounds using resource management and strategic decision making. Agricola can be played solo, or with up to five players. Each player starts with two family members, and every turn each family member performs an action, which can include collecting resources, expanding the family, building rooms, and much more. After any player takes an action, that particular action cannot be played by anyone for the remainder of the turn. Over the course of the game s 14 turns, there are 6 harvests where each player must feed their family using primarily accumulated livestock or grains and vegetables. At the end of 14 turns, each player s farms are given point values based on a pre-determined scoring system as to how developed their farms are. So, the game s goal is to end with the most impressive farm while feeding your family through harvests. My honours project goal was to code Agricola in Java, where a player can play in a solo game or play against computer AIs or fellow players. I feel Java was a good choice to use a point and click interface for the game in a Java applet window. I chose Agricola because I m a fan of board games, and the strategy involved intrigued me. Even though the goal is straight forward, there are many ways to build your farm, and even though there isn t direct competition in the game, there is competition for optimal actions. These complications also made it intriguing to develop a working AI to play this game. It is also relatively new game, and there are very few ways to play Agricola online, and the one instance I found uses a much different interface and code language [Deotte, 2013]. Design Agricola is a board game, so translating an entire board onto a single user interface can be a challenge. As seen in a complete two player game in figure 1, Agricola in particular can make for a cluttered screen if 5 farms need to be on screen at once. As seen in figure 2, I decided to have only one large farm on the screen at a time. The viewed farm can be changed using a drop down in the top left hand corner. I chose to only view one farm at a time because having 5 farms on one screen, with all the required buttons, would be far too cluttered. Since competition is indirect, opponent s farms don t normally have to be seen at all, only when actions and resources may be in dispute. Player resource totals are also directly underneath the farm in plain view, and available actions take up the right side of 3
the interface. Since Agricola isn t a straight forward game, the more complicated actions have a brief description which results in the buttons taking up a lot of space. I feel the layout still looks nice though, and the blank spaces open up since more actions are available later in the game. The time until harvests is very clear however, so players can adequately plan ahead. I kept the farm and display colors unique and consistent to enforce clarity, for example representing a wooden room simply as a red space, which is consistent to the color of the wood counter displayed on screen. For the design of the code, I decided to use a model-view-controller approach [Reenskaug and Coplien, 2009]. Because a lot of information had to be stored, and this game was best viewed within a window, it was important to have a specific layout for easy organization of code. The controller does the most work in the single class, interpreting user commands and altering the state of the view and model. The view has two parts, since I wanted to have the displayed farm a separate class apart from the numerous buttons and displays, but the farm it is still displayed with the view. The model is all the information stored within the Player, Space, and Farm class. The Player class stores resources, family members, and whether the player is human or not. The Space class represents a space on the farm layout, whether it is a fence space, a main farm space, or a blank button, and the current state (empty or used fence, room space, field space, etc.). The Farm class is just a 2d array of the Space classes to easily represent the farm. This farm is displayed using a grid bag layout to keep the farm within one table, but with varying button sizes because the main farm spaces need to be bigger than the fence spaces. Overall, the MVC approach successfully kept my code organized properly. The AI present uses a utility-based agent approach [Oommen, 2012], where the end goal of the AI is to reach the best farm in the end, and each action s intent is to improve the farm as much as possible. Some improvements, like building rooms, are only possible with the accumulation of resources, so the AI both looks at resources needed and available, improvements possible, and immediate need for food (especially if a harvest is imminent). The AI s environment while evaluating is static and discrete. The environment does change between turns however, and taking actions before another player can use these actions can also be considered. On the highest AI difficulty setting, the AI considers the next player s farm, and if there is a high potential action that the next player is likely to make, the current player s turn is more likely to pick this action. This allows for a competitive game against artificial opponents, which are aware of the game s goals to build the best possible farm while consistently feeding their family members. 4
Results I am pleased with the usability of my program to play the game of Agricola. It is easy to pick up and play, a stark contrast to the actual board game s set up time of 10-15 minutes in my experience. The game itself can be difficult to learn, with the original board game using abstract wooden pieces for all the resources, which are only different in color and shape (animals are square, resources are circular). My program application actually makes the representations easier, having a constant reminder of how much of each resource you possess and which resource is which color. The learning curve can still be high though, but that is within the game itself as well. I was only able to implement hot seat multiplayer play, but the game can be expanded through networking successfully. I was also only able to implement a basic game rule set, while the actual game gives the option to play an advanced game. This mode incorporates over 300 cards to be used throughout the game as farm improvement and occupations given to family members. These 300 cards happen to be all unique, and usually involve simple improvements like bonus food on certain turns and easier construction of rooms for family members. The advanced game does not change gameplay drastically, but it gives successive plays of the game a more unique feel. Agricola also has multiple expansion sets with the potential to be coded, but many just add more cards to gameplay [Z-Man Games, 2013]. I was able to successfully program the board game Agricola in Java using a model-viewcontroller design to neatly organize my code. Despite the game s inherent cluttered game board, my program simplifies the layout and allows the user a point and click interface to deploy their actions. Anywhere from one to five players are supported, and the AI players use a utility-based agent approach to determine actions to better build the farm. My program allows users for easy access to the basic game of Agricola, with the potential to expand through the advanced version and the many expansions of the game. My program successfully lets users play Agricola both with the friends and with challenging enemy computer players within a neat and tidy user interface. 5
References BoardGameGeek (2013) Agricola, boardgamegeek.com/boardgame/31260/agricola. BoardGameGeek (2013) Agricola Images, http://boardgamegeek.com/image/1580741/agricola. Deotte, Chris (2013) Play Agricola Board Game Online, http://playagricola.com/agricola/board1/agricola.html. Oommen, J (2012) Arficial Intelligence Agents and Environments, http://people.scs.carleton.ca/~oommen/courses/comp4106fall12/ai_ch2agents.pdf. Reenskaug, T., Coplien, J.O., (2009) The DCI Architecture: A New Vision of Object-Oriented Programming, http://www.artima.com/articles/dci_vision.html. Z-Man Games (2013) Agricola Overview, http://www.zmangames.com/boardgames/agricola.htm. 6