Table of Contents

Assignment 2: EFG

You are a Thief in a grid-based cave. Your goal is to escape with as much gold as possible. There is a Guard who wants to stop You.

Rules of the Game

The game is played on a grid-based map as follows:

Encounters

During an Encounter, the Guard has two options:

  1. Fight to try and stop the Thief,
  2. Remain hidden and sneak to a different hiding place.

If the Thief loses a fight, the game ends immediately; otherwise the Thief is free to continue with all the collected gold. The probability that the Guard wins a fight starts at 50 % and increases with each Encounter according to the formula \( 1 - \frac{0.5}{n} \) where \( n \) is the number of Encounters. The Thief knows when a fight happens, but is unaware of the Guard's sneaky hiding place changes.

Scoring

The score starts at zero. The Thief gets two points for a successful escape, and one additional point for each gold stolen. No points will be awarded in case the Thief loses a fight or gets stuck on a square with no legal moves; that means:

Extensive Form Games

This game is much more complex than the previous and developing best-response oracles is not so easy. Instead, Your task is to accurately describe the rules of the game as a two-player zero-sum extensive form game, such that it can be solved by a generic algorithm You will implement in the next homework assignment.

Requirements

Your program must accept the cave definition from standard input, and must write the resulting game tree to standard output, i.e. the expected usage is

python main.py < cave.txt > game.json

You must not open, read or write to any files, and your standard output must contain only the game representation without any debugging information.

Examples, Tests, Templates and Libraries

You can use our template and example caves (and their values ) to simplify your implementation.

The template uses our EFG library, pygambit and pydot to simplify the creation, and visualization of your extensive form games. You can download it directly from Github

pip install "cgt_bandits[dot,gambit] @ git+https://github.com/votroto/cgt_bandits.git"
Follow the installation instructions, then see the examples directory.

Use pygambit to compute equilibria and values of your games, but do not expect it to work for larger games. Implementing a better algorithm will be the subject of a subsequent homework assignment.

Input File Format

Maps have the following format:

######
#SE-D#
#-##G#
#--E-#
######

(- empty square, S start, D destination, E possible hiding place, G gold, # wall)

Notes