From 738d057c6da4aaca7516158db55f3553a03cf189 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Tue, 1 Sep 2015 18:14:37 +0200 Subject: better "can i safely feed" estimation --- gui.py | 4 ++-- mechanics.py | 1 + strategy.py | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gui.py b/gui.py index 001fc80..2a8460c 100644 --- a/gui.py +++ b/gui.py @@ -209,8 +209,8 @@ def draw_cell(cell): cx,cy = world_to_win_pt(cell.pos,c.player.center) try: mov_ang = cell.movement_angle - p2 = cell.pos + Vec( math.cos(mov_ang + 26*math.pi/180), math.sin(mov_ang + 26*math.pi/180) ) * (cell.size+700) - p3 = cell.pos + Vec( math.cos(mov_ang - 26*math.pi/180), math.sin(mov_ang - 26*math.pi/180) ) * (cell.size+700) + p2 = cell.pos + Vec( math.cos(mov_ang + mechanics.eject_delta*math.pi/180), math.sin(mov_ang + mechanics.eject_delta*math.pi/180) ) * (cell.size+700) + p3 = cell.pos + Vec( math.cos(mov_ang - mechanics.eject_delta*math.pi/180), math.sin(mov_ang - mechanics.eject_delta*math.pi/180) ) * (cell.size+700) cx2,cy2 = world_to_win_pt(p2,c.player.center) cx3,cy3 = world_to_win_pt(p3,c.player.center) diff --git a/mechanics.py b/mechanics.py index 1f9d5cc..5f2254b 100644 --- a/mechanics.py +++ b/mechanics.py @@ -4,3 +4,4 @@ def speed(size): def viewport_diag(sizesum): return 370 * max(sizesum,70)**0.431776 +eject_delta = 22 # how many degrees do ejects deviate from the original direction (maximum) diff --git a/strategy.py b/strategy.py index 900cf8f..bbbe07d 100644 --- a/strategy.py +++ b/strategy.py @@ -2,6 +2,7 @@ import math from interval_utils import * import random import nogui +import mechanics friendly_players=["Windfisch","windfisch","Cyanide","cyanide"] +\ ["Midna","Nayru","Farore","Din","Ezelo","Navi","Zelda","Tetra","Link","Ciela","Linebeck","Salia","Epona","Shiek"] +\ @@ -181,12 +182,12 @@ class Strategy: good_intervals += canonicalize_angle_interval( interval_occupied_by_cell(my_cell.pos, feedable) ) good_intervals = merge_intervals(good_intervals) - area = interval_area( intersection(good_intervals, canonicalize_angle_interval((my_cell.movement_angle - 10*math.pi/180, my_cell.movement_angle + 10*math.pi/180))) ) - success_rate += area / (2*10*math.pi/180) / len(list(self.c.player.own_cells)) + area = interval_area( intersection(good_intervals, canonicalize_angle_interval((my_cell.movement_angle - mechanics.eject_delta*math.pi/180, my_cell.movement_angle + mechanics.eject_delta*math.pi/180))) ) + success_rate += area / (2*mechanics.eject_delta*math.pi/180) / len(list(self.c.player.own_cells)) - self.gui.draw_bar(((100,40),(500,24)), success_rate, thresh=.98, color=(0,0,127)) - if success_rate >= 0.98: + self.gui.draw_bar(((100,40),(500,24)), success_rate, thresh=.80, color=(0,0,127)) + if success_rate >= 0.80: self.c.send_shoot() -- cgit v1.2.3