# Five in a line evaluation logic

This topic is 2811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
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

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
631775
• Total Posts
3002278
×