@@ -17,7 +17,7 @@ def point_in_rect(point,rect):
17
17
18
18
class Attacker (Strategy ):
19
19
def __init__ (self , match , plot_field = False ):
20
- super ().__init__ (match )
20
+ super ().__init__ (match , controller_kwargs = { 'l' : 0.0765 } )
21
21
22
22
"""
23
23
Ambiente para rascunhar novas estrategias com
@@ -116,7 +116,7 @@ def s(m):
116
116
117
117
weight = 1 / 2 + 1 / 2 * min ((dist / radius ), 1 )
118
118
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
120
120
121
121
return s
122
122
@@ -133,7 +133,7 @@ def s(m):
133
133
134
134
weight = 1 / 2 + 1 / 2 * min ((dist / radius ), 1 )
135
135
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
137
137
138
138
return s
139
139
@@ -310,13 +310,13 @@ def ttr(m):
310
310
pos_x = (
311
311
m .ball .x -
312
312
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
314
314
)
315
315
316
316
pos_y = (
317
317
m .ball .y -
318
318
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
320
320
)
321
321
322
322
return (pos_x , pos_y )
@@ -347,6 +347,36 @@ def ttr(m):
347
347
)
348
348
)
349
349
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
+
350
380
self .seek .add_field (
351
381
algorithims .fields .PointField (
352
382
self .match ,
@@ -395,6 +425,23 @@ def ttr(m):
395
425
multiplier = lambda m : max (0.80 , math .sqrt (m .ball .vx ** 2 + m .ball .vy ** 2 ) + 0.1 ) # 50 cm/s
396
426
)
397
427
)
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
+ )
398
445
399
446
self .maintain .add_field (self .base_rules )
400
447
@@ -436,7 +483,7 @@ def ttr(m):
436
483
radius = 0.04 ,
437
484
radius_max = 2 ,
438
485
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 ,
440
487
field_limits = [0.75 * 2 , 0.65 * 2 ],
441
488
multiplier = 1
442
489
)
@@ -460,10 +507,10 @@ def decide(self):
460
507
of_goal_area = [1.30 , 0.30 , 0.30 , 0.70 ]
461
508
goal_area = [- 0.05 , 0.30 , 0.20 , 0.70 ]
462
509
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 ))
464
511
angle_robot_to_ball = - math .atan2 ((self .robot .y - self .match .ball .y ), (self .robot .x - self .match .ball .x ))
465
512
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 )
467
514
468
515
dist_to_ball = math .sqrt (
469
516
(self .robot .x - self .match .ball .x )** 2 + (self .robot .y - self .match .ball .y )** 2
@@ -472,7 +519,7 @@ def decide(self):
472
519
dist_to_ball_goal = math .sqrt (
473
520
(0 - self .match .ball .x )** 2 + (0.65 - self .match .ball .y )** 2
474
521
)
475
-
522
+
476
523
if point_in_rect (ball , of_goal_area ):
477
524
behaviour = self .carry
478
525
elif point_in_rect (ball ,goal_area ):
@@ -484,11 +531,11 @@ def decide(self):
484
531
or
485
532
(ball [1 ] <= 0.2 and self .robot .y <= 0.25 )) and self .robot .x < ball [0 ]:
486
533
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 ):
488
535
behaviour = self .carry
489
536
else :
490
537
behaviour = self .seek
491
-
538
+
492
539
print (self .robot .get_name (), "::" , behaviour .name )
493
540
494
541
if self .exporter :
0 commit comments