commit
5404f4256a
7 changed files with 12 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
import sys, json, random
|
import sys, json, random
|
||||||
|
|
||||||
def move(command):
|
def move(moves):
|
||||||
record = { 'moves': [command] }
|
record = {'moves': moves}
|
||||||
print(json.dumps(record))
|
print(json.dumps(record))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ for line in sys.stdin:
|
||||||
other_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:
|
if not my_planets or not other_planets:
|
||||||
move(None)
|
move([])
|
||||||
else:
|
else:
|
||||||
planet = max(my_planets, key=lambda p: p['ship_count'])
|
planet = max(my_planets, key=lambda p: p['ship_count'])
|
||||||
dest = min(other_planets, key=lambda p: p['ship_count'])
|
dest = min(other_planets, key=lambda p: p['ship_count'])
|
||||||
move({
|
move([{
|
||||||
'origin': planet['name'],
|
'origin': planet['name'],
|
||||||
'destination': dest['name'],
|
'destination': dest['name'],
|
||||||
'ship_count': planet['ship_count'] - 1
|
'ship_count': planet['ship_count'] - 1
|
||||||
})
|
}])
|
||||||
|
|
|
@ -16,7 +16,7 @@ Information
|
||||||
<li>planets on 2d plane</li>
|
<li>planets on 2d plane</li>
|
||||||
<li>players can occupy planets</li>
|
<li>players can occupy planets</li>
|
||||||
<li>each turn, an occupied planet constructs a new ship for its owner</li>
|
<li>each turn, an occupied planet constructs a new ship for its owner</li>
|
||||||
<li>spaceship travel time is proportional to the euclidean distance (floor(sqrt(dx * dx - dy * dy)))</li>
|
<li>spaceship travel time is proportional to the euclidean distance (ceil(sqrt(dx * dx + dy * dy)))</li>
|
||||||
<li>combat happens only on planets</li>
|
<li>combat happens only on planets</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2>Turn Order</h2>
|
<h2>Turn Order</h2>
|
||||||
|
|
|
@ -18,9 +18,9 @@ How to connect
|
||||||
<code>
|
<code>
|
||||||
$ wget mozaic.zeus.gent/bot/runner.py
|
$ wget mozaic.zeus.gent/bot/runner.py
|
||||||
$ wget mozaic.zeus.gent/bot/simple.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> \
|
-n <Your name> -i <Id from the lobby> \
|
||||||
python simple.py
|
python3 simple.py
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<p>Build a bot! All information about the planetwars game, <a target="_blank" href="https://docs.google.com/presentation/d/1YXr7IsmEiBpRwgAoFPqsjFoKoyXOv9LAhPbsambGX70/edit?usp=sharing">please visit</a> for input output format etc. You can find an example bot <a href="bot/simple.py">here</a>.</p>
|
<p>Build a bot! All information about the planetwars game, <a target="_blank" href="https://docs.google.com/presentation/d/1YXr7IsmEiBpRwgAoFPqsjFoKoyXOv9LAhPbsambGX70/edit?usp=sharing">please visit</a> for input output format etc. You can find an example bot <a href="bot/simple.py">here</a>.</p>
|
||||||
<p>Optionally, you can create your own custom with the mapbuilder</p>
|
<p>Optionally, you can create your own custom with the mapbuilder</p>
|
||||||
<p>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.</p>
|
<p>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.</p>
|
||||||
<p>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 <a href="bot/runner.py">the botrunner</a> to run your bot, with the command <span style="font-style: italic;">python runner.py --host mozaic.zeus.gent -n {your name} -i {your key} {The command to start you bot}</span>.
|
<p>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 <a href="bot/runner.py">the botrunner</a> to run your bot, with the command <span style="font-style: italic;">python3 runner.py --host mozaic.zeus.gent -n {your name} -i {your key} {The command to start you bot}</span>.
|
||||||
<p>Invite friends!</p>
|
<p>Invite friends!</p>
|
||||||
<p>Bash your friends because you have the superior bot, according to the visualizer</p>
|
<p>Bash your friends because you have the superior bot, according to the visualizer</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="input_container number">
|
<div class="input_container number">
|
||||||
<label for="turns">Max turns:</label>
|
<label for="turns">Max turns:</label>
|
||||||
<input id="turns" type="number" value=200></input>
|
<input id="turns" type="number" value=1000></input>
|
||||||
</div>
|
</div>
|
||||||
<div class="input_container number">
|
<div class="input_container number">
|
||||||
<label for="nop">Number of players:</label>
|
<label for="nop">Number of players:</label>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Using token $1"
|
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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import socket, sys, subprocess, argparse, io, threading, json
|
import socket, sys, subprocess, argparse, io, threading, json
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue