Beispiel #1
0
/* Display the current game state to the user.
 */
int drawscreen(int index)
{
    return displaygame(state.map, state.game->ysize, state.game->xsize,
		       recording, macros[state.player].count > 0, !!stack,
		       state.game->seriesname, state.game->name, index + 1,
		       state.game->boxcount, state.storecount,
		       state.movecount, state.pushcount,
		       state.game->movebestcount, state.game->pushbestcount);
}
Beispiel #2
0
/* Display the current game state to the user.
 */
int drawscreen(int index)
{
    return displaygame(state.map, state.game->ysize, state.game->xsize,
		       state.game->seriesname, state.game->name, index + 1,
		       state.game->colors, state.currblock,
		       state.ycurrpos, state.xcurrpos,
		       !!stack, state.movecount, state.stepcount,
		       state.game->beststepcount, state.game->answer.count,
		       state.game->beststepknown);
}
Beispiel #3
0
int main(int argc, char *argv[]){
    int fd1[2];
    int fd2[2];
    char m[3][3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}, {'h', 'i', 'j'}};
    pipe(fd1);
    pipe(fd2);
    if (fork() == 0){
        int request;
        int i,j;
        int complete;
        srand(time(NULL));
        read(fd1[0], &request, sizeof(int));
        while (request){
            i = rand() % 3;
            j = rand() % 3;
            write(fd2[1], &i, sizeof(int));
            write(fd2[1], &j, sizeof(int));
            read(fd1[0], &request, sizeof(int));
        }
        read(fd1[0], &complete, sizeof(int));
        if (complete == 1){
            printf("Parent wins!\n");
        }
        if (complete == 2){
            printf("Child wins!\n");      
        }
        if (complete == 3){
            printf("It's draw!\n");
        }
        exit(0);
    }
    int i = rand() % 3;
    int j = rand() % 3;
    int endsignal = 0;
    int complete = 0;
    int Xed = 0;
    int Oed = 0;
    int askno = 1;
    srand(time(NULL));
    while (!complete){
        Xed = 0;
        while (!Xed){
            i = rand() % 3;
            j = rand() % 3;
            if ((m[i][j] != 'X') && (m[i][j] != 'O')){
                m[i][j] = 'X';
                Xed = 1;
            }
        }
        complete = gamestatus(m);
        if (complete){
            break;
        }
        Oed = 0;
        while (!Oed){
            write(fd1[1], &askno, sizeof(int));
            read(fd2[0], &i, sizeof(int));
            read(fd2[0], &j, sizeof(int));
            if ((m[i][j] != 'X') && (m[i][j] != 'O')){
                m[i][j] = 'O';
                Oed = 1;
            }
        }
        complete = gamestatus(m);
    }
    write(fd1[1], &endsignal, sizeof(int));
    displaygame(m);
    write(fd1[1], &complete, sizeof(int));
    return 0;
}