1
Fork 0

view dist conf

This commit is contained in:
Andy Killorin 2026-11-10 00:38:42 -05:00
parent 710050f01a
commit bd22161bbc
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
2 changed files with 10 additions and 8 deletions

View file

@ -1,4 +1,5 @@
food_amount = 920
food_amount = 100
view_dist = 200
red_count = 10
blu_count = 10
@ -18,5 +19,5 @@ none= [0.3, 0.01]
aggressive = false
food = [1,0]
kin = [-0.3,0.02]
nonkin = [0.3,-0.02]
nonkin = [-0.3,-0.02]
none= [0.3, 0.01]

View file

@ -29,7 +29,6 @@ use clap::Parser;
use serde::Deserialize;
const VIEW_DIST: f32 = 180.0;
const BOT_RADIUS: f32 = 16.0;
const KILL_RADIUS: f32 = 140.0;
@ -48,6 +47,7 @@ struct Robot {
team: Color,
policy: Policy,
weapon: Weapon,
view_dist: f32,
}
impl Mortal for Robot {
@ -72,8 +72,8 @@ impl Mortal for Robot {
}
impl Robot {
fn new(pose: Pose, team: Color, policy: Policy, weapon: Weapon) -> Self {
Self { pose, alive: AtomicBool::new(true), collider: Ball::new(BOT_RADIUS), team, policy, weapon}
fn new(pose: Pose, team: Color, policy: Policy, weapon: Weapon, view_dist: f32) -> Self {
Self { pose, alive: AtomicBool::new(true), collider: Ball::new(BOT_RADIUS), team, policy, weapon, view_dist}
}
fn move_step(&mut self, forward_right: [f32;2]) {
@ -87,7 +87,7 @@ impl Robot {
}
fn view_end(&self) -> Vec2 {
self.pose.translation + self.ahead() * VIEW_DIST
self.pose.translation + self.ahead() * self.view_dist
}
@ -229,6 +229,7 @@ struct Weapon {
#[derive(Deserialize)]
struct SimConfig {
food_amount: usize,
view_dist: f32,
red_count: usize,
red_policy: Policy,
blu_count: usize,
@ -261,14 +262,14 @@ impl Simulation {
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 + 250.0}, Rot2::from_angle(rand_angle));
robots.push(Robot::new(pose, BLUE, config.blu_policy.clone(), config.weapon.clone()));
robots.push(Robot::new(pose, BLUE, config.blu_policy.clone(), config.weapon.clone(), config.view_dist));
}
//red robots
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 + 250.0}, Rot2::from_angle(rand_angle));
robots.push(Robot::new(pose, RED, config.red_policy.clone(), config.weapon.clone()));
robots.push(Robot::new(pose, RED, config.red_policy.clone(), config.weapon.clone(), config.view_dist));
}
let mut food = Vec::new();