Skip to content

Commit 6d0fb01

Browse files
committed
Merge branch 'master' of github.com:project-neon/NeonFC
2 parents 2f48ff4 + 31f2740 commit 6d0fb01

File tree

2 files changed

+59
-13
lines changed

2 files changed

+59
-13
lines changed

strategy/offensive_strategy/Attacker.py

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def point_in_rect(point,rect):
1717

1818
class Attacker(Strategy):
1919
def __init__(self, match, plot_field=False):
20-
super().__init__(match)
20+
super().__init__(match, controller_kwargs={'l': 0.0765})
2121

2222
"""
2323
Ambiente para rascunhar novas estrategias com
@@ -116,7 +116,7 @@ def s(m):
116116

117117
weight = 1/2 + 1/2 * min((dist/radius), 1)
118118

119-
return weight * 0.75 if m.ball.y < 0.65 else 0
119+
return weight * 0.85 if m.ball.y < 0.65 else 0
120120

121121
return s
122122

@@ -133,7 +133,7 @@ def s(m):
133133

134134
weight = 1/2 + 1/2 * min((dist/radius), 1)
135135

136-
return weight * 0.75 if m.ball.y >= 0.65 else 0
136+
return weight * 0.85 if m.ball.y >= 0.65 else 0
137137

138138
return s
139139

@@ -310,13 +310,13 @@ def ttr(m):
310310
pos_x = (
311311
m.ball.x -
312312
math.cos(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))) * 0.025 +
313-
math.cos(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))+ math.pi/2)*0.2 + m.ball.vx/10
313+
math.cos(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))+ math.pi/2)*0.12 + m.ball.vx/10
314314
)
315315

316316
pos_y = (
317317
m.ball.y -
318318
math.sin(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))) * 0.025 +
319-
math.sin(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))+ math.pi/2)*0.2 + m.ball.vy/10
319+
math.sin(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))+ math.pi/2)*0.12 + m.ball.vy/10
320320
)
321321

322322
return (pos_x, pos_y)
@@ -347,6 +347,36 @@ def ttr(m):
347347
)
348348
)
349349

350+
# self.seek.add_field(
351+
# algorithims.fields.PointField(
352+
# self.match,
353+
# target= lambda m: (m.ball.x, m.ball.y - 0.05),
354+
# radius=0.15,
355+
# radius_max=0.15,
356+
# decay = lambda x: x,
357+
# field_limits = [0.75* 2 , 0.65*2],
358+
# multiplier = 1
359+
# )
360+
# )
361+
362+
self.seek.add_field(
363+
algorithims.fields.LineField(
364+
self.match,
365+
target= lambda m: (
366+
m.ball.x - math.cos(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))) * 0.025,
367+
m.ball.y - math.sin(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))) * 0.025
368+
),
369+
theta=lambda m: ( -math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))),
370+
line_size = 1,
371+
line_size_single_side = True,
372+
line_dist = 0.15,
373+
line_dist_max = 0.15,
374+
decay = lambda x: x**2,
375+
field_limits = [0.75* 2 , 0.65*2],
376+
multiplier = 1 # 75 cm/s
377+
)
378+
)
379+
350380
self.seek.add_field(
351381
algorithims.fields.PointField(
352382
self.match,
@@ -395,6 +425,23 @@ def ttr(m):
395425
multiplier = lambda m: max(0.80, math.sqrt(m.ball.vx**2 + m.ball.vy**2) + 0.1) # 50 cm/s
396426
)
397427
)
428+
self.carry.add_field(
429+
algorithims.fields.LineField(
430+
self.match,
431+
target= lambda m: (
432+
m.ball.x - math.cos(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))) * 0.025,
433+
m.ball.y - math.sin(math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))) * 0.025
434+
),
435+
theta=lambda m: ( -math.atan2((0.65-m.ball.y), (0.75*2 - m.ball.x))),
436+
line_size = 1,
437+
line_size_single_side = True,
438+
line_dist = 0.15,
439+
line_dist_max = 0.15,
440+
decay = lambda x: x**2,
441+
field_limits = [0.75* 2 , 0.65*2],
442+
multiplier = 1 # 75 cm/s
443+
)
444+
)
398445

399446
self.maintain.add_field(self.base_rules)
400447

@@ -436,7 +483,7 @@ def ttr(m):
436483
radius = 0.04,
437484
radius_max = 2,
438485
clockwise = lambda m: (m.ball.y < 0.65),
439-
decay=lambda x: 1,
486+
decay=lambda x: 1 if x > 0.5 else 0.5,
440487
field_limits = [0.75* 2 , 0.65*2],
441488
multiplier = 1
442489
)
@@ -460,10 +507,10 @@ def decide(self):
460507
of_goal_area = [1.30, 0.30, 0.30, 0.70]
461508
goal_area = [-0.05, 0.30, 0.20, 0.70]
462509

463-
angle_ball_to_goal = -math.atan2((self.match.ball.y - 0.65), (self.match.ball.x - 0.75*2))
510+
min_angle_ball_to_goal = -math.atan2((self.match.ball.y - 0.55), (self.match.ball.x - 0.75*2))
464511
angle_robot_to_ball = -math.atan2((self.robot.y - self.match.ball.y), (self.robot.x - self.match.ball.x ))
465512

466-
angle_to_goal = abs(angle_ball_to_goal - angle_robot_to_ball)
513+
min_angle_to_goal = abs(min_angle_ball_to_goal - angle_robot_to_ball)
467514

468515
dist_to_ball = math.sqrt(
469516
(self.robot.x - self.match.ball.x)**2 + (self.robot.y - self.match.ball.y)**2
@@ -472,7 +519,7 @@ def decide(self):
472519
dist_to_ball_goal = math.sqrt(
473520
(0 - self.match.ball.x)**2 + (0.65 - self.match.ball.y)**2
474521
)
475-
522+
476523
if point_in_rect(ball, of_goal_area):
477524
behaviour = self.carry
478525
elif point_in_rect(ball ,goal_area):
@@ -484,11 +531,11 @@ def decide(self):
484531
or
485532
(ball[1] <= 0.2 and self.robot.y <= 0.25)) and self.robot.x < ball[0]:
486533
behaviour = self.carry
487-
elif (angle_to_goal <= 0.75) and (dist_to_ball <= 0.20):
534+
elif (min_angle_to_goal <= 0.60) and (dist_to_ball <= 0.25):
488535
behaviour = self.carry
489536
else:
490537
behaviour = self.seek
491-
538+
492539
print(self.robot.get_name(), "::", behaviour.name)
493540

494541
if self.exporter:

strategy/offensive_strategy/MidFielder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def point_in_rect(point,rect):
1818

1919
class MidFielder(Strategy):
2020
def __init__(self, match, plot_field=False):
21-
super().__init__(
22-
match)
21+
super().__init__(match, controller_kwargs={'l': 0.0765})
2322

2423
"""
2524
Essa estrategia descreve a um goleiro base, simples, que

0 commit comments

Comments
 (0)