Article View: net.games
Article #2462Re: Battleship source for Unix w/curses
From: mcewan
Date: Thu, 27 Mar 1986 18:41
Date: Thu, 27 Mar 1986 18:41
20 lines
1470 bytes
1470 bytes
>>> My problem, however, is with the pattern that the ships are set up in.
>>> The first time you play the game (every time you play it) the pattern that
>>> the ships are in is identical.
>
>> That's easy. Just insert a "srand(getpid());" somewhere in the beginning
>> of the program, before the first "rand" call.
>
> That'll still have the same problem. getpid() will return the same pid
> each time the same user runs it, thus you would get the same seed for
> rand each time. Try srand(time()); instead.
Well, this may be true for you, in which case you have a very weird operating
system, but around here different processes have different process IDs.
Scott McEwan
{ihnp4,pur-ee}!uiucdcs!mcewan
Green s/m watchlizard seeks s/f/wl - object: companionship. Reply
Box 23, Cynosure.
Technical Details
Message-ID:
<9200034@uiucdcs>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!inuxc!pur-ee!uiucdcs!mcewanReferences:
<314@drivax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site uiucdcs Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!inuxc!pur-ee!uiucdcs!mcewan From: mcewan@uiucdcs.CS.UIUC.EDU Newsgroups: net.games Subject: Re: Battleship source for Unix w/curses Message-ID: <9200034@uiucdcs> Date: Thu, 27-Mar-86 13:41:00 EST Article-I.D.: uiucdcs.9200034 Posted: Thu Mar 27 13:41:00 1986 Date-Received: Sat, 29-Mar-86 16:05:36 EST References: <314@drivax.UUCP> Lines: 20 Nf-ID: #R:drivax.UUCP:314:uiucdcs:9200034:000:799 Nf-From: uiucdcs.CS.UIUC.EDU!mcewan Mar 27 12:41:00 1986