On this page:
2.1 The Rules
2.2 Game State Representation
2.3 Game Protocol
2.4 Examples
2.5 Handin Procedure

2 Economancy Player🔗

Due: February 16

Economancy is a card-drafting game that can be played in base mode or with a reduced or expanded set of cards. The game works with 2 to 4 players, and we will create player programs that work in any of those configurations. At first, we’ll consider a subset of the base cards, leaving more base cards as a future addition to the assignment.

2.1 The Rules🔗

See the Economancy site for the game rules. You’ll need to extract card details from there, either from the setup picture showing cards in the shop area, or from the PDF linked at the end of the rules.

2.2 Game State Representation🔗

Your Economancy player can use any representation internally that you find convenient, but to play against other Economancy players, we’ll need to pick a common exchange representation. The exchange does not need to contain the entire game state, but only the state visible to one player as revealed to it by an omniscient referee. For that purpose, we’ll represent a player’s view of the game state using JSON:

When a player program receives a JSON representation of the game state for its move, it must respond with a move as a JSON value appropriate to the game phase. The move is represented as an array containing a single value (where the value is reported an array so that the JSON form is clearly delimited):

2.3 Game Protocol🔗

An Economancy player program must read game state as JSON from standard input and write the result of a move as JSON to standard output. Your player program should loop with two steps: (1) read a JSON state for the current game state; if the state’s phase is not "end", write a JSON value for your player’s move. When your player receives an "end" state, it should exit.

A referee program that runs the game will check that the JSON move produced by a player program represents a valid turn relative to the given JSON state. When a player has no action or valid move, or when attacking and the only valid move is to stop attacking, then the playing program will not receive a board state or be expected to detect that no move is possible. Instead, the referee will skip the player. For example, if a player has multiple buys and all other players have only a single buy, then only the player with multiple buys will receive multiple board states for the "buy" phase within the relevant day.

Each player program must be runnable as a exectuable (i.e., runnable by the OS’s execve system call) with no command-line arguments. When one player wins, both player-program processes will be forcibly terminated. “Tournament mode” will include a restriction (to be determined) on how long a player program can take to complete its turn.

The relevant JSON encodings are self-delimiting—bracketed either by { and } or [ and ]and your player program should ideally not rely on any extra whitespace. However, as a convenience, the tournament referee will send player programs JSON input with no newlines except for a newline terminator at the end of each message.

Even if your player writes a newline after JSON output, beware the common mistake of forgetting to flush standard output, especially since the default flushing mode is typically different when writing to a terminal versus writing to an operating-system pipe that is connected to a referee program.

2.4 Examples🔗

Here are example traces for games involving (very bad) players that randomly select among valid moves, along with visualizations of the trace.

A page in the visualization shows a player’s move with the information that is visible to that player—which does not include investments made by other players, for example, when the player is making its own investment. The page shows both the visible game state and the player’s move, which corresponds to two JSON objects in the trace: a state and the player’s move. The final page of the visualization shows the ending game state without a player’s move (because the game is over), and the winner is highlighted in yellow.

On each page, the current shop is shown on the left, with a number below each card to show how many of that card are available. Players are shown on the right, with the player making a move highlighted by a green box. The number below a yellow circle is the number of coins held by that player; a number on the circle is the amount that the player is deciding to invest, and a blue border around a card (either in the shop or a player’s area) represents a card that a player has decided to buy or use as an attacker or defender. A blue button at the bottom of that player’s box summarize the move that the player has selected.

2.5 Handin Procedure🔗

Email the instructor an archive or a pointer to an archive (such as a link to Google Drive) that contains your source and a compiled version of your program. The compiled version should run on the CADE lab1-X.eng.utah.edu machines. Include a "README.txt" file that describes the path within your archive for the player executable. You can have multiple player executables in the archive, but choose one to enter into the tournament.