things
This commit is contained in:
parent
930432aefe
commit
d09c8e9c9a
15
TODO.md
15
TODO.md
@ -2,18 +2,19 @@
|
|||||||
1. `grid.rs`
|
1. `grid.rs`
|
||||||
- Remove need for `deposit`/`deposit_all`
|
- Remove need for `deposit`/`deposit_all`
|
||||||
- Possible solution: Make it so when data is called, it generates it in a function when needed
|
- Possible solution: Make it so when data is called, it generates it in a function when needed
|
||||||
2. GPU compute
|
2. Add check to make sure that `img_data_vec` isn't over a set size in ram, if so, render it and flush to disk
|
||||||
|
3. Auto create gif instead of doing that after the fact manually with imagemagick
|
||||||
|
4. GPU compute
|
||||||
- Tried [ArrayFire-rust](https://github.com/arrayfire/arrayfire-rust) didn't work well, looking for another library
|
- Tried [ArrayFire-rust](https://github.com/arrayfire/arrayfire-rust) didn't work well, looking for another library
|
||||||
- Try using [emu](https://github.com/calebwin/emu) (seems to be a very good option)
|
- Try using [emu](https://github.com/calebwin/emu) (seems to be a very good option)
|
||||||
- emu seems to be the way to go
|
- emu seems to be the way to go
|
||||||
- May have to completely rewrite simulation to run on the gpu (that'll be fun *pain*)
|
- May have to completely rewrite simulation to run on the gpu (that'll be fun *pain*)
|
||||||
3. Auto create a video from generated images
|
5. Auto create a video from generated images
|
||||||
- Instead of using the command `ffmpeg -r 20 -i tmp/out_%d.png -vcodec libx265 -crf 25 -s 512x512 test.mp4` maybe use a rust library to do the same (more research needed)
|
- Instead of using the command `ffmpeg -r 20 -i tmp/out_%d.png -vcodec libx265 -crf 25 -s 512x512 test.mp4` maybe use a rust library to do the same (more research needed)
|
||||||
4. Live output
|
6. Live output
|
||||||
- Might want to do after #3 ("Auto create a video from generated images")
|
- Might want to do after #5 and #3
|
||||||
5. Make collisions for walls of grid
|
7. Add config and cmd arguments when running the binary to adjust simulation settings7.
|
||||||
6. Add config and cmd arguments when running the binary to adjust simulation settings7.
|
8. sin and cos optimizations
|
||||||
7. sin and cos optimizations
|
|
||||||
- sin/cos table
|
- sin/cos table
|
||||||
- precompute before simulation
|
- precompute before simulation
|
||||||
- Cache sin/cos values in hashmap to be recalled later
|
- Cache sin/cos values in hashmap to be recalled later
|
||||||
|
|||||||
15
src/agent.rs
15
src/agent.rs
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
grid::{Grid, PopulationConfig},
|
grid::Grid,
|
||||||
util::wrap,
|
util::wrap,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,18 +40,9 @@ impl Agent {
|
|||||||
i,
|
i,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn tick(&mut self, grid: &Grid) {
|
pub fn tick(&mut self, grid: &Grid, sensor_distance: f32, sensor_angle: f32, rotation_angle: f32, step_distance: f32, width: usize, height: usize) {
|
||||||
let (width, height) = (grid.width, grid.height);
|
|
||||||
let PopulationConfig {
|
|
||||||
sensor_distance,
|
|
||||||
sensor_angle,
|
|
||||||
rotation_angle,
|
|
||||||
step_distance,
|
|
||||||
..
|
|
||||||
} = grid.config;
|
|
||||||
|
|
||||||
let xc = self.x + cos(self.angle) * sensor_distance;
|
let xc = self.x + cos(self.angle) * sensor_distance;
|
||||||
let yc = self.y + sin(self.angle) * sensor_distance;
|
let yc = self.y + sin(self.angle) * sensor_distance;
|
||||||
|
|
||||||
|
|||||||
17
src/grid.rs
17
src/grid.rs
@ -161,9 +161,22 @@ impl Grid {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn tick(&mut self) {
|
pub fn tick(&mut self) {
|
||||||
let self_immutable = self.clone();
|
let (width, height) = (self.width, self.height);
|
||||||
|
let PopulationConfig {
|
||||||
|
sensor_distance,
|
||||||
|
sensor_angle,
|
||||||
|
rotation_angle,
|
||||||
|
step_distance,
|
||||||
|
..
|
||||||
|
} = self.config;
|
||||||
|
|
||||||
|
let self_imut = self.clone(); // Create immutable copy of self before ticking agents (this is a very bad solution, needs to be improved)
|
||||||
|
|
||||||
self.agents.par_iter_mut().for_each(|agent| {
|
self.agents.par_iter_mut().for_each(|agent| {
|
||||||
agent.tick(&self_immutable);
|
agent.tick(&self_imut,
|
||||||
|
sensor_distance, sensor_angle,
|
||||||
|
rotation_angle, step_distance,
|
||||||
|
width, height);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@ -3,22 +3,23 @@ use physarum::model;
|
|||||||
fn main() {
|
fn main() {
|
||||||
// # of iterations to go through
|
// # of iterations to go through
|
||||||
// let n_iterations = 1024;
|
// let n_iterations = 1024;
|
||||||
let n_iterations = 128;
|
let n_iterations = 2048;
|
||||||
|
|
||||||
// Size of grid and pictures
|
// Size of grid and pictures
|
||||||
// let (width, height) = (256, 256);
|
let (width, height) = (256, 256);
|
||||||
let (width, height) = (512, 512);
|
// let (width, height) = (512, 512);
|
||||||
// let (width, height) = (1024, 1024);
|
// let (width, height) = (1024, 1024);
|
||||||
|
|
||||||
// # of agents
|
// # of agents
|
||||||
// let n_particles = 1 << 10;
|
// let n_particles = 1 << 10;
|
||||||
let n_particles = 1 << 16;
|
// let n_particles = 1 << 16;
|
||||||
|
let n_particles = 1 << 20;
|
||||||
println!("n_particles: {}", n_particles);
|
println!("n_particles: {}", n_particles);
|
||||||
|
|
||||||
let diffusivity = 1;
|
let diffusivity = 1;
|
||||||
|
|
||||||
// `n_populations` is the # of types of agents
|
// `n_populations` is the # of types of agents
|
||||||
let n_populations = 1;
|
let n_populations = 4;
|
||||||
// let n_populations = 3;
|
// let n_populations = 3;
|
||||||
// let n_populations = 1 + rng.gen_range(1..4); // make # of populations between 2 and 5
|
// let n_populations = 1 + rng.gen_range(1..4); // make # of populations between 2 and 5
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user