Sign in to follow this  

Five in a line evaluation logic

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this