Browse Source

Added higher chance for the first few of something to be picked

tags/v0.7.0
Fen Dweller 7 years ago
parent
commit
a1908bcad5
2 changed files with 7 additions and 2 deletions
  1. +6
    -1
      recursive-macro.js
  2. +1
    -1
      stroll.html

+ 6
- 1
recursive-macro.js View File

@@ -58,8 +58,13 @@ function fill_area2(area, weights = {"Person": 0.1, "Car": 0.05, "House": 0.1})
var count = 0; var count = 0;


// for small amounts, actually do the randomness // for small amounts, actually do the randomness

// the first few ones get a better shot
while (limit > 0) { while (limit > 0) {
count += Math.random() < candidate.weight ? 1 : 0;
if (limit <= 3)
count += Math.random() < (1 - Math.pow((1 - candidate.weight),2)) ? 1 : 0;
else
count += Math.random() < candidate.weight ? 1 : 0;
--limit; --limit;
} }




+ 1
- 1
stroll.html View File

@@ -10,7 +10,7 @@
<body> <body>
<div id=game-area> <div id=game-area>
<div id=log> <div id=log>
<div>Welcome to Stroll 0.1.0</div>
<div>Welcome to Stroll 0.1.1</div>
<div>It's a nice day for a walk</div> <div>It's a nice day for a walk</div>
</div> </div>
<button id=button-grow>Get Bigger</button> <button id=button-grow>Get Bigger</button>


Loading…
Cancel
Save