Jump to content
  • Advertisement
Sign in to follow this  
zz2

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.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!