diff options
author | Florian Jung <flo@windfisch.org> | 2015-08-11 01:59:26 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-08-11 01:59:26 +0200 |
commit | 9b2078f8db3132754390db4905ac13009046f8bf (patch) | |
tree | 24dd749f004df7be65787ecfd0744743d944dc47 /main.py | |
parent | 910d17644cd8c0b2e7c6285b27aeb97253be492d (diff) | |
parent | 06ec1ca17d38ebb8b1a901b938f5f812e494e26e (diff) |
Merge branch 'master' of github.com:Windfisch/agario-frickel
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -6,14 +6,16 @@ from pygame.locals import * import sys import math import time -import gui import random +import gui +import stats from subscriber import DummySubscriber from interval_utils import * +# global vars sub = DummySubscriber() c = client.Client(sub) - +stats = stats.Stats() # find out server and token to connect try: @@ -33,7 +35,6 @@ c.player.nick="so mal sehen" # initialize GUI gui.set_client(c) - # main loop while True: c.on_message() @@ -68,7 +69,6 @@ while True: c.send_target(runaway_x, runaway_y) print ("Running away: " + str((runaway_x-c.player.center[0], runaway_y-c.player.center[1]))) gui.debug_line(c.player.center, (runaway_x,runaway_y),(255,0,0)) - gui.update() else: food = list(filter(lambda x: x.is_food or x.mass <= sorted(c.player.own_cells, key = lambda x: x.mass)[0].mass * 0.75 and not x.is_virus, c.world.cells.values())) def dist(cell): return math.sqrt((cell.pos[0]-c.player.center[0])**2 + (cell.pos[1]-c.player.center[1])**2) @@ -77,12 +77,14 @@ while True: if len(food) > 0: c.send_target(food[0].pos[0], food[0].pos[1]) gui.debug_line(c.player.center, food[0].pos,(0,0,255)) - gui.update() print("Found food at: " + str(food[0].pos)) else: rx = c.player.center[0] + random.randrange(-400, 401) ry = c.player.center[1] + random.randrange(-400, 401) c.send_target(rx, ry) gui.debug_line(c.player.center, (rx, ry),(0,255,0)) - gui.update() print("Nothing to do, heading to random destination: " + str((rx, ry))) + + gui.update() + stats.log_pos(c.player.center) + stats.log_mass(c.player.total_mass) |