Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
some graph refactoring, like moving to sim struct instead of Checks a…
Browse files Browse the repository at this point in the history
…nd some more bug fixing with graph
  • Loading branch information
NotAF0e committed Jan 1, 2023
1 parent c876a90 commit b396128
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions pop_sim_rust_gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum Sex {
struct Sim {
population: i64,
people: Vec<Person>,
graph_data: Vec<[f64; 2]>,
}

#[derive(Debug)]
Expand All @@ -55,7 +56,6 @@ pub struct World {
struct Checks {
data: Vec<i32>,
start_months: i32,
graph_data: Vec<[f64; 2]>,
}


Expand Down Expand Up @@ -241,7 +241,7 @@ fn main() {
self.sim_data.update_details();

// Graph data pushing
self.checks.graph_data.push([self.checks.start_months as f64 - self.checks.data[1] as f64, self.sim_data.people.len() as f64]);
self.sim_data.graph_data.push([self.checks.start_months as f64 - self.checks.data[1] as f64, self.sim_data.people.len() as f64]);

self.sim_data.people.retain(|person| person.age != -1);
self.checks.data[1] -= 1;
Expand Down Expand Up @@ -270,11 +270,15 @@ fn main() {

// Plot which shows population through time
egui::Window::new("Plot - Population against months").show(ctx, |ui| {
let data: PlotPoints = PlotPoints::new(self.checks.graph_data.clone());
let data: PlotPoints = PlotPoints::new(self.sim_data.graph_data.clone());
let line = Line::new(data);
Plot::new("plot").view_aspect(2.0).
allow_drag(false).allow_scroll(false).allow_zoom(false).
show(ui, |plot_ui| plot_ui.line(line));
Plot::new("plot").view_aspect(2.0)
.allow_drag(false)
.allow_scroll(false)
.allow_zoom(false)
.allow_boxed_zoom(false)
.allow_double_click_reset(false)
.show(ui, |plot_ui| plot_ui.line(line));
});

// A table with all the people in the simulation
Expand Down Expand Up @@ -321,6 +325,7 @@ fn main() {
sim_data: Sim {
people: vec![],
population: -1,
graph_data: vec![],
},
world_data: World {
name: "Earth",
Expand All @@ -331,7 +336,6 @@ fn main() {
checks: Checks {
data: vec![0, 480, 0],
start_months: 0, // To change this val just change Checks::data[1]
graph_data: vec![],
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion world/target/.rustc_info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"rustc_fingerprint":4167461181641110981,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.68.0-nightly (ce85c9857 2022-12-30)\nbinary: rustc\ncommit-hash: ce85c98575e3016cf2007d90a85be321e592aa96\ncommit-date: 2022-12-30\nhost: x86_64-pc-windows-msvc\nrelease: 1.68.0-nightly\nLLVM version: 15.0.6\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Phonixed\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"llvm14-builtins-abi\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}}
{"rustc_fingerprint":3703614116936124184,"outputs":{"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.65.0 (897e37553 2022-11-02)\nbinary: rustc\ncommit-hash: 897e37553bba8b42751c67658967889d11ecd120\ncommit-date: 2022-11-02\nhost: x86_64-pc-windows-msvc\nrelease: 1.65.0\nLLVM version: 15.0.0\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Phonixed\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"llvm14-builtins-abi\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}}

0 comments on commit b396128

Please sign in to comment.