From c0f31e61df257a1a796b21e2ca83d12b38730b90 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Tue, 7 Apr 2020 23:57:41 +0200 Subject: [PATCH 1/5] Make python3 explicit for non-Arch based systems (as if those even exist) --- backend/templates/help/help_6.html.tera | 4 ++-- backend/templates/index2.html.tera | 2 +- client/run.sh | 2 +- client/runner.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/templates/help/help_6.html.tera b/backend/templates/help/help_6.html.tera index f7040c2..f33186e 100644 --- a/backend/templates/help/help_6.html.tera +++ b/backend/templates/help/help_6.html.tera @@ -18,9 +18,9 @@ How to connect $ wget mozaic.zeus.gent/bot/runner.py $ wget mozaic.zeus.gent/bot/simple.py -$ python runner.py -p 9142 --host mozaic.zeus.gent \ +$ python3 runner.py -p 9142 --host mozaic.zeus.gent \ -n <Your name> -i <Id from the lobby> \ - python simple.py + python3 simple.py diff --git a/backend/templates/index2.html.tera b/backend/templates/index2.html.tera index 55b771a..86339a1 100644 --- a/backend/templates/index2.html.tera +++ b/backend/templates/index2.html.tera @@ -54,7 +54,7 @@

Build a bot! All information about the planetwars game, please visit for input output format etc. You can find an example bot here.

Optionally, you can create your own custom with the mapbuilder

Start a game instance in the lobby, don't forget to name it, watching the visualization afterwars is the only way to know who won atm.

-

Start up your bot and connect to the game instance. In the lobby you will see keys corresponding to players in the game. You can use the botrunner to run your bot, with the command python runner.py --host mozaic.zeus.gent -n {your name} -i {your key} {The command to start you bot}. +

Start up your bot and connect to the game instance. In the lobby you will see keys corresponding to players in the game. You can use the botrunner to run your bot, with the command python3 runner.py --host mozaic.zeus.gent -n {your name} -i {your key} {The command to start you bot}.

Invite friends!

Bash your friends because you have the superior bot, according to the visualizer

diff --git a/client/run.sh b/client/run.sh index 8b4dad1..ed0ef4c 100755 --- a/client/run.sh +++ b/client/run.sh @@ -1,4 +1,4 @@ #!/bin/bash echo "Using token $1" -python runner.py -n simple.py --host ${HOST:-localhost} -p 9142 -i $1 python simple.py +python3 runner.py -n simple.py --host ${HOST:-localhost} -p 9142 -i $1 python3 simple.py diff --git a/client/runner.py b/client/runner.py index ff4e0e1..3f2b8f9 100755 --- a/client/runner.py +++ b/client/runner.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python3 import socket, sys, subprocess, argparse, io, threading, json From 440fc4fdecc5e3480f05b947e0f9d99c774f9636 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Wed, 8 Apr 2020 01:48:17 +0200 Subject: [PATCH 2/5] Fix simple bot --- backend/static/bot/simple.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/static/bot/simple.py b/backend/static/bot/simple.py index 4c0e199..bea8c85 100644 --- a/backend/static/bot/simple.py +++ b/backend/static/bot/simple.py @@ -1,7 +1,7 @@ import sys, json, random -def move(command): - record = { 'moves': [command] } +def move(moves): + record = {'moves': moves} print(json.dumps(record)) sys.stdout.flush() @@ -13,12 +13,12 @@ for line in sys.stdin: other_planets = [p for p in state['planets'] if p['owner'] != 1] if not my_planets or not other_planets: - move(None) + move([]) else: planet = max(my_planets, key=lambda p: p['ship_count']) dest = min(other_planets, key=lambda p: p['ship_count']) - move({ + move([{ 'origin': planet['name'], 'destination': dest['name'], 'ship_count': planet['ship_count'] - 1 - }) + }]) From 690c4b5e5705d840ce6df7fae7f9a6bc0d483c08 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Wed, 8 Apr 2020 01:57:13 +0200 Subject: [PATCH 3/5] Fix euclidean distance formula --- backend/templates/help/help_1.html.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/templates/help/help_1.html.tera b/backend/templates/help/help_1.html.tera index 79dd979..38aa8d6 100644 --- a/backend/templates/help/help_1.html.tera +++ b/backend/templates/help/help_1.html.tera @@ -16,7 +16,7 @@ Information
  • planets on 2d plane
  • players can occupy planets
  • each turn, an occupied planet constructs a new ship for its owner
  • -
  • spaceship travel time is proportional to the euclidean distance (floor(sqrt(dx * dx - dy * dy)))
  • +
  • spaceship travel time is proportional to the euclidean distance (floor(sqrt(dx * dx + dy * dy)))
  • combat happens only on planets
  • Turn Order

    From 25d218be0fcb3020b9b642c606e4fa171cf200ab Mon Sep 17 00:00:00 2001 From: redfast00 Date: Wed, 8 Apr 2020 13:22:28 +0200 Subject: [PATCH 4/5] Default to 1000 turns, this is better for larger maps --- backend/templates/lobby.html.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/templates/lobby.html.tera b/backend/templates/lobby.html.tera index ffab095..5e68a8e 100644 --- a/backend/templates/lobby.html.tera +++ b/backend/templates/lobby.html.tera @@ -22,7 +22,7 @@
    - +
    From 34e7b48664b5b724c80bd870b16797ad618d7ad6 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Wed, 8 Apr 2020 13:43:53 +0200 Subject: [PATCH 5/5] Correct distance formula again ;) --- backend/templates/help/help_1.html.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/templates/help/help_1.html.tera b/backend/templates/help/help_1.html.tera index 38aa8d6..34d2e05 100644 --- a/backend/templates/help/help_1.html.tera +++ b/backend/templates/help/help_1.html.tera @@ -16,7 +16,7 @@ Information
  • planets on 2d plane
  • players can occupy planets
  • each turn, an occupied planet constructs a new ship for its owner
  • -
  • spaceship travel time is proportional to the euclidean distance (floor(sqrt(dx * dx + dy * dy)))
  • +
  • spaceship travel time is proportional to the euclidean distance (ceil(sqrt(dx * dx + dy * dy)))
  • combat happens only on planets
  • Turn Order