RabidCicada / boardgame_framework

A framework for implementing boardgames
Apache License 2.0
1 stars 0 forks source link

Add cell auto-fill capability (seaming of hexes or more general) #3

Open RabidCicada opened 4 years ago

RabidCicada commented 4 years ago

Use-Case: Specifically need this for cell seaming during map creation.

The idea is to use mathematical operations such as convex/concave hull generation, followed by flood/seed fill or some other appropriate algorithm to fill-in/generate hexes.

Need to see which component this would be a part of.

An immediate realization for the optimization is to only give it the neighbor hexes of the seem itself to prevent highly redundant operations.

A generic hex generator/filter could be useful in places other than just map creation operations.

RabidCicada commented 4 years ago

concave hull looks like it can be troublesome. It would be deterministic I think for a discrete coordinate grid but I couldn't guarantee it would work for arbitrary maps people might throw at the system: https://towardsdatascience.com/the-concave-hull-c649795c0f0f https://github.com/sebastianbeyer/concavehull https://github.com/mapbox/concaveman

I think perhaps I stick with simple "inside-shape" tests for each 'void' point in the coordinate system

RabidCicada commented 4 years ago

Hrmph...I remember, the reason I wanted to calculate concave shape was to determine the polygon for the 'inside-shape' test: https://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/

I could simply do a convex hull around the seam adjacent edges. But I was hoping for this to be more generic :).

I could also do a blind flood/seed fill and just pass all the coordinates of the cells involved. Then I need a parameter/parameters giving the different seeds or simply a function/lambda that would "find" voids that need filling.

RabidCicada commented 4 years ago

Ohhh...I like http://openaccess.thecvf.com/content_CVPRW_2019/papers/CEFRL/He_Scan-Flood_FillSCAFF_An_Efficient_Automatic_Precise_Region_Filling_Algorithm_for_CVPRW_2019_paper.pdf for a method. Perhaps I'll implement that with user provided lambda's for classification/masking.