diff options
| author | Florian Jung <flo@windfisch.org> | 2015-08-31 20:07:10 +0200 | 
|---|---|---|
| committer | Florian Jung <flo@windfisch.org> | 2015-08-31 20:07:10 +0200 | 
| commit | 074b6cc570cdf897a2f9974617b53267faff6a13 (patch) | |
| tree | f9e2e21d00c997d0754c6f89911acb313182aeed | |
| parent | 1b71192eca047f8d13d6570bb623627389e5acc3 (diff) | |
virus{,2,3} logs for deviation
| -rw-r--r-- | stats.py | 28 | ||||
| -rw-r--r-- | strategy.py | 6 | ||||
| -rw-r--r-- | subscriber.py | 4 | 
3 files changed, 31 insertions, 7 deletions
@@ -108,7 +108,7 @@ class Stats:              self.data.mass_vs_visible_window = defaultdict(return_defaultdict_with_empty_list)              self.data.eject_distlogs = {"virus" : [], "split cell" : [], "ejected mass" : []} -            self.data.eject_deviations = {"virus" : [], "split cell" : [], "ejected mass" : []} +            self.data.eject_deviations = {"virus" : [], "virus2" : [], "virus3" : [], "split cell" : [], "ejected mass" : []}              self.data.observed_virus_sizes = defaultdict(return_zero)              self.data.remerging = {} @@ -173,7 +173,7 @@ class Stats:      def process_frame(self):          self.countdown -= 1 -        if (self.countdown <= 0): +        if False and (self.countdown <= 0):              quick_followup = (random.random() < 0.1)              if quick_followup: @@ -295,6 +295,30 @@ class Stats:                          self.data.eject_deviations[celltype] += [deviation] +                        if (celltype == 'virus'): +                            # FIXME so ugly +                            try: +                                shoot_angle = math.atan2(cell.shoot_vec2.y, cell.shoot_vec2.x) + +                                deviation = (fly_angle - shoot_angle) % (2*math.pi) +                                if deviation > math.pi: deviation -= 2*math.pi +                                print("  deviation2= "+str(deviation*180/math.pi)) + +                                self.data.eject_deviations['virus2'] += [deviation] +                            except AttributeError: +                                print("virus2 not available, wtf?!") + +                            try: +                                shoot_angle = math.atan2(cell.shoot_vec3.y, cell.shoot_vec3.x) + +                                deviation = (fly_angle - shoot_angle) % (2*math.pi) +                                if deviation > math.pi: deviation -= 2*math.pi +                                print("  deviation3= "+str(deviation*180/math.pi)) + +                                self.data.eject_deviations['virus3'] += [deviation] +                            except AttributeError: +                                print("virus3 not available") +                      else:                          print(celltype+" did NOT fly in a straight line, ignoring...") diff --git a/strategy.py b/strategy.py index 21a06cf..67b3da9 100644 --- a/strategy.py +++ b/strategy.py @@ -113,17 +113,17 @@ class Strategy:          my_smallest = min(self.c.player.own_cells, key=lambda cell : cell.mass)          my_largest =  max(self.c.player.own_cells, key=lambda cell : cell.mass) -        friendly_cells = list(filter(lambda c : c.name in friendly_players, self.c.world.cells.values())) +        friendly_cells = list(filter(lambda c : c.is_virus or c.name in friendly_players, self.c.world.cells.values()))          if friendly_cells:              dist_to_friend = min(map(lambda c : (self.c.player.center-c.pos).len() - max(my_largest.size, c.size), friendly_cells))          else:              dist_to_friend = float('inf') -        if dist_to_friend < 20 or my_largest.mass < 60: +        if dist_to_friend < 20 or my_largest.mass < 36:              if self.do_approach_friends: print("not approaching friends")              self.do_approach_friends = False -        elif dist_to_friend > 200 and my_largest.mass > 60 + 1*16: +        elif dist_to_friend > 200 and my_largest.mass > 36 + 10*16:              if not self.do_approach_friends: print("approaching friends")              self.do_approach_friends = True diff --git a/subscriber.py b/subscriber.py index ecec729..b89a6a9 100644 --- a/subscriber.py +++ b/subscriber.py @@ -214,9 +214,9 @@ class EnhancingSubscriber(DummySubscriber):                              raise KeyError                          else:                              cell.shoot_vec  = cell.parent.pos - last_feed.poslog[0] -                            cell.shoot_vec2 = last_feed.poslog[0] - last_feed.poslog[-1] +                            cell.shoot_vec2 = last_feed.poslog[-1] - last_feed.poslog[0]                              try: -                                pos_when_shot = last_feed.parent.poslog[len(last_feed.poslog)] +                                pos_when_shot = last_feed.parent.poslog[-len(last_feed.poslog)]                                  cell.shoot_vec3 = cell.parent.pos - pos_when_shot                              except:                                  print("MOAAAHH")  | 
