Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -52,7 +52,7 @@ F world2string(ww)
V ww = readfile(w.split("\n"))
L(gen) 10
L(gen) 0.<10
print(("\n#3 ".format(gen))(= * (ww.w - 4))"\n")
print(world2string(ww))
ww = nextgen(ww)

View file

@ -1,66 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Wireworld is
type Cell is (' ', 'H', 't', '.');
type Board is array (Positive range <>, Positive range <>) of Cell;
-- Perform one transition of the cellular automation
procedure Wireworld (State : in out Board) is
function "abs" (Left : Cell) return Natural is
begin
if Left = 'H' then
return 1;
else
return 0;
end if;
end "abs";
Above : array (State'Range (2)) of Cell := (others => ' ');
Left : Cell := ' ';
Current : Cell;
begin
for I in State'First (1) + 1..State'Last (1) - 1 loop
for J in State'First (2) + 1..State'Last (2) - 1 loop
Current := State (I, J);
case Current is
when ' ' =>
null;
when 'H' =>
State (I, J) := 't';
when 't' =>
State (I, J) := '.';
when '.' =>
if abs Above ( J - 1) + abs Above ( J) + abs Above ( J + 1) +
abs Left + abs State (I, J + 1) +
abs State (I + 1, J - 1) + abs State (I + 1, J) + abs State (I + 1, J + 1)
in 1..2 then
State (I, J) := 'H';
else
State (I, J) := '.';
end if;
end case;
Above (J - 1) := Left;
Left := Current;
end loop;
end loop;
end Wireworld;
-- Print state of the automation
procedure Put (State : Board) is
begin
for I in State'First (1) + 1..State'Last (1) - 1 loop
for J in State'First (2) + 1..State'Last (2) - 1 loop
case State (I, J) is
when ' ' => Put (' ');
when 'H' => Put ('H');
when 't' => Put ('t');
when '.' => Put ('.');
end case;
end loop;
New_Line;
end loop;
end Put;
Oscillator : Board := (" ", " tH ", " . .... ", " .. ", " ");
begin
for Step in 0..9 loop
Put_Line ("Step" & Integer'Image (Step) & " ---------"); Put (Oscillator);
Wireworld (Oscillator);
end loop;
end Test_Wireworld;

View file

@ -1,102 +0,0 @@
$ww = ""
$ww &= "tH........." & @CR
$ww &= ". . " & @CR
$ww &= " ... " & @CR
$ww &= ". . " & @CR
$ww &= "Ht.. ......"
$rows = StringSplit($ww, @CR)
$cols = StringSplit($rows[1], "")
Global $Wireworldarray[$rows[0]][$cols[0]]
For $I = 1 To $rows[0]
$cols = StringSplit($rows[$I], "")
For $k = 1 To $cols[0]
$Wireworldarray[$I - 1][$k - 1] = $cols[$k]
Next
Next
Wireworld($Wireworldarray)
Func Wireworld($array)
Local $labelarray = $array
Local $Top = 0, $Left = 0
$hFui = GUICreate("Wireworld", UBound($array, 2) * 25, UBound($array) * 25)
For $I = 0 To UBound($array) - 1
For $k = 0 To UBound($array, 2) - 1
Switch $array[$I][$k]
Case "t" ; Tail
$labelarray[$I][$k] = GUICtrlCreateButton("", $Left, $Top, 25, 25)
GUICtrlSetBkColor($labelarray[$I][$k], 0xFF0000)
Case "h" ; Head
$labelarray[$I][$k] = GUICtrlCreateButton("", $Left, $Top, 25, 25)
GUICtrlSetBkColor($labelarray[$I][$k], 0x0000FF)
Case "." ; Conductor
$labelarray[$I][$k] = GUICtrlCreateButton("", $Left, $Top, 25, 25)
GUICtrlSetBkColor($labelarray[$I][$k], 0xFFFF00)
Case " " ; Empty
$labelarray[$I][$k] = GUICtrlCreateButton("", $Left, $Top, 25, 25)
GUICtrlSetBkColor($labelarray[$I][$k], 0x000000)
EndSwitch
$Left += 25
Next
$Left = 0
$Top += 25
Next
GUISetState()
Local $nextsteparray = $array
While 1
$msg = GUIGetMsg()
$array = $nextsteparray
Sleep(250)
For $I = 0 To UBound($array) - 1
For $k = 0 To UBound($array, 2) - 1
If $array[$I][$k] = " " Then ContinueLoop
If $array[$I][$k] = "h" Then $nextsteparray[$I][$k] = "t"
If $array[$I][$k] = "t" Then $nextsteparray[$I][$k] = "."
If $array[$I][$k] = "." Then
$counter = 0
If $I - 1 >= 0 Then ; Top
If $array[$I - 1][$k] = "h" Then $counter += 1
EndIf
If $k - 1 >= 0 Then ; left
If $array[$I][$k - 1] = "h" Then $counter += 1
EndIf
If $I + 1 <= UBound($array) - 1 Then ; Bottom
If $array[$I + 1][$k] = "h" Then $counter += 1
EndIf
If $k + 1 <= UBound($array, 2) - 1 Then ;Right
If $array[$I][$k + 1] = "h" Then $counter += 1
EndIf
If $I - 1 >= 0 And $k - 1 >= 0 Then ; left Top
If $array[$I - 1][$k - 1] = "h" Then $counter += 1
EndIf
If $I + 1 <= UBound($array) - 1 And $k + 1 <= UBound($array, 2) - 1 Then ; Right Bottom
If $array[$I + 1][$k + 1] = "h" Then $counter += 1
EndIf
If $I + 1 <= UBound($array) - 1 And $k - 1 >= 0 Then ;Left Bottom
If $array[$I + 1][$k - 1] = "h" Then $counter += 1
EndIf
If $I - 1 >= 0 And $k + 1 <= UBound($array, 2) - 1 Then ; Top Right
If $array[$I - 1][$k + 1] = "h" Then $counter += 1
EndIf
If $counter = 1 Or $counter = 2 Then $nextsteparray[$I][$k] = "h"
EndIf
Next
Next
For $I = 0 To UBound($nextsteparray) - 1
For $k = 0 To UBound($nextsteparray, 2) - 1
Switch $nextsteparray[$I][$k]
Case "t" ; Tail
GUICtrlSetBkColor($labelarray[$I][$k], 0xFF0000)
Case "h" ; Head
GUICtrlSetBkColor($labelarray[$I][$k], 0x0000FF)
Case "." ; Conductor
GUICtrlSetBkColor($labelarray[$I][$k], 0xFFFF00)
Case " " ; Empty
GUICtrlSetBkColor($labelarray[$I][$k], 0x000000)
EndSwitch
$Left += 25
Next
$Left = 0
$Top += 25
Next
If $msg = -3 Then Exit
WEnd
EndFunc ;==>Wireworld

View file

@ -30,7 +30,7 @@ wireWorldRuleSet = new RuleSet
int cell := s.at(x, y);
cell =>
conductor
conductor:
{
int number := s.LiveCell(x, y, electronHead);
if (number == 1 || number == 2)
@ -42,15 +42,15 @@ wireWorldRuleSet = new RuleSet
^ conductor
}
}
electronHead
electronHead:
{
^ electronTail
}
electronTail
electronTail:
{
^ 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
{
@ -75,10 +75,10 @@ sealed class Model
if (y < l.Length)
{
(l[y]) =>
conductorLabel { retVal := conductor }
headLabel { retVal := electronHead }
tailLabel { retVal := electronTail }
emptyLabel { retVal := empty }
conductorLabel : { retVal := conductor }
headLabel : { retVal := electronHead }
tailLabel : { retVal := electronTail }
emptyLabel : { retVal := empty }
}
else
{
@ -117,27 +117,27 @@ sealed class Model
int cell := theSpace.at(i, j);
cell =>
conductor { label := conductorLabel }
electronHead { label := headLabel }
electronTail { label := tailLabel };
conductor : { label := conductorLabel }
electronHead : { label := headLabel }
electronTail : { label := tailLabel };
console.write(label);
Console.write(label);
j := j + 1
};
i := i + 1;
console.writeLine()
Console.writeLine()
}
}
}
public program()
public Program()
{
Model model := Model.load(sample,10,30);
for(int i := 0; i < 10; i += 1)
{
console.printLineFormatted("Iteration {0}",i);
Console.printLineFormatted("Iteration {0}",i);
model.print().run()
}
}