Display scores and walls in sim
This commit is contained in:
parent
af3308cfc5
commit
c723fdb3f7
|
@ -68,6 +68,10 @@ const Node = struct {
|
|||
node.updateScore(self.score + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_robot) {
|
||||
robot.writeCellScore(self.p, self.score);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -145,6 +149,10 @@ pub fn setWall(p: Point, direction: Cardinal, value: bool) void {
|
|||
}
|
||||
// assert(!(isEdge(p, direction) and !value));
|
||||
|
||||
if (!is_robot and value) {
|
||||
robot.showWall(p, direction);
|
||||
}
|
||||
|
||||
if (isEdge(p, direction)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ const std = @import("std");
|
|||
const assert = std.debug.assert;
|
||||
|
||||
const map = @import("map.zig");
|
||||
const Point = map.Point;
|
||||
const Cardinal = map.Cardinal;
|
||||
|
||||
const stdin = std.io.getStdIn().reader();
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
|
@ -82,3 +84,17 @@ pub fn readBack() bool {
|
|||
// What?
|
||||
std.debug.panic();
|
||||
}
|
||||
|
||||
pub fn showWall(p: Point, direction: Cardinal) void {
|
||||
const dir :u8 = switch (direction) {
|
||||
.north => 'n',
|
||||
.south => 's',
|
||||
.east => 'e',
|
||||
.west => 'w',
|
||||
};
|
||||
stdout.print("setWall {d} {d} {c}\n", .{ p.x, p.y, dir }) catch unreachable;
|
||||
}
|
||||
|
||||
pub fn writeCellScore(p: Point, score: usize) void {
|
||||
stdout.print("setText {d} {d} {d}\n", .{p.x, p.y, score}) catch unreachable;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue