Islanders-Game / Islanders

A clone of the popular "Settlers of Catan", written in Typescript.
Other
4 stars 0 forks source link

Neighbouring Hex Coordinates are reported incorrectly #1218

Closed andersfischernielsen closed 3 years ago

andersfischernielsen commented 3 years ago

When generating a random board, the harbors surrounding the board are supposed to be generated such that every other ocean tile is a harbor.

We currently do this by checking whether surrounding tiles for a given ocean tile are already a harbor and if not, then we make the current tile a harbor.

https://github.com/Colonists-Game/Colonists/blob/6ddb7fdbeed99cb488d00fc92d1675cdde212002/colonists-shared/lib/WorldGenerator.ts#L128-L140

For some reason, this check evaluates to true in certain cases where it should be false. See this (incorrect) result:

screenshot
anders-wind commented 3 years ago

Identified bug: All tiles have been placed according to the rule (don't place harbor next to harbor), and no spaces are left for them to be placed. So in the current algorithm for placement, we fail due to the order of placing harbor.