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;
}
It works when piece is black (@), but not white (O). Since this function make little sense on it's own, I'll post the file with the other source code inside it.
Hi everyone, I need some help seriously. The game is in text mode. It will be based on questions and answers and simple commands. A menu containing options of the game including:
1-Create a new player.
2-Identify as existing player.
3-Launch a new game: this action opens a new game for an... (1 Reply)
weh i type in sudo shutdown nowit dose not le me shut down can i override this with out tyoing in -h :confused:
my web site in the makeing is also wantin ga gane code for unix and well as a shut domne hwlp (3 Replies)
I am interested in learning how to write code for games. I am a C.S. student at UNO but I am in freshman classes and they are so slow. Can anyone recommend any languages to start learning first or any other ways to get started? I have Unix with Solaris in the labs at school and I also have... (4 Replies)