From cd3e42beaa35795873d58d520c0fe80733d1b45b Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Mon, 16 Sep 2019 21:18:35 +0200 Subject: [PATCH] add types --- client/bot7.txt | 23 +++++++++++++++ client/log.log | 0 client/run.sh | 4 +++ client/simple.py | 29 +++++++++++++++++++ client/src/types.rs | 69 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 client/bot7.txt create mode 100644 client/log.log create mode 100755 client/run.sh create mode 100644 client/simple.py create mode 100644 client/src/types.rs diff --git a/client/bot7.txt b/client/bot7.txt new file mode 100644 index 0000000..ca4bcd4 --- /dev/null +++ b/client/bot7.txt @@ -0,0 +1,23 @@ +start{"planets":[{"ship_count":7,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":7,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":10}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":9},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":11},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":11}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":8},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":10},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":10},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":11},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":11}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":7},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":9},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":9},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":10},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":10},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":11},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":11}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":6},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":8},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":8},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":9},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":9},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":10},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":10},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":11},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":11}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":11},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":5},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":7},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":7},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":8},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":8},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":9},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":9},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":10},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":10},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":11}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":10},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":4},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":6},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":6},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":7},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":7},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":8},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":8},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":9},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":9},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":10},{"id":12,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":10}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":9},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":3},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":5},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":5},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":6},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":6},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":7},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":7},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":8},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":8},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":9},{"id":12,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":9},{"id":14,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":10}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":8},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":2},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":4},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":4},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":5},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":5},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":6},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":6},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":7},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":7},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":8},{"id":12,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":8},{"id":14,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":9},{"id":16,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":10}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":7},{"id":1,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":1},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":3},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":3},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":4},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":4},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":5},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":5},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":6},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":6},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":7},{"id":12,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":7},{"id":14,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":8},{"id":16,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":9},{"id":18,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":10}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":6},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":10},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":2},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":2},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":3},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":3},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":4},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":4},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":5},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":5},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":6},{"id":12,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":6},{"id":14,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":7},{"id":16,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":8},{"id":18,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":9},{"id":20,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":3,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":5},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":9},{"id":2,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":1},{"id":3,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":1},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":2},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":2},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":3},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":3},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":4},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":4},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":5},{"id":23,"ship_count":5,"origin":"duteros","destination":"protos","owner":1,"turns_remaining":5},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":5},{"id":14,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":6},{"id":16,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":7},{"id":18,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":8},{"id":20,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":11}]} +{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":4},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":8},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":11},{"id":24,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":5},{"id":4,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":1},{"id":5,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":1},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":2},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":2},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":3},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":3},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":4},{"id":23,"ship_count":5,"origin":"duteros","destination":"protos","owner":1,"turns_remaining":4},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":4},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":10},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":5},{"id":16,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":6},{"id":18,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":7},{"id":20,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3}]} +{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":3},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":7},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":10},{"id":24,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":4},{"id":20,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":6},{"id":6,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":1},{"id":7,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":1},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":2},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":2},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":3},{"id":23,"ship_count":5,"origin":"duteros","destination":"protos","owner":1,"turns_remaining":3},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":3},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":9},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":4},{"id":18,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":5}]} +{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":2},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":6},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":9},{"id":24,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":3},{"id":20,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":5},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":4},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":3},{"id":8,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":1},{"id":9,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":1},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":2},{"id":23,"ship_count":5,"origin":"duteros","destination":"protos","owner":1,"turns_remaining":2},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":2},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":8}]} +{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":11,"ship_count":1,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":1},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":5},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":8},{"id":24,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":2},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":7},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":4},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":3},{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":2},{"id":13,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":1},{"id":23,"ship_count":5,"origin":"duteros","destination":"protos","owner":1,"turns_remaining":1},{"id":10,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":1}]} +{"planets":[{"ship_count":4,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":3,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":15,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":1},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":4},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":7},{"id":24,"ship_count":1,"origin":"protos","destination":"duteros","owner":2,"turns_remaining":1},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":6},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":3},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":2}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":4,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":10},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":3},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":6},{"id":17,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":1},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":5},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":2}]} +{"planets":[{"ship_count":3,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":3,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":3,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":9},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":2},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":5},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":1,"turns_remaining":5},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":4},{"id":19,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":1}]} +{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":5,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":4,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":8},{"id":21,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":1,"turns_remaining":1},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":4},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":1,"turns_remaining":4},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":3},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":10}]} +{"planets":[{"ship_count":3,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":3,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":5,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":7},{"id":29,"ship_count":4,"origin":"duteros","destination":"tritos","owner":1,"turns_remaining":5},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":3},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":1,"turns_remaining":3},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":2},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":9}]} +{"planets":[{"ship_count":4,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":4,"x":-3.0,"y":5.0,"owner":1,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":1,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":6},{"id":29,"ship_count":4,"origin":"duteros","destination":"tritos","owner":1,"turns_remaining":4},{"id":25,"ship_count":2,"origin":"tetartos","destination":"protos","owner":1,"turns_remaining":2},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":1,"turns_remaining":2},{"id":22,"ship_count":1,"origin":"protos","destination":"tetartos","owner":2,"turns_remaining":1},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":1,"turns_remaining":8},{"id":30,"ship_count":4,"origin":"tetartos","destination":"tritos","owner":1,"turns_remaining":5}]} diff --git a/client/log.log b/client/log.log new file mode 100644 index 0000000..e69de29 diff --git a/client/run.sh b/client/run.sh new file mode 100755 index 0000000..6436fed --- /dev/null +++ b/client/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rm bot*.txt +cargo run $1 python simple.py diff --git a/client/simple.py b/client/simple.py new file mode 100644 index 0000000..02d6fc4 --- /dev/null +++ b/client/simple.py @@ -0,0 +1,29 @@ +import sys, json, random + +def move(command): + record = { 'moves': [command] } + print(json.dumps(record)) + sys.stdout.flush() + +f_name = f"bot{random.randint(0, 10)}.txt" +f = open(f_name,"w+") +f.write("start") +f.flush() +for line in sys.stdin: + f.write(line) + f.flush() + state = json.loads(line) + # find planet with most ships + 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: + move(None) + else: + planet = max(my_planets, key=lambda p: p['ship_count']) + dest = min(other_planets, key=lambda p: p['ship_count']) + move({ + 'origin': planet['name'], + 'destination': dest['name'], + 'ship_count': planet['ship_count'] - 1 + }) diff --git a/client/src/types.rs b/client/src/types.rs new file mode 100644 index 0000000..fd580b3 --- /dev/null +++ b/client/src/types.rs @@ -0,0 +1,69 @@ +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +#[serde(tag = "type", content = "content")] +pub enum ServerMessage { + /// Game state in current turn + GameState(State), + /// The action that was performed + PlayerAction(PlayerAction), + /// The game is over, and this is the concluding state. + FinalState(State), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +#[serde(tag = "type", content = "value")] +pub enum PlayerAction { + Timeout, + ParseError(String), + Commands(Vec), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PlayerCommand { + pub command: Command, + #[serde(skip_serializing_if = "Option::is_none")] + pub error: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum CommandError { + NotEnoughShips, + OriginNotOwned, + ZeroShipMove, + OriginDoesNotExist, + DestinationDoesNotExist, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Command { + pub origin: String, + pub destination: String, + pub ship_count: u64, +} + + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct State { + pub planets: Vec, + pub expeditions: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Expedition { + pub id: u64, + pub ship_count: u64, + pub origin: String, + pub destination: String, + pub owner: usize, + pub turns_remaining: u64, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Planet { + pub ship_count: u64, + pub x: f64, + pub y: f64, + pub owner: Option, + pub name: String, +}