Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DrEO
sho
Commits
6e83a121
Commit
6e83a121
authored
Dec 16, 2019
by
johann dreo
Browse files
fix: check if bitstring neighborhood does not erase sensors
parent
9bce1e64
Changes
1
Hide whitespace changes
Inline
Side-by-side
sho/bit.py
View file @
6e83a121
...
...
@@ -63,13 +63,16 @@ def neighb_square(sol, scale, domain_width):
# Indices order is (y,x) in order to match
# coordinates of images (row,col).
if
sol
[
py
][
px
]
==
1
:
new
[
py
][
px
]
=
0
# Remove original position.
# Add a one somewhere around.
w
=
scale
//
2
*
domain_width
ny
=
np
.
random
.
randint
(
py
-
w
,
py
+
w
)
nx
=
np
.
random
.
randint
(
px
-
w
,
px
+
w
)
ny
=
min
(
max
(
0
,
ny
),
domain_width
-
1
)
nx
=
min
(
max
(
0
,
nx
),
domain_width
-
1
)
new
[
ny
][
nx
]
=
1
if
new
[
nx
][
ny
]
!=
1
:
new
[
py
][
px
]
=
0
# Remove original position.
new
[
ny
][
nx
]
=
1
# else pass
return
new
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment