Skip to content

Commit 869abc0

Browse files
committed
final
1 parent c993f30 commit 869abc0

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

src/my_strategy.rs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Strategy for MyStrategy {
4646
// Choose My Role 1. GK, 2. DEF, 3. OFF 4. SUP
4747
let my_role = self.coach.find_role(me, _game, _rules);
4848
// 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);
5050

5151
match my_role {
5252
Role::NONE => println!("No Role is Selected"),
@@ -85,24 +85,28 @@ impl MyStrategy {
8585
};
8686
let ball_seg = Seg2::new(self.game.ball.position(), self.game.ball.velocity()*100.0);
8787
let biset = get_bisect(&goal_line, &ball_pos);
88-
let mut target = Vec2{x:0.0, y:-self.rules.arena.depth/2.0};
88+
let mut target = biset.terminal();
8989
println!("DFAS");
9090
if self.game.ball.velocity().y < -1.0 { // KICK
9191
target = goal_line.intersection(ball_seg);
92-
if target.is_valid() {
92+
if !target.is_valid() {
9393
target = Vec2::new(ball_pos.x, -self.rules.arena.depth/2.0);
9494
}
95-
} else if self.game.ball.position().y < 1.0 {
96-
target = biset.terminal();
95+
} else if self.game.ball.position().y < 0.0 {
96+
target = Vec2{x:self.game.ball.position().x, y:-self.rules.arena.depth/2.0};
9797
}
9898
if target.x < -self.rules.arena.goal_width/2.0 + 1.5 {
9999
target.x = -self.rules.arena.goal_width/2.0 + 1.5;
100100
} else if target.x > self.rules.arena.goal_width/2.0 - 1.5{
101101
target.x = self.rules.arena.goal_width/2.0 - 1.5;
102102
}
103103
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+
// }
104108

105-
if (ball_pos.dist(self.me.position()) < 4.0 && self.game.ball.height() > 3.0) {
109+
if ball_pos.dist(self.me.position()) < 3.0 && self.game.ball.height() > 2.5 {
106110
self.action.jump_speed = self.rules.ROBOT_MAX_JUMP_SPEED;
107111
} else {
108112
self.action.jump_speed = 0.0;
@@ -132,24 +136,16 @@ impl MyStrategy {
132136
let robotpos = self.me.position();
133137
let finalDir = (*target - ballpos).th();
134138
let mut idealPath = (ballpos - robotpos).th().deg();
135-
<<<<<<< HEAD
136-
let mut movementDir = (idealPath - finalDir);
137-
=======
138139
let mut movementDir = ((ballpos - robotpos).th() - finalDir).deg();
139-
>>>>>>> origin/kickV2
140140
let ballVel = self.game.ball.velocity();
141141
if movementDir >= 180.0 {
142142
movementDir -= 360.0;
143143
}
144144
if movementDir < -180.0 {
145145
movementDir += 360.0;
146146
}
147-
<<<<<<< HEAD
148-
println!("movementDir {}", movementDir);
149-
=======
150147

151148
println!("movementDir {}", movementDir );
152-
>>>>>>> origin/kickV2
153149

154150
let mut shift = 0.0;
155151

@@ -165,34 +161,24 @@ impl MyStrategy {
165161
if self.game.ball.height() >= 4.0 && ballVel.len() > 0.0{
166162
let touchPrediction = self.ballTouchPrediction();
167163
let mut locationByPredict = touchPrediction + (touchPrediction - *target).normalize() * (self.me.radius + self.game.ball.radius + (self.game.ball.height() - self.game.ball.radius) * 0.2) + ballVel * 0.05;
168-
164+
169165
self.gtp(&locationByPredict);
170166
} else {
171167
if (movementDir.abs() < 25.0) {
172168
idealPath = (*target - robotpos).th().deg();
173169
let sagPath = (ballpos - robotpos).th().deg();
174-
<<<<<<< HEAD
175-
if ((robotCurrentPath - sagPath).abs()) < 40.0 || self.me.velocity().len() < 0.1 {
176-
=======
177170
if ((robotCurrentPath - sagPath).abs()) < 15.0 && self.me.velocity().len() > 10.0{
178-
>>>>>>> origin/kickV2
179171
jump = self.rules.ROBOT_MAX_JUMP_SPEED;
180172
} else {
181173
jump = 0.0;
182174
}
183175
} else {
184176
jump = 0.0;
185-
<<<<<<< HEAD
186-
idealPath += shift;
187-
}
188-
self.set_robot_vel(idealPath ,100.0,jump);
189-
=======
190177
idealPath = (idealPath + shift);
191178
}
192179

193180

194-
self.set_robot_vel(idealPath*3.1415/180.0 ,100.0,jump);
195-
>>>>>>> origin/kickV2
181+
self.set_robot_vel(idealPath*DEG2RAD ,100.0,jump);
196182
}
197183

198184
}

0 commit comments

Comments
 (0)