A student was in my office looking for a little AI project today. After a bit of discussion, she’s going to try to write some agents for Cartagena, one of my favorite little games for 2-4 players. If you haven’t run into it, here are the rules we use:


  1. A deck of playing cards.
  2. Four tokens per player, such as coins or poker chips.


  1. Divide a deck of cards in two: Jacks, Queens, Kings, and Aces go in one pile, 2-10 in the other.
  2. Shuffle the first pile and lay the cards out in a straight line to create a racetrack with 16 spaces.
  3. Shuffle the second pile. Deal each player three cards, and put the rest face-down as the draw pile.
  4. Place every player's tokens at one end of the racetrack.

Basic Play

  1. The first player to get all of their tokens off the end of the racetrack is the winner.
  2. Players move in turn. In each turn, a can either spend a card to move a token forward, or move a token backward to pick up one or two new cards.
  3. To move a token forward, play a card, and move a token to the next empty card on the racetrack that is of the same suit. For example, if the card played is a Heart, move one token to the next empty Heart card.
  4. To pick up more cards, move one token backward to the closest occupied card. If that card already has one token on it, pick up one card. If it has two tokens, pick up two cards. If three or more tokens are already on it, you cannot move back to it (i.e., you can never put more than three tokens on a card). You cannot back up over a card that already has three tokens on it.
  5. When the draw pile is exhausted, shuffle the discard pile to create a new one.


At the start of Green’s turn, the board looks like this:

green purplepurple red
greenred purple red greenpurplered green
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

She holds ♦ and ♣. Her legal actions are:

  1. Play ♦ and move the off-board token to [12] (the first empty ♦ space).
  2. Play ♦ and move her token from [3] to [12].
  3. Play ♦ and move [9] to [12].
  4. Play ♦ and move [11] to [12].
  5. Play ♣ and move the off-board token to [2].
  6. Play ♣ and move that token from [3] off the board, since there are no unoccupied ♣ spaces between it and the end. Another way to think about this is that the end of the racetrack effectively has all suits, i.e., can always be moved to.
  7. Play ♣ and move [9] off the board.
  8. Play ♣ and move [11] off the board.
  9. Move [9] to [5] and pick up a card.

Note that she cannot move [11] to [9], since there are already three tokens on [9]. She also cannot move [11] back to [5] or another earlier space, since players cannot back up past spaces that have three tokens.

Advanced Play

The board game Cartagena, designed by Leo Colovini, is more complicated in two ways:

  1. Each play has six tokens, and the racetrack has 36 spaces (six spaces of six different types). The movement deck also obviously has six types of cards.
  2. Each player gets to perform up to three consecutive actions in each turn. For example, a player could discard a card to move one token forward, move that same token back to pick up a card, then play the card just picked up to move forward again. This means that a player's available actions may change during a single turn.