瀏覽代碼

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

tags/v0.7.0
Fen Dweller 7 年之前
父節點
當前提交
a1908bcad5
共有 2 個檔案被更改,包括 7 行新增2 行删除
  1. +6
    -1
      recursive-macro.js
  2. +1
    -1
      stroll.html

+ 6
- 1
recursive-macro.js 查看文件

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

// for small amounts, actually do the randomness

// the first few ones get a better shot
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;
}



+ 1
- 1
stroll.html 查看文件

@@ -10,7 +10,7 @@
<body>
<div id=game-area>
<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>
<button id=button-grow>Get Bigger</button>


Loading…
取消
儲存