diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-26 21:06:52 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-26 21:07:19 +0100 |
commit | c04d4a449bd147c632c0b6ceae04f0514803b66f (patch) | |
tree | 6c75eea8bbd8cf1be06330ddf4d592b019c6b339 /planetwars-localdev/assets | |
parent | b1e9490f55e4f360c249a107dcc5809a663dec42 (diff) | |
download | planetwars.dev-c04d4a449bd147c632c0b6ceae04f0514803b66f.tar.xz planetwars.dev-c04d4a449bd147c632c0b6ceae04f0514803b66f.zip |
rename to planetwars-cli
Diffstat (limited to 'planetwars-localdev/assets')
-rw-r--r-- | planetwars-localdev/assets/hex.json | 43 | ||||
-rw-r--r-- | planetwars-localdev/assets/pw_project.toml | 10 | ||||
-rw-r--r-- | planetwars-localdev/assets/simplebot.py | 33 |
3 files changed, 0 insertions, 86 deletions
diff --git a/planetwars-localdev/assets/hex.json b/planetwars-localdev/assets/hex.json deleted file mode 100644 index 5ef4f31..0000000 --- a/planetwars-localdev/assets/hex.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "planets": [ - { - "name": "protos", - "x": -6, - "y": 0, - "owner": 1, - "ship_count": 6 - }, - { - "name": "duteros", - "x": -3, - "y": 5, - "ship_count": 6 - }, - { - "name": "tritos", - "x": 3, - "y": 5, - "ship_count": 6 - }, - { - "name": "tetartos", - "x": 6, - "y": 0, - "owner": 2, - "ship_count": 6 - }, - { - "name": "pemptos", - "x": 3, - "y": -5, - "ship_count": 6 - }, - { - "name": "extos", - "x": -3, - "y": -5, - "ship_count": 6 - } - ] -} - diff --git a/planetwars-localdev/assets/pw_project.toml b/planetwars-localdev/assets/pw_project.toml deleted file mode 100644 index 85a4ab6..0000000 --- a/planetwars-localdev/assets/pw_project.toml +++ /dev/null @@ -1,10 +0,0 @@ -[bots] - -# define a bot called simplebot -[bots.simplebot] - -# The working directory for the bot. -path = "./bots/simplebot" - -# What command to use for running the bot -argv = ["python", "simplebot.py"]
\ No newline at end of file diff --git a/planetwars-localdev/assets/simplebot.py b/planetwars-localdev/assets/simplebot.py deleted file mode 100644 index b2a6b8f..0000000 --- a/planetwars-localdev/assets/simplebot.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys, json - -def move(command): - """ print a command record to stdout """ - moves = [] - if command is not None: - moves.append(command) - - print(json.dumps({ 'moves': moves })) - # flush the buffer, so that the gameserver can receive the json-encoded line. - sys.stdout.flush() - - -for line in sys.stdin: - state = json.loads(line) - # you are always player 1. - my_planets = [p for p in state['planets'] if p['owner'] == 1] - other_planets = [p for p in state['planets'] if p['owner'] != 1] - - if not my_planets or not other_planets: - # we don't own any planets, so we can't make any moves. - move(None) - else: - # find my planet that has the most ships - planet = max(my_planets, key=lambda p: p['ship_count']) - # find enemy planet that has the least ships - destination = min(other_planets, key=lambda p: p['ship_count']) - # attack! - move({ - 'origin': planet['name'], - 'destination': destination['name'], - 'ship_count': planet['ship_count'] - 1 - }) |