Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 2.2 KB

README.md

File metadata and controls

56 lines (43 loc) · 2.2 KB

pycatan

PyPi Read The Docs Tests

A python module for running games of The Settlers of Catan.

from pycatan import Game
from pycatan.board import RandomBoard

import random

game = Game(RandomBoard())

pOne = game.players[0]
settlement_coords = game.board.get_valid_settlement_coords(player = pOne, ensure_connected = False)
game.build_settlement(player = pOne, coords = random.choice(list(settlement_coords)), cost_resources = False, ensure_connected = False)
print(game.board)

produces:



                 3:1         2:1
                  .--'--.--'--.--'--.
                  |  5  |  2  |  6  | 2:1
               .--'--.--'--.--'--.--'--.
           2:1 | 10  |  9  |  4  |  3  |
            .--'--.--'--.--'--.--'--.--'--.
            |  8  | 11  |   R |  5  |  8  | 3:1
            '--.--'--.--s--.--'--.--'--.--'
           3:1 |  4  |  3  |  6  | 10  |
               '--.--'--.--'--.--'--.--'
                  | 11  | 12  |  9  | 3:1
                  '--.--'--.--'--.--'
                 2:1         2:1

pycatan does

  • Game state (who has what resources and what buildings on what tiles)
  • Gives out resources for a given roll
  • Prints the board (it looks better with colour)
  • Determine all the valid places to build a settlement/city/road
  • Determine all the valid trades a player can do (4:1 and 2:1 with harbor)

pycatan does not

  • Track turn order
  • Handle playing development cards (though it gives you utility functions that help a lot - see the text game tutorial on read the docs)
  • Handle trades between players

PyCatan is built to be expandable. It provides all the game logic but doesn't force you to play the exact game. It would be easy to add expansions such as a Settlement Builder development card or a board that is 3 tiles high and 30 tiles long.