• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Looking for guidance on a "4 in a row" win condition

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
The map is a slightly tweaked version of tic-tac-toe.

The gameboard starts out as a grid 3x3 and each time a player marks a spot they increase the size of the board by one tile by adding a new space that connects to the current board on a full side (not diagonally).

My issue is catching when the player makes the move that gets them 4 in row, either up/down, left/right or diagonally are the possible ways to get it.

There is no guarantee that the last spot that completes the chain of 4 will be at the end of the chain. ( it could a middle spot that competes the chain of 4.)

My current plan is to check everytime the player makes a move and search for a 4 in a row chain in a 7x7 area around the newly marked spot. However, this would be something like 60 combinations to check everytime and I feel that there must be a better way.

Thanks for any feedback
 
You check all combinations for the change made. If it does complete a 4 in a row then out of all possible 4 in a row combinations that tile must make up one part of it.

There is up-down, left-right, top left-bottom right and bottom left-top right. That is 4 combinations. For each there are 4 different positions the tile might take for a 4 in a row to be complete. Total is 16 tests. Running 16 4 in a row tests is trivial. The maximum is 64 indices tested, however early exit tests will allow for less. Well under a thousand operations for each placement made.
 
Status
Not open for further replies.
Back
Top