-
Notifications
You must be signed in to change notification settings - Fork 52
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
Terraforming #742
Comments
The natural solution would be to add a I am not sure what is the best structure to represent tiles or if we even need to optimize it if can not measure it realistically yet. I suppose we could run one tick with a mutable array and get back a normal one by using EDIT2: Actually we probably could simply collect the updates and execute them all at once at the end of the tick - if more are in the same tile then it will be very efficient. |
I think a good performance test would be to run a line of robots across the screen and change the terrain of every visible location. We could run that a few times, left to right and back again, like windshield wipers. Compare that with the same run with the terraform replaced by |
Using actual mutable arrays for the terrain seems problematic; see the discussion at #30 . Another possibility would be to do something similar to entities: we have a base, immutable array storing initial terrain values, and then a map of "overrides". To look up the terrain value for a particular cell you first look it up in the override map, and then fall back to the base array if you don't find it. |
I think with terraforming the common use case will be doing sweeping terraforming of an area once and then leaving it as is. See my EDIT2 - if we collect the terrain updates at the end of the tick, we can update the pure immutable array once. So if you have a lot of robots changing the terrain at the same time it will be more efficient but the data can stay immutable. This will be particularly useful for |
As another thought, we should add a counterpart function |
I think updating the immutable terrain array once per tick is probably too frequent. Imagine you just have one robot walking back and forth changing the terrain - it can only affect one square per tick and you would be regenerating the entire tile every tick. But I can imagine buffering a bunch of terrain updates and then regenerating the immutable tile array once enough updates have accumulated. |
I bet it would not be so bad, especially if the compiler can figure out that we will not need the original array anymore. But we will have to try measure it and see. 🙂 |
I think it will be bad 😄 But yes, we will have to benchmark it! |
Now that we have custom terrain (#1775), and especially if we add something like #205 , it should be possible for robots to programmatically change the terrain.
This would require reworking the way that we store terrain values, since currently there is no way to store/remember any terrain values other than the ones that are generated by the world function. We could probably do something similar to the way that we currently store entities.
The text was updated successfully, but these errors were encountered: