debugging

This commit is contained in:
richmans
2026-04-08 21:50:17 +02:00
parent 927283f81d
commit e0fd7d8a34

View File

@@ -154,11 +154,13 @@ int run_simulations(struct Maps* maps, struct Program* program) {
if (map->cells[cell_from(ant->cell, 3)] == v1) dirs[found_dirs++] = 3; if (map->cells[cell_from(ant->cell, 3)] == v1) dirs[found_dirs++] = 3;
if (map->cells[cell_from(ant->cell, 4)] == v1) dirs[found_dirs++] = 4; if (map->cells[cell_from(ant->cell, 4)] == v1) dirs[found_dirs++] = 4;
if (found_dirs == 0) { if (found_dirs == 0) {
res = (rnum(&rstate) % 4) + 1; res = 0;
} else if (found_dirs == 1) { } else if (found_dirs == 1) {
debug("FOUND 1\n");
res = dirs[0]; res = dirs[0];
} else { } else {
int dirrie = rnum(&rstate) % found_dirs; int dirrie = rnum(&rstate) % found_dirs;
debug("FOUND %d\n", found_dirs);
res = dirs[dirrie]; res = dirs[dirrie];
} }
set_reg(ant, v2, res); set_reg(ant, v2, res);
@@ -171,7 +173,7 @@ int run_simulations(struct Maps* maps, struct Program* program) {
set_reg(ant, ins->arg2, v1); set_reg(ant, ins->arg2, v1);
break; break;
case INS_PICKUP: case INS_PICKUP:
debug("PICKUP?\n"); debug("PICKUP? %d %d\n", ant->carrying, food[ant->cell]);
if (!ant->carrying && food[ant->cell] > 0) { if (!ant->carrying && food[ant->cell] > 0) {
ant->carrying = food[ant->cell]--; ant->carrying = food[ant->cell]--;
debug("PICKUP!\n"); debug("PICKUP!\n");