{"id":19520903,"url":"https://github.com/sebastianbach/game","last_synced_at":"2025-07-21T16:02:20.724Z","repository":{"id":50407332,"uuid":"518991678","full_name":"SebastianBach/game","owner":"SebastianBach","description":"Python based simulation of a simple game with various strategies.","archived":false,"fork":false,"pushed_at":"2022-08-01T21:07:59.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T13:51:56.062Z","etag":null,"topics":["pyside6","python","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SebastianBach.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-28T20:53:26.000Z","updated_at":"2023-02-06T19:52:04.000Z","dependencies_parsed_at":"2022-09-13T00:01:54.864Z","dependency_job_id":null,"html_url":"https://github.com/SebastianBach/game","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianBach%2Fgame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianBach%2Fgame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianBach%2Fgame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianBach%2Fgame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SebastianBach","download_url":"https://codeload.github.com/SebastianBach/game/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240769154,"owners_count":19854587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pyside6","python","simulation"],"created_at":"2024-11-11T00:28:15.579Z","updated_at":"2025-02-26T00:26:04.474Z","avatar_url":"https://github.com/SebastianBach.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Simple Game\n\nThe game board consists of a series of squares. The players place their game piece on the field 0; the winner is the first to reach the field 30.\n\nThe players take turns rolling the dice (D6) and have a choice. Either they move their piece towards the goal by the number of points rolled, **or** they move an opposing piece backwards by the same number of points. What would you choose?\n\n# Strategies\n\n## Run\n\n```\"run\"```: I move forward no matter what.\n\n## Chaos\n\n```\"chaos\"```: In two out of three cases, I move forward. In one out of three cases, I move a random opponent's piece back.\n\n## Big Steps\n\n```\"big\"```: If I roll a 4 or more, I go forward. If I roll a 3 or less, I move the leading player's piece back.\n\n## Second Place\n\n```\"second\"```: Everyone tries to throw back the player who is in the lead. That's why I like to stay in 2nd place at first. Only towards the end do I sprint to the finish.\n\n## Waiting\n\n```\"waiting\"```: Everyone tries to throw back the player who is in the lead. That's why I stop when I reach square 24 or 25. I throw back anyone who overtakes me and wait for me to roll a 5 or 6 to win.\n\n## Drag Down\n\n```\"drag\"```: I move forward. But when I see that a player is about to win, I pull him back down.\n\n\n# Setup\n\n- Install Python\n- Install dependencies via ```pip install -r requirements.txt```\n\n# Run\n\nRun the simulation via:\n\n```\npython simulation.py MODE SEED PLAYER_1 PLAYER_2 PLAYER_3 ...\n```\n\nRun the simulation with UI via:\n\n```\npython simulation_ui.py MODE SEED PLAYER_1 PLAYER_2 PLAYER_3 ...\n```\n\n- *MODE*: The game mode. *show* will run the game with a delay, *run* will run the game without delay.\n- *SEED*: random number generator seed.\n- *PLAYER_1* : For each player, set the used strategy.\n\nExample:\n\n```\npython simulation.py show 123 run second waiting\npython simulation_ui.py show 123 run second waiting\n``` \n\n# Test\n\nExecute test with:\n\n```\npython tests.py\n```\n\n# Extend\n\nTo add a new playing strategy, extend ```strategies.py```:\n\n```\ndef strategy_custom(move: my_move, id: int, cnt: int, roll: int, state: list):\n\n    move.move_me()\n    return move\n\n\nstrategies[\"custom\"] = strategy_custom\n```\n\nNow players with the ```custom``` strategy can be added:\n\n```\npython game.py show 123 custom run waiting\n```\n\nYour custom strategy function must return the modified ```move``` object. Either choose ```move_me()``` to move the player or ```move_other()``` to move back an opponent.\n\nThe arguments given to your function are:\n\n- ```move```: ```my_move```object to edit and return.\n- ```id```: ID of the current player. Is the index in the ```state``` list.\n- ```cnt```: Number of players. Same as ```len(state)```.\n- ```roll```: The number that was rolled.\n- ```state```: List storing the current position of each player.\n\nThe current position of the player is ```state[id]```.\n\nAs soon as the points rolled are enough to win the game, the game engine registers this case. The strategy does not have to handle this case explicitly.\n\nDon`t forget to add a unit test to ```tests.py```.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianbach%2Fgame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastianbach%2Fgame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianbach%2Fgame/lists"}