1
Fork 0

robot amount from toml

This commit is contained in:
Andy Killorin 2026-11-09 23:44:00 -05:00
parent 0bdb3ffef0
commit 8c2e9f37eb
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -45,7 +45,6 @@ struct Robot {
pose: Pose,
alive: AtomicBool,
collider: Ball,
sensor: Sensor,
team: Color,
policy: Policy,
}
@ -73,7 +72,7 @@ impl Mortal for Robot {
impl Robot {
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]) {
@ -223,16 +222,16 @@ impl Simulation {
let angle = Uniform::new(0.0, TAU).unwrap();
// blue robots
for i in 5..20 {
for i in 0..config.blu_count {
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()));
}
//red robots
for i in 5..20 {
for i in 0..config.red_count {
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()));
}