What to use for flow free-like game random level creation?

后端 未结 5 2188
难免孤独
难免孤独 2020-12-12 15:50

I need some advice. I\'m developing a game similar to Flow Free wherein the gameboard is composed of a grid and colored dots, and the user has to connect the same colored do

5条回答
  •  臣服心动
    2020-12-12 16:35

    You have two choices:

    1. Write a custom solver
    2. Brute force it.

    I used option (2) to generate Boggle type boards and it is VERY successful. If you go with Option (2), this is how you do it:

    Tools needed:

    • Write a A* solver.
    • Write a random board creator

    To solve:

    1. Generate a random board consisting of only endpoints
    2. while board is not solved:
      • get two endpoints closest to each other that are not yet solved
      • run A* to generate path
      • update board so next A* knows new board layout with new path marked as un-traversable.
    3. At exit of loop, check success/fail (is whole board used/etc) and run again if needed

    The A* on a 10x10 should run in hundredths of a second. You can probably solve 1k+ boards/second. So a 10 second run should get you several 'usable' boards.

    Bonus points:

    • When generating levels for a IAP (in app purchase) level pack, remember to check for mirrors/rotations/reflections/etc so you don't have one board a copy of another (which is just lame).
    • Come up with a metric that will figure out if two boards are 'similar' and if so, ditch one of them.

提交回复
热议问题