Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same rules generate different results in StructureSynth #1

Closed
bezo97 opened this issue Sep 20, 2020 · 2 comments
Closed

Same rules generate different results in StructureSynth #1

bezo97 opened this issue Sep 20, 2020 · 2 comments

Comments

@bezo97
Copy link

bezo97 commented Sep 20, 2020

Hi, the following rules generate different results in BrowserSynth and StructureSynth:

{ s 8 ry 30} crate
rule crate {
  box
  { s 0.5 x 0.9 z 0.9 y -0.9 h 22} crate2
  { s 0.5 x -0.9 z 0.9 y -0.9 h 44 } crate2
  { s 0.5 x 0.9 z -0.9 y -0.9 h 66} crate2
  { s 0.5 x -0.9 z -0.9 y -0.9 h 88} crate2
}
rule crate2 {
  box
  { s 0.5 x 0.9 z 0.9 y -0.9 h 22} crate
  { s 0.5 x -0.9 z 0.9 y -0.9 h 44 } crate
  { s 0.5 x 0.9 z -0.9 y -0.9 h 66} crate
  { s 0.5 x -0.9 z -0.9 y -0.9 h 88} crate
}
StructureSynth (expected behavior) BrowserSynth
ss ss

Clearly, only one of the four branches are executed. Note that crate and crate2 do the same thing - but the result is correct only when a single rule is used.
I wonder if this is a bug or an undocumented intentional change?

@kronpano
Copy link
Owner

BrowserSynth is based on a slighly older version of eisenscript here on GitHub.
There is a difference in how the rules are "interpreted"
The original StructureSynth is strictly width-first then depth - BrowserSynth/eisenscript is depth first then width.

That means in StructureSynth first all your commands for crate would be executed, then all for crate two ..... but always staying at the same level or depth.
BrowserSynth would go to the first crate command, then execute the crate2 for that first one, then the crate again .... - but - as it stands it would go into an infinite loop on the first corner and never get to the second corner.
The termination is only done by a default limit to prevent too many crashed by limiting the default number of objects.

This is not how the original works, I know, but I am not able to understand the eisenscript code enough to change that.

There are two simple things you can do.
Just add those two lines at the top of the script
set maxobjects 6000
set maxdepth 7

Generally BrowserSynth is limited to 1000 objects so bump that up to 6000 and limit the recursion depth to e.g. 6 or 7

Then you get the same image in BrowserSynth
SaveImg_2020-9-20-19-53-24
maxdepth and maxobjects are the only termination criteria in BrowserSynth

Hope it helps.

@bezo97
Copy link
Author

bezo97 commented Sep 21, 2020

I understand, this is a good workaround. Thank you!
If compatibility with StructureSynth is a goal then it should be properly fixed though - I'll investigate the eisenscript interpreter and keep you updated. Also might be worth teaming up with @after12am

@bezo97 bezo97 closed this as completed Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants