Code: Select all
if ((board[p] & 1) == 1)
s++;
if ((board[p]) == bknight)
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
return s;
Moderator: Ras
Code: Select all
if ((board[p] & 1) == 1)
s++;
if ((board[p]) == bknight)
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
return s;
Code: Select all
if ((board[p] & 1) == 1)
s++;
if ((board[p]) == bknight)
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
return s;
Code: Select all
if (board[p] == bknight)
{
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
s++;
}
return s;
}
Well, yes, but only because there are 12 s++; lines in the example you posted there.outAtime wrote:id still like to get rid of all those s++'s and use something elses += 10 perhaps? but that would change the overall result of s right?
Code: Select all
if (board[p] == bknight) {
for (int i = 0; i < 10; i++)
s++;
}
Code: Select all
s += (board[p] & 1) + 10*(board[p] == bknight);
Code: Select all
if (board[q] && ((board[q] & 1) == 0))
t++;
t += (board[q] && ((board[q] & 1) + 10*(board[q] == wknight)));
return t;
You only need this part:outAtime wrote:Thanks for the suggestion, that idea matches some already added code.
so for black:Code: Select all
if (board[q] && ((board[q] & 1) == 0)) t++; t += (board[q] && ((board[q] & 1) + 10*(board[q] == wknight))); return t;
Code: Select all
t += (board[q] && ((board[q] & 1) + 10*(board[q] == wknight)));
return t;+10 won't work. But you can replace the last 9 with +9 and it will.outAtime wrote:Is there a faster way than this which will give the same results? I hate adding all the ++ lines... ive tried just doing +=10 but it gave different results. Thx.
Code: Select all
if ((board[p] & 1) == 1) s++; if ((board[p]) == bknight) s++; s++; s++; s++; s++; s++; s++; s++; s++; s++; return s;
Because of your source code indention and/or possible missing brackets, it is quite unclear to me what you will achive. Can you describe in words what you want to do with those statements?outAtime wrote:Thanks for the suggestion, that idea matches some already added code.
so for black:or no i still need the if (board[q] == wknight) { above t+= ...Code: Select all
if (board[q] && ((board[q] & 1) == 0)) t++; t += (board[q] && ((board[q] & 1) + 10*(board[q] == wknight))); return t;
is that right or can I remove (board[q] && (( section, maybe its not needed.
Thanks for the help.
Code: Select all
x && (y*10)
Code: Select all
(x != 0) && (y*10 != 0) => {0, 1} or {false, true}
Code: Select all
if ( (board[q] != 0) && ((board[q] & 1) == 0) ) {
t++; // for whatever reason
}
if ( board[q] == wknight ) {
t += 10; // or 9?!
}