#Nested for-loop alternatives for performance

1 messages · Page 1 of 1 (latest)

quaint grail
#

Can u show the code functions?

#

and that loops

#

its hard for me to understand what u describe in message

#

uh,

#

thats MC killer function

#

lol

#

Ok, i am trying lol

#

so u for each 884,736 blocks per tick lol

#

that impossible to get under 60ms

#

why?

#

What it does?

#

so like own world generation?

#

ok, so then just dont for each every block but only generated blocks

#

also generate chunks whats arent generated yet

#

do max one chuck per tick

#

20 chunks per sec is great performance

#

i see

#

also check for no generated chunks

#

only

#

also u every loop getting overworld again and again

#

save overworld then run getBlock

#

for each chunk next to players

#

¯_(ツ)_/¯

tired rain
#

u cant do this type of stuff fast

quaint grail
#

it is world generation and cave generation is same thing lol

#

it just looks differently in world

#

¯_(ツ)_/¯

#

it does lol

#

it loads also each block in the chunk

#

Here are steps for optimalization

  • Generate Chunks whats are not generated yet,
  • Generate max 1-2 chunks per tick,
  • Create Randomizing Algorithm for Generation and dont for blocks what u dont need
  • Learn Async Functions
#

?async

civic jewelBOT
quaint grail
#

Thats my answer

#

🦅

tired rain
#

cellular automata is not script's cup of tea

#

its one of the stress testing alorithms ppl use

quaint grail
#

U mean like runtime overlapping generation?

tired rain
#

for hardware testing

quaint grail
#

like life simulator?

tired rain
#

about world gen i look at it as a world edit addon with that said u will need to smartly break down area into chunks and then queue it every tick or use async techniques with genrator funcs and stuff which is ugly af

my best bet is to breakdown area into smaller chunks then queue it every tick

#

i faced simillar issue years back when i was trying to make a infinte area filler

#

so i did this

#

which worked great

#

but i was using inbuit fill command so my chunk size was high 32x32x32 but since ur doing a cave genration u cant use fill so reduce chunk size to 8x8x8 ot 16x16x16

#

u can also create illuion of fast genration by starting at player location and first make them then fill rest hidden ones

#

tho that requires lot more work

#

if u have ever worked with graph searching alorithms in a 3d world u can use techinues from there to build nearby player then other

flint crown
#

Minecraft is quite literally built on the foundation of chunking so it's an absolutely valid tactic and should be used

#

you could event potentially use the watchdog events to throttle

tired rain
#

Algorithm | Nested for-loop alternatives for performance

loud silo
#

Nested for-loop alternatives for performance

marsh aspen
#

I found something( on jayly's github )that may help you

import { system } from "@minecraft/server";

// Cancel termination of a script runtime due to a violation of the performance
// watchdog system.
system.events.beforeWatchdogTerminate.subscribe((eventData) => {
  eventData.cancel = true;
});