Compare commits
5 Commits
feedab80b8
...
093d218e79
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
093d218e79 | ||
|
|
4e47f5bf9b | ||
|
|
dd55346e98 | ||
|
|
d09545ff00 | ||
|
|
31133425f6 |
37
LICENSE
37
LICENSE
@@ -1,21 +1,24 @@
|
||||
MIT License
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Copyright (c) 2019 Rob Heaton
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
For more information, please refer to <https://unlicense.org>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
# Wavefunction Collapse
|
||||
|
||||
This is the example code for my blog post,
|
||||
"The Wavefunction Collapse Algorithm explained
|
||||
very clearly". To install dependencies:
|
||||
This is the example code for my blog post, ["The Wavefunction Collapse Algorithm explained very clearly"](https://robertheaton.com/2018/12/17/wavefunction-collapse-algorithm/). To install dependencies:
|
||||
|
||||
```
|
||||
virtualenv vendor
|
||||
source vendor/bin/active
|
||||
source vendor/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
6
main.py
6
main.py
@@ -143,13 +143,13 @@ class Wavefunction(object):
|
||||
"""
|
||||
x, y = co_ords
|
||||
opts = self.coefficients[x][y]
|
||||
valid_weights = {tile: weight for tile, weight in self.weights.iteritems() if tile in opts}
|
||||
valid_weights = {tile: weight for tile, weight in self.weights.items() if tile in opts}
|
||||
|
||||
total_weights = sum(valid_weights.values())
|
||||
rnd = random.random() * total_weights
|
||||
|
||||
chosen = None
|
||||
for tile, weight in valid_weights.iteritems():
|
||||
for tile, weight in valid_weights.items():
|
||||
rnd -= weight
|
||||
if rnd < 0:
|
||||
chosen = tile
|
||||
@@ -272,7 +272,7 @@ def render_colors(matrix, colors):
|
||||
color = colors[val]
|
||||
output_row.append(color + val + colorama.Style.RESET_ALL)
|
||||
|
||||
print "".join(output_row)
|
||||
print("".join(output_row))
|
||||
|
||||
|
||||
def valid_dirs(cur_co_ord, matrix_size):
|
||||
|
||||
Reference in New Issue
Block a user