Talk:Boids: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
Huh. The output of that Racket implementation just crashes my browser about half a second in. It's been a while since I've come across such a total JS implementation bug. There ''might'' be a bug in the Racket code — I've not checked, to be honest — but the browser keeling over in response is really wrong. –[[User:Dkf|Donal Fellows]] ([[User talk:Dkf|talk]]) 12:31, 25 January 2014 (UTC) |
Huh. The output of that Racket implementation just crashes my browser about half a second in. It's been a while since I've come across such a total JS implementation bug. There ''might'' be a bug in the Racket code — I've not checked, to be honest — but the browser keeling over in response is really wrong. –[[User:Dkf|Donal Fellows]] ([[User talk:Dkf|talk]]) 12:31, 25 January 2014 (UTC) |
||
: It worked find for me. Like you said, no matter what the Racked output does, the browser should not crash, so I think we should focus the blame on your browser for now (what is it, BTW?). --[[User:Ledrug|Ledrug]] ([[User talk:Ledrug|talk]]) 00:25, 26 January 2014 (UTC) |
: It worked find for me. Like you said, no matter what the Racked output does, the browser should not crash, so I think we should focus the blame on your browser for now (what is it, BTW?). --[[User:Ledrug|Ledrug]] ([[User talk:Ledrug|talk]]) 00:25, 26 January 2014 (UTC) |
||
== Python code for cave generation == |
|||
The board was generated by this simple Python code: |
|||
<lang python>from array import array |
|||
from math import hypot |
|||
nx = 85 |
|||
ny = 16 |
|||
background = '.' |
|||
foreground = '#' |
|||
mat = [array("c", background) * nx for _ in xrange(ny)] |
|||
def add_circle(mat, (cx, cy, r)): |
|||
for y in xrange(cy - r, cy + r + 1): |
|||
for x in xrange(cx - r, cx + r + 1): |
|||
if hypot(cx - x, cy - y) <= r: |
|||
if x >= 0 and x < len(mat[0]) and y >= 0 and y < len(mat): |
|||
mat[y][x] = foreground |
|||
for c in [(14, 2, 8), (nx / 2, ny / 2, 3), (nx - 17, ny - 2, 9)]: |
|||
add_circle(mat, c) |
|||
for row in mat: |
|||
print row.tostring()</lang> |