3D.lua

For scripts to aid with computation or simulation in cellular automata.
User avatar
muzik
Posts: 5665
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: 3D.lua

Post by muzik » January 10th, 2019, 9:56 am

New neighbourhood suggestion: currently hexagonal rules are simulated using a square grid neighbourhood which resembles the intersection of two 2x2 squares. How about adding a new neighbourhood which comes about as the intersection of two 2x2x2 blocks (with the one intersecting cell being the center)? It probably wouldn't be as good an analogue as the hexahedral neighbourhoood but would be interesting to see.

User avatar
Andrew
Moderator
Posts: 964
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: 3D.lua

Post by Andrew » January 12th, 2019, 10:52 pm

muzik wrote:New neighbourhood suggestion: ...
Given the lack of interest in the currently supported neighborhoods I'd have to say the chances of me implementing a new one are zilch.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
muzik
Posts: 5665
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: 3D.lua

Post by muzik » June 4th, 2024, 8:28 am

Is 3D.lua tied to the currently set refresh rate? Patterns seem to whizz past compared to normal 2D Golly patterns, leading to the conclusion that it's using the 144hz monitor refresh rate rather than a fixed 60fps (which is preferable for some things, but not always others).

User avatar
rowett
Moderator
Posts: 3860
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: 3D.lua

Post by rowett » June 4th, 2024, 10:44 am

muzik wrote:
June 4th, 2024, 8:28 am
Is 3D.lua tied to the currently set refresh rate? Patterns seem to whizz past compared to normal 2D Golly patterns, leading to the conclusion that it's using the 144hz monitor refresh rate rather than a fixed 60fps (which is preferable for some things, but not always others).
From my brief experiment on Windows 11: Golly uses the monitor refresh rate for the event loop. This is both for 3D.lua and if you're running B3/23 in QuickLife.

User avatar
Andrew
Moderator
Posts: 964
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: 3D.lua

Post by Andrew » June 5th, 2024, 5:18 am

rowett wrote:
June 4th, 2024, 10:44 am
From my brief experiment on Windows 11: Golly uses the monitor refresh rate for the event loop. This is both for 3D.lua and if you're running B3/23 in QuickLife.
Actually, Golly uses a 60 hertz timer to generate patterns, so if you run a small pattern like a blinker at a step size of 1 it should do about 600 generations in 10 seconds, regardless of the monitor's refresh rate (see StartGenTimer in wxcontrol.cpp). If you don't see that on Windows 11 then something is going wrong.

Scripts that generate patterns (like 3D.lua) are a different matter. It is up to the script to decide if it wants to update patterns at a particular frame rate. If you look at the EventLoop routine in 3D.lua it calls NextGeneration as fast as it can go (g.sleep is only called when not generating a pattern). If I run the following small oscillator in 3D.lua on my Windows 10 VM it does about 170 gens per second. I'd be interested to see what speed you get on Windows 11.

Code: Select all

3D version=1 size=45 pos=21,21,21
x=3 y=3 z=4 rule=3D4,7/5,8
$bo/bo$bbo$obo/bo$bbo$obo/$bo!
Note however that on a Mac there *is* a restriction on how fast a script can update the viewport. If I run the same pattern in 3D.lua on my Mac I only see about 60 gens per second. I'm pretty sure this is because some low-level wxMac code prevents window updates occurring faster than 60 frames per second (I forget the details but I remember investigating this about 10 years ago).
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
rowett
Moderator
Posts: 3860
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: 3D.lua

Post by rowett » June 5th, 2024, 6:02 am

Andrew wrote:
June 5th, 2024, 5:18 am
rowett wrote:
June 4th, 2024, 10:44 am
From my brief experiment on Windows 11: Golly uses the monitor refresh rate for the event loop. This is both for 3D.lua and if you're running B3/23 in QuickLife.
Actually, Golly uses a 60 hertz timer to generate patterns, so if you run a small pattern like a blinker at a step size of 1 it should do about 600 generations in 10 seconds, regardless of the monitor's refresh rate (see StartGenTimer in wxcontrol.cpp). If you don't see that on Windows 11 then something is going wrong.
I don't see that. My experiment was pretty much as you suggested. I ran a simple pattern in 3D.lua and measured 600 steps in 10 seconds (60 per second). I then ran a blinker in B3/S23 QuickLife and measured the same.

I then changed my monitor refresh rate to 30Hz and repeated the experiment. In both cases I got 300 steps in 10 seconds (30 per second).

User avatar
Andrew
Moderator
Posts: 964
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: 3D.lua

Post by Andrew » June 5th, 2024, 6:15 am

rowett wrote:
June 5th, 2024, 6:02 am
I then changed my monitor refresh rate to 30Hz and repeated the experiment. In both cases I got 300 steps in 10 seconds (30 per second).
That's odd. Maybe wxMSW is now doing the same throttling as wxMac (but only on Win 11?). Or maybe it's done automatically by the OS?

Can you bump the refresh rate above 60Hz? I'd be surprised if Golly then generates at that faster rate.

EDIT: Why is muzik seeing faster rates in 3D.lua on his Windows system? Is it because his monitor is doing refreshes at 144Hz?
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
rowett
Moderator
Posts: 3860
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: 3D.lua

Post by rowett » June 5th, 2024, 6:23 am

Andrew wrote:
June 5th, 2024, 6:15 am
Can you bump the refresh rate above 60Hz? I'd be surprised if Golly then generates at that faster rate.

EDIT: Why is muzik seeing faster rates in 3D.lua on his Windows system? Is it because his monitor is doing refreshes at 144Hz?
I switched to 75Hz. I see 75 generations a second in 3D.lua (which probably answers the question about muzik and his 144Hz monitor).

However, I see 64 generations per second in QuickLife.

User avatar
Andrew
Moderator
Posts: 964
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: 3D.lua

Post by Andrew » June 5th, 2024, 7:00 am

rowett wrote:
June 5th, 2024, 6:23 am
However, I see 64 generations per second in QuickLife.
Ok, that makes sense. The timer firing rate is only approximately 60 gens per sec. On my Mac I typically see about 62 gens per sec -- this is because we set SIXTY_HERTZ = 16 for Mac/Linux in wxprefs.h (the wxTimer interval has to be an integer) and 1000/16 = 62.5. But for Windows we had to set SIXTY_HERTZ = 15 (see comments why) and 1000/15 = 66.7.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
confocaloid
Posts: 3275
Joined: February 8th, 2022, 3:15 pm

Re: 3D.lua

Post by confocaloid » June 5th, 2024, 7:06 am

Andrew wrote:
June 5th, 2024, 5:18 am
[...] If I run the following small oscillator in 3D.lua on my Windows 10 VM it does about 170 gens per second. I'd be interested to see what speed you get on Windows 11.

Code: Select all

3D version=1 size=45 pos=21,21,21
x=3 y=3 z=4 rule=3D4,7/5,8
$bo/bo$bbo$obo/bo$bbo$obo/$bo!
[...]
I ran the same pattern in 3D.lua on Ubuntu 22.04.
With display refresh rate set to 60 Hz, the pattern evolves for about 60 ticks per second.
With display refresh rate set to 48 Hz, the pattern evolves for about 48 ticks per second.
Then I ran the pentadecathlon in QuickLife (same system), with step 1. The results are the same (the number of ticks per second matches the display refresh rate).
In every case, I ran the pattern for about 20 seconds.
127:1 B3/S234c User:Confocal/R (isotropic CA, incomplete)
Unlikely events happen.
My silence does not imply agreement, nor indifference. If I disagreed with something in the past, then please do not construe my silence as something that could change that.

User avatar
Andrew
Moderator
Posts: 964
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: 3D.lua

Post by Andrew » June 5th, 2024, 8:05 am

confocaloid wrote:
June 5th, 2024, 7:06 am
I ran the same pattern in 3D.lua on Ubuntu 22.04.
With display refresh rate set to 60 Hz, the pattern evolves for about 60 ticks per second.
With display refresh rate set to 48 Hz, the pattern evolves for about 48 ticks per second.
Ok, so the only anomaly seems to be when I run 3D.lua on my Windows VM. Not surprising really -- I've seen other cases where the VM doesn't behave the same as a real Windows machine.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
muzik
Posts: 5665
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: 3D.lua

Post by muzik » June 5th, 2024, 2:25 pm

Andrew wrote:
June 5th, 2024, 6:15 am
EDIT: Why is muzik seeing faster rates in 3D.lua on his Windows system?
To clarify, I'm running Linux in this case; yet to see if Windows does anything different for either 3D.lua or 2D patterns. Monitor refresh rate is indeed set to 144.

User avatar
b-engine
Posts: 1781
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on earth

Re: 3D.lua

Post by b-engine » June 5th, 2024, 5:19 pm

muzik wrote:
June 5th, 2024, 2:25 pm
To clarify, I'm running Linux in this case; yet to see if Windows does anything different for either 3D.lua or 2D patterns. Monitor refresh rate is indeed set to 144.
I also met this problem in Windows 11.
My rules
-
100th post: 18 November 2023
1000th post: 8 March 2024
10000th post:
-
Warning: Do not add my new rules to LifeWiki without permission.

Post Reply