@@ -46,7 +46,7 @@ impl Strategy for MyStrategy {
46
46
// Choose My Role 1. GK, 2. DEF, 3. OFF 4. SUP
47
47
let my_role = self . coach . find_role ( me, _game, _rules) ;
48
48
// Execute My Role
49
- let oppGoal = Vec2 :: new ( 0.0 , - self . rules . arena . depth /2.0 ) ;
49
+ let oppGoal = Vec2 :: new ( 0.0 , self . rules . arena . depth /2.0 + 20 .0) ;
50
50
51
51
match my_role {
52
52
Role :: NONE => println ! ( "No Role is Selected" ) ,
@@ -69,7 +69,9 @@ fn get_bisect(seg: &Seg2, vec: &Vec2) -> Seg2{
69
69
let v2 = seg. origin ( ) . rotateVector ( -ang. deg ( ) ) ;
70
70
let s = Seg2 :: new ( * vec, v2) ;
71
71
let v3 = s. intersection ( * seg) ;
72
- println ! ( "AAA {:?} {:?}" , ang, v3) ;
72
+ if ! v3. is_valid ( ) {
73
+ return Seg2 :: new ( * vec, ( seg. origin ( ) + seg. terminal ( ) ) * 0.5 )
74
+ }
73
75
Seg2 :: new ( * vec, v3)
74
76
}
75
77
@@ -78,15 +80,14 @@ impl MyStrategy {
78
80
79
81
80
82
fn gk ( & mut self ) {
81
- let ball_pos = self . game . ball . position ( ) ;
83
+ let ball_pos = self . game . ball . position ( ) + self . game . ball . velocity ( ) * 0.1 ;
82
84
let goal_line = Seg2 {
83
85
origin : Vec2 { x : self . rules . arena . goal_width /2.0 , y : -self . rules . arena . depth /2.0 } ,
84
86
terminal : Vec2 { x : -self . rules . arena . goal_width /2.0 , y : -self . rules . arena . depth /2.0 }
85
87
} ;
86
88
let ball_seg = Seg2 :: new ( self . game . ball . position ( ) , self . game . ball . velocity ( ) * 100.0 ) ;
87
89
let biset = get_bisect ( & goal_line, & ball_pos) ;
88
90
let mut target = biset. terminal ( ) ;
89
- println ! ( "DFAS" ) ;
90
91
if self . game . ball . velocity ( ) . y < -1.0 { // KICK
91
92
target = goal_line. intersection ( ball_seg) ;
92
93
if !target. is_valid ( ) {
@@ -100,16 +101,11 @@ impl MyStrategy {
100
101
} else if target. x > self . rules . arena . goal_width /2.0 - 1.5 {
101
102
target. x = self . rules . arena . goal_width /2.0 - 1.5 ;
102
103
}
103
- self . gtp ( & target) ;
104
- // let my = self.me.position();
105
- // if self.game.ball.position().dist(Vec2::new(0.0, -self.rules.arena.depth/2.0)) < 20.0 && self.game.ball.velocity().len() < 2.0 {
106
- // self.kick(&((ball_pos - my) * 10.0));
107
- // }
108
104
105
+ self . gtp ( & target) ;
106
+ self . action . jump_speed = 0.0 ;
109
107
if ball_pos. dist ( self . me . position ( ) ) < 3.0 && self . game . ball . height ( ) > 2.5 {
110
108
self . action . jump_speed = self . rules . ROBOT_MAX_JUMP_SPEED ;
111
- } else {
112
- self . action . jump_speed = 0.0 ;
113
109
}
114
110
115
111
}
0 commit comments