From 8cab4c775ba48d02bf2cf7b3dd61b93c25eafcff Mon Sep 17 00:00:00 2001 From: Vincent Bons Date: Fri, 22 May 2020 09:18:54 +0200 Subject: [PATCH] Update README.md --- README.md | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c18b15f..a1453d0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # carcassonne Carcassonne implementation in python @@ -12,27 +13,39 @@ Carcassonne implementation in python * Abbots * Farmers +## Installation + +* Clone the project +* Go to the project folder +* Run: + + pip install . + +You can now use the API in other projects. + ## API Code example for a game with two players import random - from typing import Optional - - from main.carcassonne_game import CarcassonneGame - from main.objects.actions.action import Action - from main.tile_sets.tile_sets import TileSet - - game = CarcassonneGame( - players=2, - tile_sets=[TileSet.BASE, TileSet.THE_RIVER, TileSet.INNS_AND_CATHEDRALS], - supplementary_rules=[SupplementaryRule.ABBOTS, SupplementaryRule.FARMERS] - ) - - while not game.is_finished(): - player: int = game.state.current_player - valid_actions: [Action] = game.get_possible_actions() - action: Optional[Action] = random.choice(valid_actions) - if action is not None: - game.step(player, action) - game.render() + from typing import Optional + + from wingedsheep.carcassonne.carcassonne_game import CarcassonneGame + from wingedsheep.carcassonne.carcassonne_game_state import CarcassonneGameState + from wingedsheep.carcassonne.objects.actions.action import Action + from wingedsheep.carcassonne.tile_sets.supplementary_rules import SupplementaryRule + from wingedsheep.carcassonne.tile_sets.tile_sets import TileSet + + game = CarcassonneGame( + players=2, + tile_sets=[TileSet.BASE, TileSet.THE_RIVER, TileSet.INNS_AND_CATHEDRALS], + supplementary_rules=[SupplementaryRule.ABBOTS, SupplementaryRule.FARMERS] + ) + + while not game.is_finished(): + player: int = game.get_current_player() + valid_actions: [Action] = game.get_possible_actions() + action: Optional[Action] = random.choice(valid_actions) + if action is not None: + game.step(player, action) + game.render()