- Home /
board game algorithm
Hi, what happen is, I have a board layout in 7*7 grid, and each tile can be own by one of the 4 players.
Each tile has a score of 0-9. If a player claim it, that player will gain that much score each turn. If one or more connected tiles are own by the same player, there will be bonus score added.
I am trying to solve an algorithm to check on how many tiles are connected in a single island.
Any recommendation? THX in advance.
if you have an array of your board you can start with checking the first tile and if it was full check it's up down left and right and if this up,down,.. was for the same player Save this new tiles in another array which saves tiles which you are not going to check again then You can have this only by these new array which saves Blocks which You are not going to check again!! public var tiles:gameobject[][]; /i have not used 2d array in unity yet because i didnt need to but it think these will work any way You are saving you tiles / public var DontCheckIndex[][]; //these indexes wont be checked again! /then write your Recursive function here which will keep checking nodes from right,left,up,down/