|
@@ -1,6 +1,12 @@
|
|
|
const util = require("util");
|
|
|
+const fs = require("node:fs");
|
|
|
const Computer = require("../IntComp/Computer");
|
|
|
|
|
|
+// Load and parse the input
|
|
|
+const input = fs.readFileSync("./13/input.dat", "utf8")
|
|
|
+ .split(",")
|
|
|
+ .map((x) => parseInt(x, 10));
|
|
|
+
|
|
|
const sampleInput = [104, 1, 104, 2, 104, 3, 104, 6, 104, 5, 104, 4, 99];
|
|
|
|
|
|
const gameTiles = [
|
|
@@ -11,7 +17,7 @@ const gameTiles = [
|
|
|
"°", // Ball
|
|
|
];
|
|
|
|
|
|
-const arcade = new Computer(sampleInput);
|
|
|
+const arcade = new Computer(input);
|
|
|
arcade.Run();
|
|
|
|
|
|
// console.log(arcade.outputValues);
|
|
@@ -32,6 +38,7 @@ function render(screenState) {
|
|
|
let board = [];
|
|
|
let boardWidth = -1;
|
|
|
let boardHeight = -1;
|
|
|
+ let blockTileCount = 0;
|
|
|
|
|
|
for (let i = 0; i < screenState.length; i += 3) {
|
|
|
const x = screenState[i];
|
|
@@ -53,6 +60,9 @@ function render(screenState) {
|
|
|
|
|
|
for (const row of board) {
|
|
|
for (const tile of row) {
|
|
|
+ if (tile == 2) {
|
|
|
+ blockTileCount++;
|
|
|
+ }
|
|
|
boardString += gameTiles[tile];
|
|
|
}
|
|
|
boardString += "\n";
|
|
@@ -60,6 +70,7 @@ function render(screenState) {
|
|
|
|
|
|
console.clear();
|
|
|
console.log(boardString);
|
|
|
+ console.log("\n", "Block tiles: ", blockTileCount);
|
|
|
}
|
|
|
|
|
|
function normalizeBoard(board, width, height) {
|