Port the old procedural block prevention code #26

Closed
opened 2026-03-07 22:28:56 +00:00 by nexustix · 0 comments
Owner

When solid features that block movement around the level are placed there is a chance of making a level unbeatable. An approach that has been viable in older iterations was to locally check if placing a solid features would cause a disconnect between two areas. Following heuristic has proven functional

First the surrounding tiles of a target (X) are fetched, unwrapped, and put into an array:

##_
_X_
###

->

##__###_

Second it will be counted how many distinct sections this array has (looping at the ends of the array), by looping over it and increasing a counter whenever the polarity (solidness) of a cell flips:

##__###_

->

1_2_3__4

If There are more than 2 polarity changes (sections) then placing a solid feature at the target has a chance to make the level unplayable.

When solid features that block movement around the level are placed there is a chance of making a level unbeatable. An approach that has been viable in older iterations was to locally check if placing a solid features would cause a disconnect between two areas. Following heuristic has proven functional First the surrounding tiles of a target (X) are fetched, unwrapped, and put into an array: ``` ##_ _X_ ### -> ##__###_ ``` Second it will be counted how many distinct sections this array has (looping at the ends of the array), by looping over it and increasing a counter whenever the polarity (solidness) of a cell flips: ``` ##__###_ -> 1_2_3__4 ``` If There are more than 2 polarity changes (sections) then placing a solid feature at the target has a chance to make the level unplayable.
nexustix changed title from Port the old procedural gen block prevention code to Port the old procedural block prevention code 2026-03-09 21:04:39 +00:00
nexustix 2026-03-10 17:32:38 +00:00
Sign in to join this conversation.
No description provided.