Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Plants vs. Zombies: Wall-nut Bowling (1-5) plays to its end

Mason363763eff9f9306
diff --git a/games/pvz/src/board.c b/games/pvz/src/board.c
index 007ece56..b5fcef4b 100644
--- a/games/pvz/src/board.c
+++ b/games/pvz/src/board.c
@@ -300,8 +300,9 @@ void board_start(int level) {
/* (the zombies wait for the first plant, the first time through the Adventure) */
if (progress.finished) B.started = 1;
if (B.mode == MODE_BOWLING) {
+ /* (Challenge::StartLevel: a wall-nut on the belt, the next in 400 ticks, the zombies in 200) */
B.npackets = 1, B.packets[0].kind = P_WALLNUT, B.packets[0].x = 0;
- B.started = 1, B.wave_in = 200;
+ B.started = 1, B.wave_in = 200, B.conveyor_in = 400;
}
if (B.mode == MODE_CONVEYOR) B.started = 1, B.conveyor_in = 1;
if (B.mode == MODE_WHACK) {
@@ -789,7 +790,8 @@ void board_tick(void) {
/* the effects */
for (int i = 0; i < B.nfx; i++)
if (++B.fx[i].t >= B.fx[i].life) B.fx[i--] = B.fx[--B.nfx];
- if (!B.started) return;
+ /* (nothing moves before the first plant, the first time through, nor in 1-5's shovel lesson) */
+ if (!B.started || B.tutorial == 4) return;
if (has_conveyor()) conveyor_tick();
plants_tick();
@@ -827,7 +829,11 @@ void board_tick(void) {
n->x = 1000;
break;
}
- damage_zombie(z, z->armor > 0 ? 900 : 1800, false);
+ /* (Plant::UpdateBowling: a paper or a door takes 400, a cone or a bucket 900, and the blow stops there;
+ * a door hit by a nut already bouncing, and a bare zombie, take 1800) */
+ if (z->shield > 0 && !(z->kind == Z_DOOR && n->dir)) damage_zombie(z, z->shield < 400 ? z->shield : 400, false);
+ else if (z->shield <= 0 && z->armor > 0) damage_zombie(z, z->armor < 900 ? z->armor : 900, false);
+ else damage_zombie(z, 1800, false);
z->hit_at = B.ticks;
if (z->health <= 0) kill_zombie(z, DIE_NORMAL);
n->dir = n->row == 0 ? 1 : n->row == 4 ? -1 : n->dir == 0 ? (frand() < 0.5f ? -1 : 1) : -n->dir;
diff --git a/games/pvz/src/draw.c b/games/pvz/src/draw.c
index 52eee392..dc851a2b 100644
--- a/games/pvz/src/draw.c
+++ b/games/pvz/src/draw.c
@@ -576,7 +576,7 @@ void draw_lawn(bool hud_mower) {
for (float x = ice->x; x < 820; x += 75)
gfx_anim(I_ICE_TRAIL, 0, SX(x), SY(row_y(r, x) - 22), 0, TINT_NONE, a);
}
- if (B.mode == MODE_BOWLING) gfx_image(I_BOWLING_STRIPE, SX(BOARD_LEFT + 3 * CELL_W), SY(BOARD_TOP + 250));
+ if (bowling_line()) gfx_image(I_BOWLING_STRIPE, SX(BOARD_LEFT + 3 * CELL_W), SY(BOARD_TOP + 250));
/* row by row, from the back */
for (int r = 0; r < B.nrows; r++) {
for (int i = 0; i < B.ngraves; i++)
diff --git a/games/pvz/src/draw.h b/games/pvz/src/draw.h
index 8c29cd13..13a481b8 100644
--- a/games/pvz/src/draw.h
+++ b/games/pvz/src/draw.h
@@ -15,6 +15,7 @@ void draw_plant_at(int kind, int x, int y, int alpha);
void draw_sun(float x, float y, int value, int alpha);
void draw_street(const uint8_t *kinds, int n);
int left_fog_column(void);
+bool bowling_line(void); /* (screens.c) */
/* hud.c: the seed bank, the progress meter, the cursor and the screen's messages */
typedef struct {
@@ -29,6 +30,7 @@ void hud_draw(bool cursor);
void hud_cursor_draw(void);
void hud_bank_draw(int x, int y, bool costs);
int bank_width(void);
+/* cooldown_full < 0: a packet on the conveyor belt (free: no cost on it) */
void packet_draw(int kind, int x, int y, int cooldown, int cooldown_full, bool dim, bool selected, int key);
void draw_ready(int t);
void draw_message_band(const char *s);
diff --git a/games/pvz/src/hud.c b/games/pvz/src/hud.c
index ed44c7e1..cdf899c2 100644
--- a/games/pvz/src/hud.c
+++ b/games/pvz/src/hud.c
@@ -15,8 +15,10 @@ static const uint16_t C_DARK = 0x0000;
void packet_draw(int kind, int x, int y, int cooldown, int full, bool dim, bool selected, int key) {
gfx_image(I_PACKET, x, y);
- gfx_image(I_PACKET_PEASHOOTER + kind, x + 10, y + 12);
- if (kind < N_SEEDS && plant_defs[kind].cost)
+ /* (the explode-o-nut: the wall-nut's picture in red, as the game colours it) */
+ if (kind == P_EXPLODENUT) gfx_anim(I_PACKET_WALLNUT, 0, x + 10, y + 12, 0, TINT_RED, 32);
+ else gfx_image(I_PACKET_PEASHOOTER + kind, x + 10, y + 12);
+ if (full >= 0 && kind < N_SEEDS && plant_defs[kind].cost)
gfx_text(F_SMALL, x + 10, y + 26, gfx_fmt("%d", plant_defs[kind].cost), C_DARK, GFX_CENTER);
if (full > 0 && cooldown > 0) {
int h = 28 * cooldown / full;
@@ -56,7 +58,7 @@ static void conveyor_draw(void) {
for (int i = 0; i < B.npackets; i++) {
int x = 6 + (int)(B.packets[i].x * 0.4f);
if (x > 190) continue;
- packet_draw(B.packets[i].kind, x, 4, 0, 0, false, hud.selected == i, i + 1 <= 10 ? i + 1 : 0);
+ packet_draw(B.packets[i].kind, x, 4, 0, -1, false, hud.selected == i, i + 1 <= 10 ? i + 1 : 0);
}
}
@@ -124,8 +126,9 @@ static const char *tutorial_hint(void) {
}
void hud_draw(bool cursor) {
- if (has_conveyor()) conveyor_draw();
- else if (B.mode != MODE_VASE && B.mode != MODE_WHACK) {
+ if (has_conveyor()) {
+ if (B.tutorial != 4) conveyor_draw(); /* (1-5's belt comes after the shovel lesson) */
+ } else if (B.mode != MODE_VASE && B.mode != MODE_WHACK) {
hud_bank_draw(0, 0, true);
for (int i = 0; i < B.nseeds; i++) {
int kind = B.seeds[i];
diff --git a/games/pvz/src/save.c b/games/pvz/src/save.c
index e77478c1..111a4844 100644
--- a/games/pvz/src/save.c
+++ b/games/pvz/src/save.c
@@ -204,6 +204,8 @@ bool board_load(void) {
memcpy(B.coins, p, c[4] * sizeof(Coin)), p += c[4] * sizeof(Coin);
memcpy(B.rollers, p, c[6] * sizeof(Roller)), p += c[6] * sizeof(Roller);
if (B.has_boss) memcpy(&boss, p, sizeof boss);
+ /* (1-5 kept by an earlier version, standing still after the shovel lesson: the bowling goes on) */
+ if (B.mode == MODE_BOWLING && B.tutorial != 4) B.started = 1;
board_forget();
return true;
}
diff --git a/games/pvz/src/screens.c b/games/pvz/src/screens.c
index 1117ce3e..d9dffd46 100644
--- a/games/pvz/src/screens.c
+++ b/games/pvz/src/screens.c
@@ -149,6 +149,11 @@ static const Line talks[] = {
static int talk_at; /* the line being said (its index), -1 none */
static int talk_after; /* what follows: TA_* */
+/* Wall-nut Bowling's red line: the first time, from "We're going BOWLING!" on */
+bool bowling_line(void) {
+ if (B.mode != MODE_BOWLING || B.tutorial == 4) return false;
+ return g_state != ST_DAVE || talk_at < 0 || talks[talk_at].id < 2400 || talks[talk_at].id > 2410;
+}
enum { TA_PAN, TA_SHOVEL, TA_BOWL, TA_SLOT_ASK, TA_SLOT_ASK8, TA_MENU, TA_SHOP };
static int talk_bit(int id) {
switch (id / 100) {
@@ -239,6 +244,11 @@ static void begin_level(int level) {
}
} else if (level == 5)
talk = 2411, after = TA_PAN;
+ if (talk == 2400) {
+ /* 1-5 the first time: three peashooters on the lawn for Crazy Dave's shovel lesson */
+ static const uint8_t at[3][2] = {{5, 1}, {7, 2}, {6, 3}};
+ for (int i = 0; i < 3; i++) plant_new(&B.plants[B.nplants++], P_PEASHOOTER, at[i][0], at[i][1]);
+ }
if (talk) say(talk, after);
else start_pan(0, 380, needs_choice() ? ST_CHOOSE : ST_READY);
}
@@ -257,14 +267,11 @@ static void start_play(void) {
go(ST_PLAY);
}
-/* the shovel lesson of level 1-5: three peashooters to dig up */
+/* the shovel lesson of level 1-5: the three peashooters to dig up, the lawn still till then (board_tick) */
static void shovel_lesson(void) {
- static const uint8_t at[3][2] = {{5, 1}, {7, 2}, {6, 3}};
progress.items |= ITEM_SHOVEL;
- for (int i = 0; i < 3; i++) plant_new(&B.plants[B.nplants++], P_PEASHOOTER, at[i][0], at[i][1]);
B.tutorial = 4;
B.phase = PH_PLAY;
- B.started = 0;
hud.shovel = true;
go(ST_PLAY);
}
@@ -299,7 +306,7 @@ static void play_input(void) {
if (board_collect(cx, cy, 52)) {
if (B.tutorial == 1 && B.level == 1) {}
}
- for (int n = 1; n <= 10; n++) {
+ for (int n = 1; n <= 10 && B.tutorial != 4; n++) {
if (!hit(K_DIGIT(n))) continue;
int slot = n - 1;
hud.shovel = false;
@@ -579,7 +586,8 @@ void game_frame(uint32_t keys) {
bool left = false;
for (int i = 0; i < B.nplants; i++) left |= B.plants[i].health > 0;
if (!left) {
- B.tutorial = 0, B.nplants = 0, hud.shovel = false;
+ /* (the bowling starts from its first tick: zombies, the belt, the rolling nuts) */
+ B.tutorial = 0, B.nplants = 0, B.started = 1, B.ticks = 0, hud.shovel = false;
say(2410, TA_BOWL);
}
break;
@@ -1089,7 +1097,8 @@ void game_draw(void) {
case ST_READY:
draw_lawn(true);
hud_draw(false);
- draw_ready(state_t);
+ /* (Wall-nut Bowling starts as Crazy Dave leaves, without "Ready... Set... PLANT!") */
+ if (B.mode != MODE_BOWLING) draw_ready(state_t);
break;
case ST_PLAY:
draw_lawn(true);
diff --git a/games/pvz/tests/check.py b/games/pvz/tests/check.py
index 7793503f..96024c5c 100644
--- a/games/pvz/tests/check.py
+++ b/games/pvz/tests/check.py
@@ -1,7 +1,9 @@
#!/usr/bin/env python3
"""Checks of Plants vs. Zombies on a computer (make test): the host build, with AddressSanitizer and UBSan,
through the first start, a level kept by Home and continued, the saves coming back from pvz_saves.py, every
-screen pressed through, a level lost, and every level of the Adventure played by a robot (tests/play.c --sim).
+screen pressed through, a level lost, Wall-nut Bowling (1-5) played with the keys to the end, the conveyor-belt
+levels and the mini-games started through their screens, and every level of the Adventure played by a robot
+(tests/play.c --bot and --sim).
python3 tests/check.py build/play [--quick]
@@ -101,6 +103,60 @@ try:
["--progress", str(prog), "--money", "60000"])
shutil.rmtree(tour, ignore_errors=True)
+ # Wall-nut Bowling, played with the keys through its screens (issue #248: after the shovel lesson the zombies
+ # never came and the nuts didn't roll). The first time, from a save at 1-5 and from 1-1 through 1-4: Crazy Dave
+ # with three peashooters on the lawn, the shovel lesson (no red line, no belt yet), "We're going BOWLING!", the
+ # zombies 2 seconds in, the belt, nuts rolling and bouncing, a cone knocked off (no more), the explode-o-nut, the
+ # huge wave, its flag, the final wave, won and the potato mine found. Then 1-5 again from Choose a Level
+ def bot(saves_dir, what, args, frames=150000):
+ out = run(["--saves", saves_dir, "--out", saves_dir, "--frames", str(frames)] + args, what)
+ m = re.search(r"^bot (\w+) (.*)$", out or "", re.M)
+ if not m:
+ failures.append(f"{what}: no bot line\n{(out or '')[-500:]}")
+ return None, None
+ f = m.group(2).split()
+ return m.group(1), dict(zip(f[::2], map(int, f[1::2]))) | {"end": end_state(out, what)}
+
+ def bowled(b, what, first):
+ want = dict(dave=1, line_dave=0 if first else 1, lesson=int(first), line_lesson=0, belt_lesson=0, line_play=1,
+ explodenuts=1, cones=1, flag=1)
+ for k, v in want.items():
+ check(b[k] == v, f"{what}: {k} {b[k]}, not {v}: {b}")
+ check(0 < b["first_zombie"] <= 250, f"{what}: the first zombie came {b['first_zombie']} ticks in: {b}")
+ check(b["rolled"] >= 20 and b["bounced"] >= 5 and b["exploded"] >= 1, f"{what}: the nuts: {b}")
+ check(b["huge"] >= 1 and b["final"] >= 1, f"{what}: no huge wave or final wave: {b}")
+ e = b["end"]
+ check(e and e["progress"] == 6 and e["wave"] == e["waves"] == 8, f"{what}: not all 8 waves, or 1-6 not open: {e}")
+
+ for prog, extra, what in ((5, [], "1-5 from a save at it"), (1, [], "1-1 to 1-5 played"),
+ (6, ["--replay"], "1-5 from Choose a Level")):
+ d = tempfile.mkdtemp(prefix="pvz_bowl_")
+ how, b = bot(d, what, ["--progress", str(prog), "--bot", "5"] + extra)
+ if b:
+ check(how == "won", f"{what}: {how} {b}")
+ if how == "won":
+ bowled(b, what, prog != 6)
+ shutil.rmtree(d, ignore_errors=True)
+
+ # 1-5 kept by Home as NumPlay 1.17.0 left it, standing still after the lesson: Continue brings it back going
+ d = tempfile.mkdtemp(prefix="pvz_stall_")
+ how, b = bot(d, "1-5 kept standing", ["--progress", "5", "--bot", "5", "--stall-home"])
+ if b:
+ check(b["stalled"] == 1 and b["end"] and b["end"]["running"] == 0, f"1-5 kept standing: not kept {b}")
+ how, b = bot(d, "1-5 kept standing, continued", ["--bot", "5"], 60000)
+ if b:
+ check(how == "won" and b["came"] == 1, f"1-5 kept standing, continued: {how} {b}")
+ shutil.rmtree(d, ignore_errors=True)
+
+ # the conveyor-belt levels and the mini-games, the first time through their screens (Crazy Dave, the street,
+ # "Ready... Set... PLANT!"): the zombies come and the level ends, won or lost (the robot loses a few)
+ for level in (10, 15, 20, 25, 30, 35, 40, 45, 50) if not QUICK else (10, 15, 35):
+ d = tempfile.mkdtemp(prefix="pvz_kind_")
+ how, b = bot(d, f"level {level} through its screens", ["--progress", str(level), "--bot", str(level)], 200000)
+ if b:
+ check(how in ("won", "lost") and b["came"] == 1, f"level {level} through its screens: {how} {b}")
+ shutil.rmtree(d, ignore_errors=True)
+
# every level, a robot planting (with all the sun it wants): it must not crash, and win nearly all of them
levels = [1, 5, 10, 15, 20, 25, 30, 35, 41, 45, 49, 50] if QUICK else range(1, 51)
won = 0
diff --git a/games/pvz/tests/play.c b/games/pvz/tests/play.c
index 4c28e8fb..f3510bad 100644
--- a/games/pvz/tests/play.c
+++ b/games/pvz/tests/play.c
@@ -3,6 +3,7 @@
* play [--frames N] [--keys "10-40:right,50:ok,..."] [--shots 30,60|every:N] [--out DIR] [--saves DIR]
* [--progress L] [--money M]
* play --sim L [--frames N] [--shots ...] [--out DIR] [--quiet]
+ * play --bot L [--progress P] [--replay] [--stall-home] [--frames N] [--saves DIR] (see "the player" below)
* ... [--raw DIR --raw-from T --raw-to T] [--sun-from T]
*
* Keys: left right up down ok back shovel home almanac 0-9. "a-b:key" holds the key from tick a to b, "a:key" for
@@ -290,6 +291,119 @@ static void robot(void) {
}
}
+/* ---------------------------------------------------------------- the player (--bot) */
+
+/* --bot L: the Adventure through its screens, keys pressed as a player would, until level L is won or lost: OK through the
+ * title, the menu, Crazy Dave and the rewards; on the lawn the robot above plants, but Wall-nut Bowling is played with
+ * the keys (the shovel lesson, then a nut picked from the belt, the cursor to its row, OK). --replay: level L from
+ * Choose a Level. --stall-home: in 1-5's bowling, the lawn left standing as NumPlay 1.17.0 and earlier left it after the
+ * shovel lesson, and Home (the next start must bring the level back going). */
+static int bot_level, bot_replay, bot_stall, bot_done;
+static int bot_prev = -1, bot_t, bot_n;
+static struct {
+ int dave, line_dave, lesson, line_lesson, belt_lesson, play_t0, line_play, first_zombie, belt, explodenuts;
+ int bounced, exploded, cones, huge, final, flag, stalled, came;
+ uint16_t bounce_ids[64];
+} bw;
+
+static uint32_t step_to(int col, int row) {
+ return hud.col < col ? K_RIGHT : hud.col > col ? K_LEFT : hud.row < row ? K_DOWN : hud.row > row ? K_UP : 0;
+}
+
+static uint32_t bot_bowl(int t) {
+ if (B.tutorial == 4) {
+ /* the shovel lesson: the shovel, then each peashooter */
+ if (!hud.shovel) return K_SHOVEL;
+ for (int i = 0; i < B.nplants; i++)
+ if (B.plants[i].health > 0) {
+ uint32_t k = step_to(B.plants[i].col, B.plants[i].row);
+ return k ? k : K_OK;
+ }
+ return 0;
+ }
+ if (bot_stall && B.wave >= 1) {
+ B.started = 0, bw.stalled = 1;
+ return K_HOME;
+ }
+ /* the zombie nearest the house: a nut down its row (or, the belt full, down the rows in turn) */
+ const Zombie *near = NULL;
+ int alive = 0;
+ for (int i = 0; i < B.nzombies; i++) {
+ const Zombie *z = &B.zombies[i];
+ if (z->health <= 0 || (z->flags & ZF_HYPNO) || z->x > 760) continue;
+ alive++;
+ if (!near || z->x < near->x) near = z;
+ }
+ int row = near ? near->row : B.npackets >= 8 ? t / 60 % B.nrows : -1;
+ if (row < 0 || !B.npackets) return 0;
+ if (hud.selected < 0) {
+ int pick = -1;
+ for (int i = 0; i < B.npackets && pick < 0; i++)
+ if (B.packets[i].kind == (alive >= 3 ? P_EXPLODENUT : P_WALLNUT)) pick = i;
+ return K_DIGIT((pick < 0 ? 0 : pick) + 1);
+ }
+ uint32_t k = step_to(2, row);
+ return k ? k : K_OK;
+}
+
+static uint32_t bot_keys(int t) {
+ if (g_state != bot_prev) bot_prev = g_state, bot_t = 0, bot_n = 0;
+ else bot_t++;
+ /* (the robot plants every tick, the keys are pressed one at a time) */
+ if (g_state == ST_PLAY && B.mode != MODE_BOWLING) robot();
+ if (t % 6) return 0;
+ uint32_t k = 0;
+ switch (g_state) {
+ case ST_TITLE: case ST_HELP: case ST_DAVE: case ST_PAUSE: k = K_OK; break;
+ case ST_MENU: k = bot_replay && !board_saved() && bot_n == 0 ? K_DOWN : K_OK; break;
+ case ST_LEVELS: k = bot_n < progress.level - bot_level ? K_LEFT : K_OK; break;
+ case ST_CHOOSE: bot_done = -2; break; /* (the levels with a seed choice aren't the player's) */
+ case ST_PLAY: k = B.mode == MODE_BOWLING ? bot_bowl(t) : 0; break;
+ case ST_WON: k = bot_t > 70 ? K_OK : 0; break;
+ case ST_AWARD:
+ if (B.level >= bot_level) bot_done = 1;
+ else k = bot_t > 50 ? K_OK : 0;
+ break;
+ case ST_LOST: bot_done = -1; break;
+ }
+ bot_n++;
+ return k;
+}
+
+/* what 1-5 showed, after each tick */
+static void bot_watch(int t) {
+ /* (on every level: the zombies came) */
+ if (g_state == ST_PLAY && B.level == bot_level && B.nzombies) bw.came = 1;
+ if (B.mode != MODE_BOWLING) return;
+ if (g_state == ST_DAVE && !bw.dave) bw.dave = 1, bw.line_dave = bowling_line();
+ if (g_state != ST_PLAY) return;
+ if (B.tutorial == 4) {
+ bw.lesson = 1, bw.line_lesson |= bowling_line(), bw.belt_lesson |= B.nrollers > 0;
+ return;
+ }
+ if (!bw.play_t0) bw.play_t0 = t, bw.line_play = 1;
+ bw.line_play &= bowling_line();
+ if (B.nzombies && !bw.first_zombie) bw.first_zombie = t - bw.play_t0;
+ if (B.npackets > bw.belt) bw.belt = B.npackets;
+ for (int i = 0; i < B.npackets; i++) bw.explodenuts |= B.packets[i].kind == P_EXPLODENUT;
+ for (int i = 0; i < B.nrollers; i++) {
+ if (!B.rollers[i].dir) continue;
+ bool seen = false;
+ for (int k = 0; k < 64; k++) seen |= bw.bounce_ids[k] == B.rollers[i].id;
+ if (!seen) bw.bounce_ids[bw.bounced++ % 64] = B.rollers[i].id;
+ }
+ for (int i = 0; i < B.nfx; i++) {
+ const Fx *f = &B.fx[i];
+ if (f->t) continue;
+ bw.exploded += f->kind == FX_BOOM, bw.huge += f->kind == FX_TEXT && f->v == 0, bw.final += f->kind == FX_TEXT && f->v == 2;
+ }
+ for (int i = 0; i < B.nzombies; i++) {
+ const Zombie *z = &B.zombies[i];
+ bw.flag |= z->kind == Z_FLAG;
+ bw.cones |= z->kind == Z_CONE && z->armor == 0 && z->health > 0; /* (a nut knocks the cone off, no more) */
+ }
+}
+
static int sim(int level, int frames, const char *out, bool quiet) {
progress_load();
progress.level = (uint8_t)level, progress.slots = 10, progress.items = 0x7F;
@@ -361,6 +475,9 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--raw-from") && i + 1 < argc) raw_from = atoi(argv[++i]);
else if (!strcmp(argv[i], "--raw-to") && i + 1 < argc) raw_to = atoi(argv[++i]);
else if (!strcmp(argv[i], "--sun-from") && i + 1 < argc) sun_from = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "--bot") && i + 1 < argc) bot_level = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "--replay")) bot_replay = 1;
+ else if (!strcmp(argv[i], "--stall-home")) bot_stall = 1;
}
mkdir(out, 0755);
mkdir(saves, 0755);
@@ -389,12 +506,14 @@ int main(int argc, char **argv) {
}
}
if (money >= 0) progress.money = (uint32_t)money;
- for (int t = 0; t < frames && g_running; t++) {
- host_keys = 0;
+ int t;
+ for (t = 0; t < frames && g_running && !bot_done; t++) {
+ host_keys = bot_level ? bot_keys(t) : 0;
for (int i = 0; i < nholds; i++)
if (t >= holds[i].a && t <= holds[i].b) host_keys |= holds[i].k;
if (host_keys) host_keys |= K_ANY;
game_frame(host_keys);
+ if (bot_level) bot_watch(t);
host_time += 10;
if (t % 3 == 0 || shot_now(t)) game_draw();
if (raw_now(t)) raw_frame(t);
@@ -407,5 +526,12 @@ int main(int argc, char **argv) {
printf("state %d level %d phase %d sun %d zombies %d plants %d wave %d/%d progress %d money %u slots %d items %d "
"running %d\n", g_state, B.level, B.phase, (int)B.sun, B.nzombies, B.nplants, B.wave, B.nwaves, progress.level,
(unsigned)progress.money, progress.slots, progress.items, g_running);
+ if (bot_level)
+ printf("bot %s ticks %d dave %d line_dave %d lesson %d line_lesson %d belt_lesson %d line_play %d first_zombie %d "
+ "belt %d explodenuts %d rolled %d bounced %d exploded %d cones %d huge %d final %d flag %d stalled %d came %d\n",
+ bot_done == 1 ? "won" : bot_done == -1 ? "lost" : bot_done == -2 ? "choose" : "unfinished", t, bw.dave,
+ bw.line_dave, bw.lesson, bw.line_lesson, bw.belt_lesson, bw.line_play, bw.first_zombie, bw.belt,
+ bw.explodenuts, B.mode == MODE_BOWLING ? B.planted : 0, bw.bounced, bw.exploded, bw.cones, bw.huge, bw.final,
+ bw.flag, bw.stalled, bw.came);
return 0;
}