Handbook
Glossary
drunken-bishop ( bytes -- board )
Vocabulary
drunken-bishop
.
private
Inputs
bytes
an
object
Outputs
board
an
object
Definition
USING:
byte-arrays
combinators
kernel
math
math.bitwise
math.order
namespaces
sequences
;
IN:
drunken-bishop.private
::
drunken-bishop
( bytes -- board )
board-width
get
:>
w
board-height
get
:>
h h
[
w
<byte-array>
]
replicate
:>
board h
2/
:>
y! w
2/
:>
x! 15 x y board
nth
set-nth
bytes
[
{
0 -2 -4 -6
}
[
shift
2
bits
{
{
0
[
-1 -1
]
}
{
1
[
-1 1
]
}
{
2
[
1 -1
]
}
{
3
[
1 1
]
}
}
case
:>
( dy dx ) dy y
+
0 h 1
-
clamp
y! dx x
+
0 w 1
-
clamp
x! x y board
nth
[
dup
14
<
[
1
+
]
when
]
change-nth
]
with
each
]
each
16 x y board
nth
set-nth
board
;