![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing global variable to a function which is called by another function | sars | Shell Programming and Scripting | 4 | 06-30-2008 08:39 AM |
| Game: Name this person | reborg | What's on Your Mind? | 268 | 09-03-2007 05:47 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Reversi Game - Function help
So I am making a Reversi program, and I found that a function doesn't work correctly as it should.
Code:
int check_file(int x, int y, int xinc, int yinc, int xmax, int ymax, int xmin,
int ymin, char board[BOARDSIZE][BOARDSIZE], char piece, int ai)
{
char opponent = flipped(piece);
int valid = 0;
int x1 = x, y1 = y;
while (x1 < xmax || x1 > xmin || y1 < ymax || y1 > ymin) {
if (board[y1][x1] == opponent)
valid = 1;
else if (board[y1][x1] == piece && valid == 1) {
while ((y1 != y || x1 != x) && !ai)
board[y1-=yinc][x1-=xinc] = piece;
return 1;
} else
return 0;
x1+=xinc, y1+=yinc;
}
return 0;
}
LA.GG— [viewing file: reversi.tar] All help is appreciated, Octal. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
while (x1 < xmax || x1 > xmin || y1 < ymax || y1 > ymin) Wouldn't your statement resolve to TRUE? |
|
#3
|
|||
|
|||
|
After trying '&&' instead of '||', I noticed that the function doesn't work correctly for black's, or white's moves.
|
|||
| Google The UNIX and Linux Forums |