Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33700
| References | <SNT139-W8C22F3D436702B17D7803A3560@phx.gbl> <mailman.17.1353367913.29569.python-list@python.org> <993b9303-dbca-43f1-9ff4-9677278776b1@googlegroups.com> |
|---|---|
| Date | 2012-11-21 14:41 +1100 |
| Subject | Re: Getting a seeded value from a list |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.128.1353469287.29569.python-list@python.org> (permalink) |
On Wed, Nov 21, 2012 at 1:18 PM, <frednotbob@hotmail.ca> wrote:
> Each time the player goes from 'Foo' to 'Bar' (or vice versa), make_map randomly 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 = {'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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Getting a seeded value from a list Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-19 18:31 -0500
Re: Getting a seeded value from a list frednotbob@hotmail.ca - 2012-11-19 21:45 -0800
Re: Getting a seeded value from a list frednotbob@hotmail.ca - 2012-11-19 21:45 -0800
Re: Getting a seeded value from a list Nobody <nobody@nowhere.com> - 2012-11-20 08:26 +0000
Re: Getting a seeded value from a list frednotbob@hotmail.ca - 2012-11-20 18:18 -0800
Re: Getting a seeded value from a list Chris Angelico <rosuav@gmail.com> - 2012-11-21 14:41 +1100
Re: Getting a seeded value from a list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 03:47 +0000
Re: Getting a seeded value from a list Chris Angelico <rosuav@gmail.com> - 2012-11-21 15:00 +1100
RE: Getting a seeded value from a list "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-23 16:27 +0000
Re: Getting a seeded value from a list Chris Angelico <rosuav@gmail.com> - 2012-11-24 09:32 +1100
RE: Getting a seeded value from a list "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-26 20:17 +0000
Re: Getting a seeded value from a list Hans Mulder <hansmu@xs4all.nl> - 2012-11-27 02:01 +0100
Re: Getting a seeded value from a list Chris Angelico <rosuav@gmail.com> - 2012-11-27 07:24 +1100
Re: Getting a seeded value from a list frednotbob@hotmail.ca - 2012-11-20 18:18 -0800
Re: Getting a seeded value from a list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 03:37 +0000
csiph-web