Hi, to avoid reinventing the wheel I would like to know if any known method of evaluating, if there are x no. of items of the same type in a line on a gird, exists.
For example: are there 5 items (of the same type) in a line anywhere on the grid.
Five in a line evaluation logic
Typically you only have to check if the last stone placed on the board makes five in a line, which can be done by counting how many you got to the right, how many to the left and adding the new stone, and similarly for the other 3 directions.
thanks! now that you said it like that it seems pretty easy.
On Change
for added or moved item check:
horizontal direction = 1 + count left + count right
vertical direction = 1 + count up + count down
diagonal A direction = 1 + count down left + count up right
diagonal B direction = 1 + count up left + count down right
On Change
for added or moved item check:
horizontal direction = 1 + count left + count right
vertical direction = 1 + count up + count down
diagonal A direction = 1 + count down left + count up right
diagonal B direction = 1 + count up left + count down right
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement