« on: December 26, 2020, 08:13:31 pm »
You have probably seen these pictures before... Now you can see where they come from!
EDIT: Now with zoom.
' Version 2020-12-28
'
' 111 110 101 100 011 010 001 000
' A B C D E F G H
'
' Each of A-H can be either 0 or 1.
' There are 2^8=256 possible rules.
' Hardware.
' Structure(s) to hold table of rules.
' Overall dimension of plot.
ZoomFactor = 8
' State arrays and variables.
' Initialize.
PresentRule = 31
CALL UpdateAndDraw
(PresentRule
, 0) 'CALL AutoPlay
' Main Loop
IF (ZoomFactor
= 1) THEN ZoomFactor
= 0 ZoomFactor = ZoomFactor + 2
IF (ZoomFactor
> 64) THEN ZoomFactor
= 64 CALL UpdateAndDraw
(PresentRule
, 0) ZoomFactor = ZoomFactor - 2
IF (ZoomFactor
< 2) THEN ZoomFactor
= 1 CALL UpdateAndDraw
(PresentRule
, 0) PresentRule = PresentRule + 1
IF (PresentRule
> 256) THEN PresentRule
= 1 CALL UpdateAndDraw
(PresentRule
, 0) PresentRule = PresentRule - 1
IF (PresentRule
< 1) THEN PresentRule
= 256 CALL UpdateAndDraw
(PresentRule
, 0) CALL UpdateAndDraw
(PresentRule
, 1) CALL UpdateAndDraw
(PresentRule
, 0) CALL UpdateAndDraw
(PresentRule
, 2)
PresentRule = 31
FOR j
= 1 TO (INT((DomainWidth
/ ZoomFactor
) / 2) - 1) '(INT((DomainWidth / ZoomFactor) / 2) - 1)
a
= "Rule:" + STR$(r
- 1) + " of 255"
CALL DrawRuleKey
(j
, 585, 1, 1, 1, Rules
(r
).A
) j = j + 80
CALL DrawRuleKey
(j
, 585, 1, 1, 0, Rules
(r
).B
) j = j + 80
CALL DrawRuleKey
(j
, 585, 1, 0, 1, Rules
(r
).C
) j = j + 80
CALL DrawRuleKey
(j
, 585, 1, 0, 0, Rules
(r
).D
) j = j + 80
CALL DrawRuleKey
(j
, 585, 0, 1, 1, Rules
(r
).E
) j = j + 80
CALL DrawRuleKey
(j
, 585, 0, 1, 0, Rules
(r
).F
) j = j + 80
CALL DrawRuleKey
(j
, 585, 0, 0, 1, Rules
(r
).G
) j = j + 80
CALL DrawRuleKey
(j
, 585, 0, 0, 0, Rules
(r
).H
)
IF (s
= 0) THEN a
= "Seed: Standard" ELSE a
= "Seed: Random"
a
= "Zoom:" + STR$(ZoomFactor
)
a = "* Use Up/Down arrows to change zoom. "
a = "* Use Left/Right arrows to change rule."
a = "* Press R for random initial condition."
a = CurrentState(k)
a = CurrentState(k - 1)
b = CurrentState(k)
c = CurrentState(k)
c = CurrentState(k + 1)
IF ((a
= 1) AND (b
= 1) AND (c
= 1)) THEN NextState
(k
) = Rules
(RuleNumber
).A
IF ((a
= 1) AND (b
= 1) AND (c
= 0)) THEN NextState
(k
) = Rules
(RuleNumber
).B
IF ((a
= 1) AND (b
= 0) AND (c
= 1)) THEN NextState
(k
) = Rules
(RuleNumber
).C
IF ((a
= 1) AND (b
= 0) AND (c
= 0)) THEN NextState
(k
) = Rules
(RuleNumber
).D
IF ((a
= 0) AND (b
= 1) AND (c
= 1)) THEN NextState
(k
) = Rules
(RuleNumber
).E
IF ((a
= 0) AND (b
= 1) AND (c
= 0)) THEN NextState
(k
) = Rules
(RuleNumber
).F
IF ((a
= 0) AND (b
= 0) AND (c
= 1)) THEN NextState
(k
) = Rules
(RuleNumber
).G
IF ((a
= 0) AND (b
= 0) AND (c
= 0)) THEN NextState
(k
) = Rules
(RuleNumber
).H
CurrentState(k) = NextState(k)
xx = p * (1 - 1 / ZoomFactor)
IF (CurrentState
(2 * p
- k
) = 1) THEN PSET ((2 * p
- k
- xx
), y
), _RGBA(0, 0, 0, 255) LINE (ZoomFactor
* ((k
- xx
) - 1 / 2), ZoomFactor
* (y
- 1))-(ZoomFactor
* ((k
- xx
) + 1 / 2), ZoomFactor
* y
), _RGBA(0, 0, 0, 255), BF
LINE (ZoomFactor
* ((k
- xx
) - 1 / 2), ZoomFactor
* (y
- 1))-(ZoomFactor
* ((k
- xx
) + 1 / 2), ZoomFactor
* y
), _RGBA(0, 0, 0, 20), BF
IF (CurrentState
(2 * p
- k
) = 1) THEN LINE (ZoomFactor
* ((2 * p
- k
- xx
) - 1 / 2), ZoomFactor
* (y
- 1))-(ZoomFactor
* ((2 * p
- k
- xx
) + 1 / 2), ZoomFactor
* y
), _RGBA(0, 0, 0, 255), BF
LINE (ZoomFactor
* ((2 * p
- k
- xx
) - 1 / 2), ZoomFactor
* (y
- 1))-(ZoomFactor
* ((2 * p
- k
- xx
) + 1 / 2), ZoomFactor
* y
), _RGBA(0, 0, 0, 20), BF
CurrentState(k) = 0
CurrentState
((UBOUND(CurrentState
) - 1) / 2 + 1) = 1 CurrentState(k) = 1
CurrentState(k) = 0
CurrentState(k) = 1
CurrentState(k + 1) = 1
CurrentState(k + 2) = 0
CurrentState(k + 3) = 0
a = IntToB2$(j)
Rules
(j
+ 1).A
= VAL(MID$(a
, 1, 1)) Rules
(j
+ 1).B
= VAL(MID$(a
, 2, 1)) Rules
(j
+ 1).C
= VAL(MID$(a
, 3, 1)) Rules
(j
+ 1).D
= VAL(MID$(a
, 4, 1)) Rules
(j
+ 1).E
= VAL(MID$(a
, 5, 1)) Rules
(j
+ 1).F
= VAL(MID$(a
, 6, 1)) Rules
(j
+ 1).G
= VAL(MID$(a
, 7, 1)) Rules
(j
+ 1).H
= VAL(MID$(a
, 8, 1))
n = x
n = n \ 2
TheReturn
= RIGHT$("00000000" + TheReturn
, 8) IntToB2$ = TheReturn
xx = x - 20
yy = y
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(255, 255, 255, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(0, 0, 0, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(200, 200, 200, 255), B
xx = x
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(255, 255, 255, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(0, 0, 0, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(200, 200, 200, 255), B
xx = x + 20
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(255, 255, 255, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(0, 0, 0, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(200, 200, 200, 255), B
xx = x
yy = y + 20
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(255, 255, 255, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(0, 0, 0, 255), BF
LINE (xx
- 10, yy
- 10)-(xx
+ 10, yy
+ 10), _RGB32(200, 200, 200, 255), B
« Last Edit: December 28, 2020, 11:28:00 pm by STxAxTIC »
Logged
You're not done when it works, you're done when it's right.