Better random ship placement for bs
Craig Dooley
xlnxminusx at gmail.com
Wed Jun 15 08:56:04 PDT 2005
bs places the starting point of ships of length x between 0 and 10 -
x. This patch allows them to be anywhere on the board, more evenly
spreading the ships.
--
-----------------------------------------------------------------------
Craig Dooley <xlnxminusx at xxxxxxxxx>
Index: bs.c
===================================================================
RCS file: /home/dcvs/src/games/bs/bs.c,v
retrieving revision 1.5
diff -u -r1.5 bs.c
--- bs.c 15 Mar 2005 20:53:37 -0000 1.5
+++ bs.c 15 Jun 2005 11:43:31 -0000
@@ -303,12 +303,9 @@
static void
randomplace(int b, ship_t *ss)
{
- int bwidth = BWIDTH - ss->length;
- int bdepth = BDEPTH - ss->length;
-
do {
- ss->y = rnd(bdepth);
- ss->x = rnd(bwidth);
+ ss->y = rnd(BDEPTH);
+ ss->x = rnd(BWIDTH);
ss->dir = rnd(2) ? E : S;
} while (!checkplace(b, ss, FALSE));
}
More information about the Submit
mailing list