I am using two-dimensional array storage, 1 said blank, 0 means white (people), 1 PC,
Two for traversal, on every flag
On current flags near 8 pieces to detect, calculate the up and down or so left lower left upper right number of pieces,
Determine whether is blocked at the same time, judging by pieces in one direction, the maximum number of pieces to determine whether the next here,
This is a direction of code
Pieces to the left to the right code
Flag=1;////initializes the
Number=1;////temporary number
Stone=0;/////if both sides are, 0 no is blocked, 1 is blocked side, 2 on both sides will be blocked
While (data [I] + flag [j]==data [I] [j] & amp; & (j + flag) & lt;=14)///////ring calculation to the right number of pieces
{
Flag++;
Number++;
}
If (data [I] + flag [j]==ISWHITE & amp; & (j + flag) & lt;=14)//////to the right to judge whether the pieces block, if yes, the current direction of number of pieces - 0.5
{
Number -=0.5;
Stone++;
}
If (data [I] + flag [j]==1 & amp; & (j + flag) & lt;=14)///////if it is a blank to add address temporary variable
{
Temp_y=I;
Temp_x=j + flag;
}
Flag=1;///////////initializes the addend
While (data [I] [j - flag]==data [I] [j] & amp; & (j - flag) & gt;=0)//////////the left
{
Flag++;
Number++;
}
If (data [I] [j - flag]==ISWHITE & amp; & (j - flag) & gt;=0)/////////the left judgement block
{
Number -=0.5;
Stone++;
}
If (data [I] [j - flag]==1 & amp; & (j - flag) & gt;=0)///////to the left to determine blank
{
Temp_y=I;
Temp_x=j - flag;
}
If (stone!=2)/////////determine whether the potential energy is the largest, if is the largest, coordinate is equal to the temporary x, y
If (number & gt; Total)/////////total for a maximum number
{
Y=temp_y; X=temp_x;
Total=number;
}
It's just like near the number eight pieces for detection and judgment, next I prepare to explore current near 16 pieces pieces,
And this piece of traverse too troublesome, appear a lot of repeated
CodePudding user response:
Under the great spirit guide, and correct my train of thought,