Update conways
This commit is contained in:
parent
6d31d5da98
commit
fb37c4f58b
@ -163,7 +163,7 @@ function int => printSym
|
||||
}
|
||||
else
|
||||
{
|
||||
" "
|
||||
"."
|
||||
}
|
||||
print
|
||||
}
|
||||
@ -350,5 +350,5 @@ function int int => int row
|
||||
|
||||
function int int => int coordToIndex
|
||||
{
|
||||
8 req * +
|
||||
req 8 req * +
|
||||
}
|
374
tests/conway_diehard.qbl
Normal file
374
tests/conway_diehard.qbl
Normal file
@ -0,0 +1,374 @@
|
||||
//valid,.............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// ...................#.........
|
||||
// .............##..............
|
||||
// ..............#...###........
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// --------
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// .............................
|
||||
// --------
|
||||
// :END:
|
||||
|
||||
arr field { int 841 }
|
||||
|
||||
arr field2 { int 841 }
|
||||
|
||||
13 9 coordToIndex 1 field.write
|
||||
14 9 coordToIndex 1 field.write
|
||||
14 10 coordToIndex 1 field.write
|
||||
19 8 coordToIndex 1 field.write
|
||||
18 10 coordToIndex 1 field.write
|
||||
19 10 coordToIndex 1 field.write
|
||||
20 10 coordToIndex 1 field.write
|
||||
|
||||
printArray
|
||||
|
||||
true 129
|
||||
while
|
||||
{
|
||||
// i
|
||||
iteration
|
||||
0 dup 1 > -
|
||||
}
|
||||
deq
|
||||
|
||||
printArray
|
||||
|
||||
function => iteration
|
||||
{
|
||||
true 0
|
||||
while
|
||||
{
|
||||
// y
|
||||
true 0 req
|
||||
// true x y
|
||||
while
|
||||
{
|
||||
// x y
|
||||
dup swp req
|
||||
// y x x
|
||||
dup swp
|
||||
// x y x y
|
||||
neighbourhood
|
||||
// x y c
|
||||
dup swp req
|
||||
// x y x c
|
||||
req dup swp req
|
||||
// x y x y c
|
||||
coordToIndex req req req
|
||||
// i x y c
|
||||
dup field.read
|
||||
// x y c i v
|
||||
req req req swp
|
||||
// x y c v i
|
||||
req req
|
||||
// c v i x y
|
||||
update
|
||||
// x y
|
||||
check
|
||||
req
|
||||
// lt x+1 y
|
||||
}
|
||||
// x y
|
||||
deq check
|
||||
// lt y+1
|
||||
}
|
||||
deq
|
||||
copyArrays
|
||||
}
|
||||
|
||||
function => copyArrays
|
||||
{
|
||||
true 0
|
||||
while
|
||||
{
|
||||
// 0
|
||||
dup field2.read
|
||||
dup field.write
|
||||
checkArr
|
||||
}
|
||||
deq
|
||||
}
|
||||
|
||||
function => printArray
|
||||
{
|
||||
true 0
|
||||
while
|
||||
{
|
||||
// y
|
||||
true 0 req
|
||||
// true x y
|
||||
while
|
||||
{
|
||||
// x y
|
||||
dup req dup swp
|
||||
// x y x y
|
||||
coordToIndex
|
||||
// x y i
|
||||
req req field.read
|
||||
// x y v
|
||||
req req printSym
|
||||
// x y
|
||||
check req
|
||||
// lt x+1 y
|
||||
}
|
||||
// x y
|
||||
"" deq req println check
|
||||
// lt y+1
|
||||
}
|
||||
deq
|
||||
"--------" println
|
||||
}
|
||||
|
||||
function int => printSym
|
||||
{
|
||||
// x
|
||||
1 ==
|
||||
// eq
|
||||
if
|
||||
{
|
||||
"#"
|
||||
}
|
||||
else
|
||||
{
|
||||
"."
|
||||
}
|
||||
print
|
||||
}
|
||||
|
||||
function int => bool int checkArr
|
||||
{
|
||||
// i
|
||||
1 + field.length dup
|
||||
// i+1 l i+1
|
||||
< req
|
||||
// lt i+1
|
||||
}
|
||||
|
||||
function int => bool int check
|
||||
{
|
||||
//???
|
||||
// i
|
||||
1 + 29 dup < req
|
||||
//???
|
||||
// i+1 29 i+1
|
||||
}
|
||||
|
||||
function int int int => update
|
||||
{
|
||||
// count value index
|
||||
3 dup req req req
|
||||
// 3 c c v i
|
||||
== req req req
|
||||
// eq c v i
|
||||
if
|
||||
{
|
||||
1 deq deq field2.write
|
||||
}
|
||||
else
|
||||
{
|
||||
// c v i
|
||||
2 req req req
|
||||
// 2 c v i
|
||||
== 1 req req req
|
||||
// 1 v i eq
|
||||
== req && req
|
||||
// teq i
|
||||
if
|
||||
{
|
||||
1
|
||||
}
|
||||
else
|
||||
{
|
||||
0
|
||||
}
|
||||
field2.write
|
||||
}
|
||||
}
|
||||
|
||||
function int int => int neighbourhood
|
||||
{
|
||||
// x y
|
||||
dup 1 req req -
|
||||
// x y x-1
|
||||
0 req req dup >=
|
||||
// x y x-1 ge
|
||||
req req req
|
||||
// ge x y x-1
|
||||
if
|
||||
{
|
||||
req dup swp
|
||||
// x y x-1 y
|
||||
req req
|
||||
// x-1 y x y
|
||||
row
|
||||
// x y abc
|
||||
}
|
||||
else
|
||||
{
|
||||
// x y x-1
|
||||
req req
|
||||
// x-1 x y
|
||||
deq 0
|
||||
// x y 0
|
||||
}
|
||||
dup swp req req
|
||||
// y x abc x
|
||||
dup swp req row
|
||||
// x y abc def
|
||||
req req +
|
||||
// x y abcdef
|
||||
|
||||
dup swp req req
|
||||
// y x abcdef x
|
||||
dup swp req
|
||||
// x y x y abcdef
|
||||
coordToIndex
|
||||
// x y abcdef i
|
||||
req req req
|
||||
// i x y abcdef
|
||||
field.read
|
||||
// x y abcdef v
|
||||
req req -
|
||||
// x y abcdef-v
|
||||
|
||||
1 req req req
|
||||
// 1 x y abcdef
|
||||
+ req req
|
||||
// x+1 y abcdef
|
||||
dup 29 req req req
|
||||
// x+1 l x+1 y abcdef
|
||||
< req req req
|
||||
// lt x+1 y abcdef
|
||||
if
|
||||
{
|
||||
row
|
||||
// abcdef ghi
|
||||
}
|
||||
else
|
||||
{
|
||||
deq deq 0
|
||||
// abcdef 0
|
||||
}
|
||||
+
|
||||
// abcdefghi
|
||||
}
|
||||
|
||||
function int int => int row
|
||||
{
|
||||
// x y
|
||||
1 req dup -
|
||||
// x y y-1
|
||||
dup req req
|
||||
// y-1 x x y
|
||||
0 dup swp req req
|
||||
// 0 y-1 x y-1 x y
|
||||
> req req req req
|
||||
// gt x y-1 x y
|
||||
if
|
||||
{
|
||||
deq deq 0
|
||||
// x y 0
|
||||
}
|
||||
else
|
||||
{
|
||||
// x y-1 x y
|
||||
coordToIndex req req
|
||||
// i x y
|
||||
field.read
|
||||
// x y a
|
||||
}
|
||||
// x y a
|
||||
dup swp req req
|
||||
// y x a x
|
||||
dup swp req
|
||||
// x y x y a
|
||||
coordToIndex
|
||||
// x y a i
|
||||
req req req field.read
|
||||
// x y a b
|
||||
req req +
|
||||
// x y a+b
|
||||
req 1 req
|
||||
// a+b x 1 y
|
||||
req req + req
|
||||
// x y+1 a+b
|
||||
req req 29
|
||||
// a+b x y+1 l
|
||||
req req dup
|
||||
// y+1 l a+b x y+1
|
||||
< req req req
|
||||
// lt a+b x y+1
|
||||
if
|
||||
{
|
||||
// a+b x y+1
|
||||
req coordToIndex
|
||||
// a+b i
|
||||
req field.read
|
||||
// a+b c
|
||||
}
|
||||
else
|
||||
{
|
||||
req deq deq 0
|
||||
// a+b 0
|
||||
}
|
||||
+
|
||||
// a+b+c
|
||||
}
|
||||
|
||||
function int int => int coordToIndex
|
||||
{
|
||||
// y x
|
||||
req 29 req * +
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user