DragonFly BSD
DragonFly submit List (threaded) for 2005-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Better random ship placement for bs


From: Craig Dooley <xlnxminusx@xxxxxxxxx>
Date: Wed, 15 Jun 2005 11:54:05 -0400

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@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));
 }


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]