david-pfx / PuzzleScriptNext

A direct successor to PuzzleScript, building on the work of PuzzleScript Plus, Pattern:Script and others.
http://www.puzzlescriptnext.polyomino.com
MIT License
15 stars 6 forks source link

2 Dimensional Rules #118

Open just-kirb opened 2 weeks ago

just-kirb commented 2 weeks ago

Check ([ ] -> [x]) all that apply, then describe the issue below:

Summary of proposed idea: allow for 2 dimensional rules to exist within the engine.

proposed idea: there will be 2 new special tags in the rules section: 2drule and 2druleend and the main idea is that they are considered open and closed parenthesis on establishing 2 dimensional rules.

proposed format:

  1. It is still a 1-1 mapping of the cells
  2. The 2d rule must be rectangular in its dimensions, otherwise it runs into an error of an non-rectangular shape
  3. Arrows must always sandwich the before and after in every line of the code
  4. "[" must always indicate the start of the 2d structure, and "]" must always indicate the end of said structure
  5. Multiple rules that happen simultaneously have to be split per line to not have too much confusion on reading the code.
  6. Preludes are written within the line of the 2drule.
  7. Some functionality (ex: "...") might be restricted due to it being difficult to code.
  8. the direction is in the reading format, where "|" is just the normal direction, and a line break in the middle of the rules indicate to return to the original starting reading point, but moving the original starting reading point by 1 unit with a direction of 90 degrees clockwise of the same direction.
  9. Mirroring may be possible with a "mirror" prefix, that allow for also checking 90 degree counterclockwise within the linebreaks
  10. command based rules can be indicated in the row with the 2druleend line Example of a rule: 2drule right [no player| crateu |no player ->[wall| |wall cratel |target cratex|crater -> |goal|
    no player| crated |no player] -> wall| |wall] [candle]->[candlel] 2druleend sfx0 in this case, if a all crates form a 3x3 t pattern on a crate with the directions placed correctly without the player going in the way of the pattern, then the boxes would disappear, the 4 empty corners of the t would become walls, the target and the cratex becomes a goal, and a sound plays. before: image after: (imagine a spooky sound playing) image

Why?: There are multiple reasons why implementing this would be very beneficial:

  1. it can make diagonal adjacency much more easier to do: 2drule [player| ->[playerdead|
    |goblin]-> |goblin] 2druleend
  2. it makes detecting certain 2d shapes easier to do: 2drule [crate| |crate->[ | | crate|crate|crate -> |blockH|
    crate| |crate]-> | | ] 2druleend
  3. it allows to set up radiuses more easily: late [radius]->[] 2drule late [ | | | | -> [ | radius | radius | radius | | | | | -> radius | radius | radius | radius | radius | |player| | -> radius | radius | player | radius | radius | | | | -> radius | radius | radius | radius | radius | | | | ] -> | radius | radius | radius | ]

Thank you for reading and considering this suggestion.

david-pfx commented 2 weeks ago

I like the idea, but what kind of game will you make? Easier is good, but new kinds of game is better.

As a side note, this would not be feasible with the existing (PS) rule parser, which needs to be rewritten. The rule pattern matching would also need modifying. Just saying.

just-kirb commented 2 weeks ago

A future project that would heavily use this feature might be a 14 minesweeper variants demake (with a more traditional randomizer), which might need to use lots of weird adjacencies that require 2d rules to handle it easily.

For the coding, ideally the existing parser and pattern matcher could ignore any rules that has 2drule and 2drule end sandwiched between them, and the new 2d rule parser and matcher could deal with these special rules, making it so that it isn't too bad if the code for 2d is broken. And there are multiple puzzle games that already have that kind of 2d replacement in situations, so it isn't unheard of to code such a system: https://store.steampowered.com/app/3126790/Wordban_Sokoban/