nn ui text

This commit is contained in:
sparshg 2023-01-09 00:56:00 +05:30
parent 7e3acb4d57
commit 7255bd617d
3 changed files with 30 additions and 5 deletions

View File

@ -200,7 +200,9 @@ async fn main() {
.ui(ui, |ui| {
ui.drag(hash!(), "", Some((2, 500)), &mut size);
});
ui.same_line(364.);
ui.same_line(307.);
widgets::Button::new("Debug").ui(ui);
ui.same_line(0.);
if widgets::Button::new(if bias { "Hide Bias" } else { "Show Bias" }).ui(ui)
{
bias = !bias;

View File

@ -159,6 +159,15 @@ impl NN {
BLACK
},
);
if i == 1 && inputs.len() > 1 {
draw_text(
&format!("{:.2}", inputs[j]),
p.0 - if inputs[j] < 0. { 50. } else { 42. },
p.1 + 4.,
16.,
WHITE,
);
}
}
}
for (j, p) in p2s.iter().enumerate() {
@ -166,6 +175,13 @@ impl NN {
draw_circle(p.0, p.1, 8., BLACK);
if !outputs.is_empty() {
draw_circle(p.0, p.1, 8., Color::new(1., 1., 1., outputs[j]));
draw_text(
&format!("{:.2}", outputs[j]),
p.0 + 14.,
p.1 + 4.,
16.,
WHITE,
);
}
}
draw_rectangle(width * 0.45, height * 0.45, 10., 10., RED);

View File

@ -163,21 +163,28 @@ impl World {
draw_text(
if self.over { "DEAD" } else { "ALIVE" },
-width * 0.5 + 20.,
75.,
70.,
24.,
if self.over { RED } else { GREEN },
);
draw_text(
&format!("Score: {}", self.score),
&format!("Hits: {}", self.score),
-width * 0.5 + 20.,
100.,
90.,
24.,
WHITE,
);
draw_text(
&format!("Fired: {}", self.player.shots),
-width * 0.5 + 20.,
110.,
24.,
WHITE,
);
draw_text(
&format!("Fitness: {:.2}", self.fitness),
-width * 0.5 + 20.,
125.,
130.,
24.,
WHITE,
);