summaryrefslogtreecommitdiffstats
path: root/wump
diff options
context:
space:
mode:
authorgarbled <garbled@NetBSD.org>2006-01-19 21:20:35 +0000
committergarbled <garbled@NetBSD.org>2006-01-19 21:20:35 +0000
commit9117ffa747e07c4209c5f3f152571da2652489b0 (patch)
tree9f46ed08f8642c4fdeee407a60bfa1f0d5cd124a /wump
parent3ea04edd077e8bb119ecace2bc5302312f05722b (diff)
downloadbsdgames-darwin-9117ffa747e07c4209c5f3f152571da2652489b0.tar.gz
bsdgames-darwin-9117ffa747e07c4209c5f3f152571da2652489b0.tar.zst
bsdgames-darwin-9117ffa747e07c4209c5f3f152571da2652489b0.zip
Fix some minor buglets in wump:
1) Don't put two pits in the same room. 2) Don't put bats and pits in the same room. (you will never hit the bat) 3) Don't start the player in a room with a pit or bad, if possible. Some caves are so crowded the loop may go on forever, so we give up after 100 tries to put them in a safe location (as long as it's not with the wumpus). 4) Make the manpage reflect reality WRT the default number of rooms. Bug #3 pointed out by salo.
Diffstat (limited to 'wump')
-rw-r--r--wump/wump.64
-rw-r--r--wump/wump.c14
2 files changed, 11 insertions, 7 deletions
diff --git a/wump/wump.6 b/wump/wump.6
index 67ae2c30..f2e928c3 100644
--- a/wump/wump.6
+++ b/wump/wump.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: wump.6,v 1.6 2003/08/07 09:37:57 agc Exp $
+.\" $NetBSD: wump.6,v 1.7 2006/01/19 21:20:35 garbled Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -74,7 +74,7 @@ Specifies the number of rooms in the cave which contain bottomless pits.
The default is three.
.It Fl r
Specifies the number of rooms in the cave.
-The default cave size is twenty-five rooms.
+The default cave size is twenty rooms.
.It Fl t
Specifies the number of tunnels connecting each room in the cave to
another room.
diff --git a/wump/wump.c b/wump/wump.c
index 4754146c..1cff6dbc 100644
--- a/wump/wump.c
+++ b/wump/wump.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wump.c,v 1.19 2006/01/19 20:15:31 garbled Exp $ */
+/* $NetBSD: wump.c,v 1.20 2006/01/19 21:20:35 garbled Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: wump.c,v 1.19 2006/01/19 20:15:31 garbled Exp $");
+__RCSID("$NetBSD: wump.c,v 1.20 2006/01/19 21:20:35 garbled Exp $");
#endif
#endif /* not lint */
@@ -643,7 +643,7 @@ initialize_things_in_cave()
for (i = 0; i < pit_num; ++i) {
do {
loc = (random() % room_num) + 1;
- } while (cave[loc].has_a_pit && cave[loc].has_a_bat);
+ } while (cave[loc].has_a_pit || cave[loc].has_a_bat);
cave[loc].has_a_pit = 1;
#ifdef DEBUG
if (debug)
@@ -657,10 +657,14 @@ initialize_things_in_cave()
(void)printf("<wumpus in room %d>\n", loc);
#endif
+ i = 0;
do {
player_loc = (random() % room_num) + 1;
- } while (player_loc == wumpus_loc || (level == HARD ?
- (link_num / room_num < 0.4 ? wump_nearby() : 0) : 0));
+ i++;
+ } while (player_loc == wumpus_loc || cave[player_loc].has_a_pit ||
+ cave[player_loc].has_a_bat || (level == HARD ?
+ (link_num / room_num < 0.4 ? wump_nearby() : 0) : 0) ||
+ (i > 100 && player_loc != wumpus_loc));
}
int