robot amount from toml
This commit is contained in:
parent
0bdb3ffef0
commit
8c2e9f37eb
1 changed files with 5 additions and 6 deletions
|
|
@ -45,7 +45,6 @@ struct Robot {
|
||||||
pose: Pose,
|
pose: Pose,
|
||||||
alive: AtomicBool,
|
alive: AtomicBool,
|
||||||
collider: Ball,
|
collider: Ball,
|
||||||
sensor: Sensor,
|
|
||||||
team: Color,
|
team: Color,
|
||||||
policy: Policy,
|
policy: Policy,
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +72,7 @@ impl Mortal for Robot {
|
||||||
|
|
||||||
impl Robot {
|
impl Robot {
|
||||||
fn new(pose: Pose, team: Color, policy: Policy) -> Self {
|
fn new(pose: Pose, team: Color, policy: Policy) -> Self {
|
||||||
Self { pose, alive: AtomicBool::new(true), collider: Ball::new(BOT_RADIUS), sensor: Sensor::None, team, policy}
|
Self { pose, alive: AtomicBool::new(true), collider: Ball::new(BOT_RADIUS), team, policy}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_step(&mut self, forward_right: [f32;2]) {
|
fn move_step(&mut self, forward_right: [f32;2]) {
|
||||||
|
|
@ -223,16 +222,16 @@ impl Simulation {
|
||||||
|
|
||||||
let angle = Uniform::new(0.0, TAU).unwrap();
|
let angle = Uniform::new(0.0, TAU).unwrap();
|
||||||
// blue robots
|
// blue robots
|
||||||
for i in 5..20 {
|
for i in 0..config.blu_count {
|
||||||
let rand_angle = angle.sample(&mut rng);
|
let rand_angle = angle.sample(&mut rng);
|
||||||
let pose:Pose = Pose::from_parts(Vec2 { x: 100.0, y: i as f32*50.0 }, Rot2::from_angle(rand_angle));
|
let pose:Pose = Pose::from_parts(Vec2 { x: 100.0, y: i as f32*50.0 + 250.0}, Rot2::from_angle(rand_angle));
|
||||||
robots.push(Robot::new(pose, BLUE, config.blu_policy.clone()));
|
robots.push(Robot::new(pose, BLUE, config.blu_policy.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//red robots
|
//red robots
|
||||||
for i in 5..20 {
|
for i in 0..config.red_count {
|
||||||
let rand_angle = angle.sample(&mut rng);
|
let rand_angle = angle.sample(&mut rng);
|
||||||
let pose:Pose = Pose::from_parts(Vec2 { x: 1200.0, y: i as f32*50.0 }, Rot2::from_angle(rand_angle));
|
let pose:Pose = Pose::from_parts(Vec2 { x: 1200.0, y: i as f32*50.0 + 250.0}, Rot2::from_angle(rand_angle));
|
||||||
robots.push(Robot::new(pose, RED, config.red_policy.clone()));
|
robots.push(Robot::new(pose, RED, config.red_policy.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue