wip: current project state

This commit is contained in:
Emil
2026-06-21 22:27:20 +03:00
parent 88892db493
commit a5436897ed
48 changed files with 4583 additions and 760 deletions
+86 -16
View File
@@ -1,5 +1,5 @@
use verbatim::ai::GameSession;
use verbatim::ai::AiAction;
use verbatim::ai::GameSession;
fn setup_empty() -> GameSession {
let mut s = GameSession::new_seeded(42);
@@ -11,19 +11,53 @@ fn setup_empty() -> GameSession {
#[test]
fn sand_falls_down() {
let mut s = setup_empty();
s.perform_action(&AiAction::FillRect { x: 100, y: 115, w: 10, h: 1, material: "stone".into() });
s.perform_action(&AiAction::SetCell { x: 105, y: 105, material: "sand".into() });
s.perform_action(&AiAction::FillRect {
x: 100,
y: 115,
w: 10,
h: 1,
material: "stone".into(),
});
s.perform_action(&AiAction::SetCell {
x: 105,
y: 105,
material: "sand".into(),
});
s.step(10);
assert_eq!(s.get_cell(105, 105).material, "empty", "sand should have fallen from y=105");
assert_eq!(s.get_cell(105, 114).material, "sand", "sand should be resting on stone at y=114");
assert_eq!(
s.get_cell(105, 105).material,
"empty",
"sand should have fallen from y=105"
);
assert_eq!(
s.get_cell(105, 114).material,
"sand",
"sand should be resting on stone at y=114"
);
}
#[test]
fn sand_displaces_water() {
let mut s = setup_empty();
s.perform_action(&AiAction::FillRect { x: 100, y: 115, w: 10, h: 1, material: "stone".into() });
s.perform_action(&AiAction::FillRect { x: 100, y: 110, w: 10, h: 5, material: "water".into() });
s.perform_action(&AiAction::SetCell { x: 105, y: 105, material: "sand".into() });
s.perform_action(&AiAction::FillRect {
x: 100,
y: 115,
w: 10,
h: 1,
material: "stone".into(),
});
s.perform_action(&AiAction::FillRect {
x: 100,
y: 110,
w: 10,
h: 5,
material: "water".into(),
});
s.perform_action(&AiAction::SetCell {
x: 105,
y: 105,
material: "sand".into(),
});
s.step(20);
let sand_at_bottom = s.get_cell(105, 114).material == "sand";
assert!(sand_at_bottom, "sand should sink to bottom through water");
@@ -32,20 +66,56 @@ fn sand_displaces_water() {
#[test]
fn sand_piles_on_stone() {
let mut s = setup_empty();
s.perform_action(&AiAction::FillRect { x: 100, y: 115, w: 10, h: 1, material: "stone".into() });
s.perform_action(&AiAction::SetCell { x: 105, y: 105, material: "sand".into() });
s.perform_action(&AiAction::SetCell { x: 105, y: 104, material: "sand".into() });
s.perform_action(&AiAction::FillRect {
x: 100,
y: 115,
w: 10,
h: 1,
material: "stone".into(),
});
s.perform_action(&AiAction::SetCell {
x: 105,
y: 105,
material: "sand".into(),
});
s.perform_action(&AiAction::SetCell {
x: 105,
y: 104,
material: "sand".into(),
});
s.step(15);
let count = s.count_material_in_region(104, 112, 3, 4, "sand");
assert!(count >= 2, "both sand cells should have piled up, got {} sand cells", count);
assert!(
count >= 2,
"both sand cells should have piled up, got {} sand cells",
count
);
}
#[test]
fn sand_does_not_fall_through_stone() {
let mut s = setup_empty();
s.perform_action(&AiAction::FillRect { x: 100, y: 110, w: 10, h: 1, material: "stone".into() });
s.perform_action(&AiAction::SetCell { x: 105, y: 105, material: "sand".into() });
s.perform_action(&AiAction::FillRect {
x: 100,
y: 110,
w: 10,
h: 1,
material: "stone".into(),
});
s.perform_action(&AiAction::SetCell {
x: 105,
y: 105,
material: "sand".into(),
});
s.step(10);
assert_eq!(s.get_cell(105, 109).material, "sand", "sand should rest on top of stone");
assert_eq!(s.get_cell(105, 110).material, "stone", "stone should remain");
assert_eq!(
s.get_cell(105, 109).material,
"sand",
"sand should rest on top of stone"
);
assert_eq!(
s.get_cell(105, 110).material,
"stone",
"stone should remain"
);
}