Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
94
Task/Wireworld/EasyLang/wireworld.easy
Normal file
94
Task/Wireworld/EasyLang/wireworld.easy
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
sys topleft
|
||||
global m[] nc .
|
||||
background 777
|
||||
#
|
||||
proc show . .
|
||||
clear
|
||||
scale = 100 / nc
|
||||
sz = scale * 0.95
|
||||
for i to len m[]
|
||||
x = (i - 1) mod nc
|
||||
y = (i - 1) div nc
|
||||
move x * scale y * scale
|
||||
if m[i] = 0
|
||||
color 000
|
||||
elif m[i] = 1
|
||||
color 980
|
||||
elif m[i] = 2
|
||||
color 338
|
||||
else
|
||||
color 833
|
||||
.
|
||||
rect sz sz
|
||||
.
|
||||
.
|
||||
proc read . .
|
||||
s$ = input
|
||||
nc = len s$ + 2
|
||||
for i to nc
|
||||
m[] &= 0
|
||||
.
|
||||
repeat
|
||||
m[] &= 0
|
||||
for c$ in strchars s$
|
||||
if c$ = "."
|
||||
m[] &= 1
|
||||
elif c$ = "H"
|
||||
m[] &= 2
|
||||
elif c$ = "t"
|
||||
m[] &= 3
|
||||
else
|
||||
m[] &= 0
|
||||
.
|
||||
.
|
||||
for i to nc - len s$ - 1
|
||||
m[] &= 0
|
||||
.
|
||||
s$ = input
|
||||
until s$ = ""
|
||||
.
|
||||
for i to nc
|
||||
m[] &= 0
|
||||
.
|
||||
.
|
||||
read
|
||||
#
|
||||
len mn[] len m[]
|
||||
#
|
||||
proc update . .
|
||||
for i to len m[]
|
||||
if m[i] = 2
|
||||
mn[i] = 3
|
||||
elif m[i] = 3
|
||||
mn[i] = 1
|
||||
elif m[i] = 1
|
||||
s = 0
|
||||
for dx = -1 to 1
|
||||
for dy = -1 to 1
|
||||
ix = i + dy * nc + dx
|
||||
s += if m[ix] = 2
|
||||
.
|
||||
.
|
||||
if s = 2 or s = 1
|
||||
mn[i] = 2
|
||||
else
|
||||
mn[i] = 1
|
||||
.
|
||||
.
|
||||
.
|
||||
swap mn[] m[]
|
||||
.
|
||||
on timer
|
||||
update
|
||||
show
|
||||
timer 0.5
|
||||
.
|
||||
show
|
||||
timer 0.5
|
||||
#
|
||||
input_data
|
||||
tH.........
|
||||
. .
|
||||
...
|
||||
. .
|
||||
Ht.. ......
|
||||
|
|
@ -50,7 +50,7 @@ wireWorldRuleSet = new RuleSet
|
|||
{
|
||||
^ conductor
|
||||
}
|
||||
:{
|
||||
!{
|
||||
^ cell
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ sealed class Model
|
|||
|
||||
constructor load(string stateString, int maxX, int maxY)
|
||||
{
|
||||
var strings := stateString.splitBy(newLineConstant).selectBy:(s => s.toArray()).toArray();
|
||||
var strings := stateString.splitBy(newLineConstant).selectBy::(s => s.toArray()).toArray();
|
||||
|
||||
theSpace := IntMatrixSpace.allocate(maxX, maxY, RuleSet
|
||||
{
|
||||
|
|
@ -135,7 +135,7 @@ sealed class Model
|
|||
public program()
|
||||
{
|
||||
Model model := Model.load(sample,10,30);
|
||||
for(int i := 0, i < 10, i += 1)
|
||||
for(int i := 0; i < 10; i += 1)
|
||||
{
|
||||
console.printLineFormatted("Iteration {0}",i);
|
||||
model.print().run()
|
||||
|
|
|
|||
10
Task/Wireworld/F-Sharp/wireworld.fs
Normal file
10
Task/Wireworld/F-Sharp/wireworld.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Wireworld. Nigel Galloway: January 22nd., 2024
|
||||
type Cell= |E |T |H |C
|
||||
let n=array2D [[T;H;C;C;C;C;C;C;C;C;C];
|
||||
[C;E;E;E;C;E;E;E;E;E;E];
|
||||
[E;E;E;C;C;C;E;E;E;E;E];
|
||||
[C;E;E;E;C;E;E;E;E;E;E];
|
||||
[H;T;C;C;E;C;C;C;C;C;C]]
|
||||
let fG n g=match n|>Seq.sumBy(fun n->match Array2D.get g (fst n) (snd n) with H->1 |_->0) with 1 |2->H |_->C
|
||||
let fX i=i|>Array2D.mapi(fun n g->function |E->E |H->T |T->C |C->fG (Seq.allPairs [max 0 (n-1)..min (n+1) (Array2D.length1 i-1)] [max 0 (g-1)..min (g+1) (Array2D.length2 i-1)]) i)
|
||||
Seq.unfold(fun n->Some(n,fX n))n|>Seq.take 15|>Seq.iteri(fun n g->printfn "%d:\n%A\n" n g)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import "/fmt" for Fmt
|
||||
import "/ioutil" for FileUtil, Stdin
|
||||
import "./fmt" for Fmt
|
||||
import "./ioutil" for FileUtil, Stdin
|
||||
|
||||
var rows = 0 // extent of input configuration
|
||||
var cols = 0 // """
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue