aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1997-09-24 22:55:14 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1997-09-24 22:55:14 +0000
commitd3c80dc8d227ac64a5d6763aba1f984fec06c57d (patch)
treec98fb1e1ffb1ca7096f6891d3e3e117c743dc87f /games
parenta768c2696789412f801c01cb1c56edb02d76d1e7 (diff)
downloadsrc-d3c80dc8d227ac64a5d6763aba1f984fec06c57d.tar.gz
src-d3c80dc8d227ac64a5d6763aba1f984fec06c57d.zip
Convert to random()
Notes
Notes: svn path=/head/; revision=29831
Diffstat (limited to 'games')
-rw-r--r--games/cribbage/cards.c6
-rw-r--r--games/cribbage/crib.c8
2 files changed, 6 insertions, 8 deletions
diff --git a/games/cribbage/cards.c b/games/cribbage/cards.c
index 742370a635f1..239011bb29bc 100644
--- a/games/cribbage/cards.c
+++ b/games/cribbage/cards.c
@@ -53,9 +53,7 @@ makedeck(d)
{
register int i, j, k;
- i = time(NULL);
- i = ((i & 0xff) << 8) | ((i >> 8) & 0xff) | 1;
- srand(i);
+ srandomdev();
k = 0;
for (i = 0; i < RANKS; i++)
for (j = 0; j < SUITS; j++) {
@@ -76,7 +74,7 @@ shuffle(d)
CARD c;
for (j = CARDS; j > 0; --j) {
- k = (rand() >> 4) % j; /* random 0 <= k < j */
+ k = random() % j; /* random 0 <= k < j */
c = d[j - 1]; /* exchange (j - 1) and k */
d[j - 1] = d[k];
d[k] = c;
diff --git a/games/cribbage/crib.c b/games/cribbage/crib.c
index 4f7bf5c2b3c2..23c53dfe1bbf 100644
--- a/games/cribbage/crib.c
+++ b/games/cribbage/crib.c
@@ -207,9 +207,9 @@ game()
"Cut to see whose crib it is -- low card wins? ");
getline();
}
- i = (rand() >> 4) % CARDS; /* random cut */
+ i = random() % CARDS; /* random cut */
do { /* comp cuts deck */
- j = (rand() >> 4) % CARDS;
+ j = random() % CARDS;
} while (j == i);
addmsg(quiet ? "You cut " : "You cut the ");
msgcard(deck[i], FALSE);
@@ -377,7 +377,7 @@ cut(mycrib, pos)
"How many cards down do you wish to cut the deck? ");
getline();
}
- i = (rand() >> 4) % (CARDS - pos);
+ i = random() % (CARDS - pos);
turnover = deck[i + pos];
addmsg(quiet ? "You cut " : "You cut the ");
msgcard(turnover, FALSE);
@@ -387,7 +387,7 @@ cut(mycrib, pos)
win = chkscr(&cscore, 2);
}
} else {
- i = (rand() >> 4) % (CARDS - pos) + pos;
+ i = random() % (CARDS - pos) + pos;
turnover = deck[i];
addmsg(quiet ? "I cut " : "I cut the ");
msgcard(turnover, FALSE);