0
$\begingroup$

I am writing some code to generate 2D polygonal creatures based on 2 arguments: number of edges and a seed. Using the seed and the iterative function, i generate a sequence of radius which defines the position of the corners of the polygon (rotating them around the "center" of the creature). Seed and number of edges will be part of the "genetic code" of the creature, small difference should result in small changes.

  1. So what i would need is something that takes and argument between 0 and 1 and returns a number between 0 and 1.
  2. AND for close seeds (i.e. 0.2399 and 0.2400) the output numbers should be close too (but not simply shifted)
  3. Lastly, a linear combination of seeds should give a linear combination of results(or at least something close to it)

Do you know any function like this? It does not have to be a super good pseudo random generator (point 3 would be nice but not essential)

$\endgroup$
4
  • $\begingroup$ Does my edit differ from your intended meaning? If not, feel free to roll it back! $\endgroup$
    – Trebor
    Commented Sep 24, 2021 at 13:44
  • $\begingroup$ @Trebor thank you it is improved :) Only thing i would remove is the tag polygons, since the question is a bit more general than the specific case $\endgroup$
    – Blucenere
    Commented Sep 26, 2021 at 20:10
  • $\begingroup$ I'm not sure but I think you can do it by clicking the 'edit' button at the bottom of your question text. $\endgroup$
    – Trebor
    Commented Sep 27, 2021 at 0:48
  • $\begingroup$ @Trebor yep, done $\endgroup$
    – Blucenere
    Commented Sep 27, 2021 at 10:26

1 Answer 1

0
$\begingroup$

I don't think you can have condition 3 together with 1+2, but a simple way to achieve 1+2 is to use an existing rng, and for each seed, return an average of the output of this seed and nearby seeds (as small a resolution as desired). That will assure that nearby seeds give similar results. You can play with the averaging using weights etc.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .