From: Julian Cowley Date: Mon, 7 Mar 2022 10:40:52 +0000 (-1000) Subject: Add debugging of arrow paths X-Git-Tag: 1.8~3 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=493865da581f5d10901bad2f3e4af36217dd43cc;p=wumpus.git Add debugging of arrow paths Add debugging statements that print out the location of the arrow and the rooms it is supposed to move to. The statements use conditional compiling using the DEBUG macro. --- diff --git a/wumpus.c b/wumpus.c index 2adc696..0bb6315 100644 --- a/wumpus.c +++ b/wumpus.c @@ -334,6 +334,11 @@ badrange: { int k1; +#ifdef DEBUG + (void) printf("Location is %d, looking for tunnel to room %d\n", + scratchloc+1, path[k]+1); +#endif + /* 810 FOR K1=1 TO 3 */ for (k1 = 0; k1 < 3; k1++) { @@ -351,13 +356,16 @@ badrange: */ scratchloc = path[k]; +#ifdef DEBUG + (void) printf("Found tunnel to room %d\n", scratchloc+1); +#endif + /* this simulates logic at 895 in the BASIC code */ check_shot(); if (finished != NOT) return; goto nextpath; } - /* 820 NEXT K1 */ } @@ -365,6 +373,11 @@ badrange: /* 830 L=S(L,FNB(1)) */ scratchloc = cave[scratchloc][FNB()]; +#ifdef DEBUG + (void) printf("No tunnel for room %d, new location is %d\n", + path[k]+1, scratchloc+1); +#endif + /* 835 GOTO 900 */ check_shot(); if (finished != NOT) @@ -433,6 +446,10 @@ void move_wumpus() if (k < 3) loc[WUMPUS] = cave[loc[WUMPUS]][k]; +#ifdef DEBUG + (void) printf("Wumpus location is now room %d\n", loc[WUMPUS]+1); +#endif + /* 955 IF L(2)<>L THEN 970 */ if (loc[WUMPUS] != loc[YOU]) return;