15 puzzle game: Difference between revisions

m
Back to previous version, because of better understanding.
m (Changed cells initialization)
m (Back to previous version, because of better understanding.)
Tag: Manual revert
 
Line 16,484:
const stdout = std.io.getStdOut().writer();
 
const empty_token = 15;
const tokens = [16][]const u8{ " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "13", "14", "15", " " };
 
const empty_token = 15;
var empty: u8 = empty_token;
var valuecells: [16]u8 = undefined;
var invalid: bool = false;
 
// Create cells
var cells = init: {
var value: [16]u8 = undefined;
for (value, 0..) |_, i| {
value[i] = @intCast(i);
}
break :init value;
};
 
const Move = enum { no, up, down, left, right };
Line 16,567 ⟶ 16,559:
 
pub fn main() !void {
var n: u8 = 0;
while (n < 16) : (n += 1) {
valuecells[in] = @intCast(i)n;
}
 
try shuffle(50);
try showBoard();
Line 16,575 ⟶ 16,572:
}
}
 
</syntaxhighlight>
 
22

edits