summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorSpitfireX <timm.weber@me.com>2015-08-10 23:32:15 +0200
committerSpitfireX <timm.weber@me.com>2015-08-10 23:32:15 +0200
commita4219f004cea5392fa5e9356ee9f42bc877c8224 (patch)
treef0f9f9af0557e6b9fc84bb6fe92fe68f5bddd6ec /main.py
parent0b38518540aef32e5420aed456acfa7402200215 (diff)
Added basic statistics
- added a new stats module - added mass and position tracking to the current cell logic
Diffstat (limited to 'main.py')
-rw-r--r--main.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/main.py b/main.py
index aa1430c..a4c77f2 100644
--- a/main.py
+++ b/main.py
@@ -6,13 +6,15 @@ from pygame.locals import *
import sys
import math
import time
-import gui
import random
+import gui
+import stats
from subscriber import DummySubscriber
+# global vars
sub = DummySubscriber()
c = client.Client(sub)
-
+stats = stats.Stats()
# find out server and token to connect
try:
@@ -26,14 +28,13 @@ c.connect(addr,token)
c.send_facebook(
'g2gDYQFtAAAAEKO6L3c8C8/eXtbtbVJDGU5tAAAAUvOo7JuWAVSczT5Aj0eo0CvpeU8ijGzKy/gXBVCxhP5UO+ERH0jWjAo9bU1V7dU0GmwFr+SnzqWohx3qvG8Fg8RHlL17/y9ifVWpYUdweuODb9c=')
-c.player.nick="test cell pls ignore"
+#c.player.nick="test cell pls ignore"
c.send_spectate()
# initialize GUI
gui.set_client(c)
-
# main loop
while True:
c.on_message()
@@ -49,7 +50,6 @@ while True:
if dist < cell.size*4 and cell.mass > 1.25 * my_smallest:
runaway_x += (c.player.center[0] - cell.pos[0]) / cell.mass / dist
runaway_y += (c.player.center[1] - cell.pos[1]) / cell.mass / dist
-
runaway_r = math.sqrt(runaway_x**2 + runaway_y**2)
if (runaway_r > 0):
@@ -75,4 +75,7 @@ while True:
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))) \ No newline at end of file
+ print("Nothing to do, heading to random destination: " + str((rx, ry)))
+
+ stats.log_pos(c.player.center)
+ stats.log_mass(c.player.total_mass) \ No newline at end of file