Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33562

Re: Getting a seeded value from a list

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.047
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; '"as': 0.07; 'level,': 0.07; 'mentioned,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Getting': 0.09; 'static': 0.13; 'arrays,': 0.16; 'generated,': 0.16; 'generator.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'storing': 0.16; 'instance': 0.17; "shouldn't": 0.17; '(in': 0.18; 'examples': 0.18; 'load': 0.19; 'mostly': 0.20; 'all,': 0.21; 'trying': 0.21; '(all': 0.22; 'clock': 0.22; "i'd": 0.22; 'sets': 0.23; "i've": 0.23; 'random': 0.24; '(which': 0.26; 'setting': 0.26; 'values': 0.26; '(as': 0.27; '(such': 0.27; 'execution': 0.27; 'regular': 0.27; 'header:X-Complaints-To:1': 0.28; 'subject:list': 0.28; 'initial': 0.28; 'participant': 0.29; 'seed': 0.29; 'served': 0.29; 'usable': 0.29; 'case,': 0.29; "i'm": 0.29; 'function': 0.30; 'figure': 0.30; 'point': 0.31; 'room': 0.32; 'running': 0.32; 'could': 0.32; "aren't": 0.33; 'url:home': 0.33; 'values.': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'another': 0.33; 'entry': 0.33; "can't": 0.34; 'list': 0.35; 'nov': 0.35; 'saved': 0.35; 'sequence': 0.35; 'continue': 0.35; 'there': 0.35; 'next': 0.35; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'generation': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'level': 0.37; '(for': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'save': 0.61; 'first': 0.61; "you'll": 0.62; 'back': 0.62; 'different': 0.63; 'hello!': 0.65; 'state,': 0.65; 'restore': 0.69; 'online': 0.70; 'suited': 0.71; 'saving': 0.72; 'competition': 0.74; 'again!': 0.84; 'around,': 0.84; 'encounters': 0.84; 'entry,': 0.84; 'generation.': 0.84; 'interrupt': 0.84; 'room).': 0.84; 'subject:value': 0.84; 'tomorrow,': 0.84; 'treasure': 0.84; 'weather': 0.84; 'clueless': 0.91; 'dennis': 0.91; 'received:108': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Getting a seeded value from a list
Date Mon, 19 Nov 2012 18:31:43 -0500
Organization > Bestiaria Support Staff <
References <SNT139-W8C22F3D436702B17D7803A3560@phx.gbl>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-68-177-195.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17.1353367913.29569.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1353367913 news.xs4all.nl 6853 [2001:888:2000:d::a6]:33825
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33562

Show key headers only | View raw


On Sun, 18 Nov 2012 19:00:57 -0800, Graham Fielding
<frednotbob@hotmail.ca> declaimed the following in
gmane.comp.python.general:

> 
> 
> 
> 
> Hello!  Clueless noob again! :) This time around, I'm trying to figure out the random.seed() function -- specifically, I'd like to retrieve the seeded values from a list (which I've called levelSeed), and use them in a random-dungeon generator.  The numbers are generating and storing properly, but I can't find any examples online that aren't specific to a particular purpose (such as mathematics, arrays, and the like). Would I use 'getstate' when the dungeon is generated, or is there another method that would be better suited to the task? 		 	   		  

	The "seed" sets the initial state of the generator. After setting
the state, you just use regular random number generation to retrieve
values.

	Are you generating the entire level on entry, or as each room is
"opened" (if, "as opened", you have the complication that going down a
level and back up will result in different random numbers vs going
straight to the room).

	Generating on entry only needs the seed for the initial generation
point (as mentioned, first time you could use the system clock and save
the value).

	getstate() is likely mostly usable when you need to interrupt the
execution of the program and need to continue the random sequence from
where it left off -- but don't need to restore prior values (in your
case, prior rooms). That is: say a weather simulation... You only need
to save the current "weather matrix" (for each point: temp, wind-speed,
wind-direction [where a "point" may be lat/long/altitude]) AND the
current state of the random number generation. Tomorrow, you just load
the saved state [one instance in time] and reseed the generator.

	But for a dungeon -- you may be best served by generating the entire
level (all rooms, doors, static encounters [traps, treasure]) when
entering the level, and saving the entire dungeon (after all, after a
treasure is collected, it shouldn't re-appear the next time you start
that same level -- if you only save the starting seed, then all
encounters will also be regenerated). In this scenario, where you save
the entire dungeon, you don't even need to worry about the seed --
you'll never really want to recreate the same dungeon for another party
[unless running a competition in which case you seed every computer the
same so every participant is running the identical dungeon].
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


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