Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; '(at': 0.03; '21,': 0.07; 'assign': 0.07; 'nasty': 0.07; 'integers': 0.09; 'subject:Getting': 0.09; 'thread,': 0.09; 'dictionary,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "{'foo':": 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'previously': 0.18; '(or': 0.18; "i'd": 0.22; 'player': 0.23; 'random': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'select': 0.26; 'values': 0.26; 'easiest': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; 'decide': 0.28; 'usually': 0.30; 'could': 0.32; 'goes': 0.33; 'retain': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'whatever': 0.35; 'identified': 0.35; 'mapping': 0.35; 'nov': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'level.': 0.36; 'method': 0.36; 'should': 0.36; 'level': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'stay': 0.61; 'back': 0.62; 'time,': 0.62; 'levels': 0.66; 'stated': 0.69; 'absolutely': 0.84; "'foo'": 0.84; 'fresh.': 0.84; 'seeds': 0.84; 'seeds,': 0.84; 'subject:value': 0.84; '1:18': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=rN4kCx26cZ6GWl79vpWlPMZcX8yVO0aTHbRh6k8ur2Q=; b=TVhZtf7CTPqsf0wYXlXbXaWvsfqgbTr/IcVrDps33DAPUn2pvZXSOVWqEzzbU06nmi h/8tQeRdfhYfB4exoYJjhL9vU4jNu+uyOehVqRkVHL5plFgZ6VO2LkhTY4CBT1Mz6DjS AzbjfYknkvamN2JvgGXtJSKppX3236efR0WO0S0YyTVzn/ddb47n/c0c3zkC601S5NJN IJlN6/rlorFljjuTe4YewtvtPKGqPB0mFLNVXxoY1Zx3iM0CK5VjlmuOWidwutWwxShx pQKb2mYePXozguFYHbERG/XSI/1vJe3c3xmDiXI1iXLwoAdVmdEi26RnO3LNkZ0qMzsp 7fRg== MIME-Version: 1.0 In-Reply-To: <993b9303-dbca-43f1-9ff4-9677278776b1@googlegroups.com> References: <993b9303-dbca-43f1-9ff4-9677278776b1@googlegroups.com> Date: Wed, 21 Nov 2012 14:41:24 +1100 Subject: Re: Getting a seeded value from a list From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353469287 news.xs4all.nl 6945 [2001:888:2000:d::a6]:49353 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33700 On Wed, Nov 21, 2012 at 1:18 PM, wrote: > Each time the player goes from 'Foo' to 'Bar' (or vice versa), make_map r= andomly generates a new layout for either level. > > What I'd like to do is select values from 'levelSeed' and assign them to = the levels that make_map generates so that the player goes back to the same= 'Foo' and 'Bar' each time (at least until the player repopulates levelSeed= with new values by whatever method I eventually decide to use). The easiest way would be to retain a mapping of seeds, eg: seeds =3D {'Foo': 142857, 'Bar': 271828} And then you reseed the random number generator with seeds[level] each time. (If your levels are identified by consecutive integers starting from 0 or 1, you could use a list instead of a dictionary, but the same applies.) However, this still means that the player will see the exact same level regenerated every time, absolutely fresh. As previously stated in this thread, that's not usually a good thing for encounters, treasure, etc. Once some nasty critter has been killed, he should STAY killed! :) ChrisA