void initall() { the_winner_is = kXS_NOBODY_PLAYER; initboard(); clearpathcounts(); clearwinpath(); }
DWORD PCOCamera::Open(int number) { DWORD err =0; HANDLE camHandle=NULL; if(getsencamfunc(&camLib)==TRUE) { errmsg.ShowError(_T("Cannot load library sencam")); return PCO_ERROR_APPLICATION_DLLNOTFOUND; } strcpy_s(libname,sizeof(libname),CAMLIB_NAME); err = initboard(number,&camHandle); errmsg.ShowPCOError(_T("initboard"), err); if(err == PCO_NOERROR) { boardnum=number; cameraHandle=camHandle; } err = setup_camera(camHandle); errmsg.ShowPCOError(_T("setup_camera"), err); if(err != PCO_NOERROR) Close(); else err=get_cam_param(camHandle,&campar); if(err == PCO_NOERROR) SetDefaultValues(); return err; }
short playgame (char *input_str, struct board *board) { int flag; board->oracle[0] = 0; board->oracle[1] = 0; initboard (board); flag = parse_input_string (input_str, board); if (flag <= 0) return flag; return ia_compute_move (board) + 1; }
void main(void) { int i; initboard(); while(total<8) { place(); for(i=total-1; i >= 0; i--) shift(i); } display(); printf("Displaying %d pieces.\n", total); }
int main() { int i,j; char again[2],winner,**board; board=(char**)malloc(sizeof(char*)*3); for (i=0; i<3; i++) { board[i]=(char*)malloc(sizeof(char)*3); } printf("\nWelcome to a game of Tic-Tac-Toe!\n"); do { board=initboard(board); displayboard(board); do { board=human_move(board,PLAYER1); displayboard(board); winner=checkwin(board,PLAYER1); if (winner!=PLAYER1 && winner!=' ') { if (computer_move(board,PLAYER2,PLAYER1)) { winner=checkwin(board,PLAYER2); } else { printf("\nComputer passed\n"); } displayboard(board); } } while (winner==BLANK); if (winner!=' ') { printf("THE WINNER IS %c!\n",winner); } else { printf("IT'S A TIE.\n"); } printf("\nPlay again (y)?: "); scanf("%s",again); } while(again[0]=='y'); for (i=0; i<3; i++) { free(board[i]); } free(board); printf("\nThank you for playing.\n\n"); return 0; }
void main(int argc, char **argv) { Bool printout = false; Bool binary = false; Bool convert = false; int opt; extern int optind; argv0 = argv[0]; while((opt = getopt(argc, argv, "cbp")) != EOF) { switch(opt) { case 'c': convert = true; break; case 'b': binary = true; break; case 'p': printout = true; break; default: usage(); } } if(binary && convert) error("what the hey?"); if (optind < argc) dictname = argv[optind]; print("dict..."); if(binary) initbinary(dictname); else initdict(dictname); if(convert) outbinary(dictname); if(printout) { printdict(root,0); exits(0); } print("board..."); initboard(); print("ready\n"); gameplay(); }
//main function int main() { /* variable declaration */ char done=' '; printf("WELCOME TO TIC-TAC-TOE GAME\n"); printf("PLAYER1 plays against another PLAYER2\n"); /*calling function for intializing the board with empty cells*/ initboard(); do { //print the board printboard(); player1_move();//call player1 move function to place the cell for player1 done=check();//check whether the player1 wins or not,if it wins,exit from the loop if(done!=' ') break; printboard(); /* check whether the board is full or not continue to the move for player2 and check whether the player 2 wins after their move and check whether the board is full or not*/ done=isBoardFull(); if(done!=' ') break; player2_move(); done=check(); if(done!=' ') break; done=isBoardFull(); if(done!=' ') break; }while(done==' '); /*check for return statement from the loop,to declare the win*/ if(done=='X') {printf("Congrats, Player1 Wins\n"); printboard();} else if(done=='0') {printf("Congrats, Player2 Wins\n"); printboard();} else printf("Match Draw\n"); return 0; }
int main(void) { const int flash_burn = 0; int testcpu; initboard(); initsdram(); com_init(); sendtocom0("LH-1008 Satellite Navigation System\n\n\n"); initmodules(); //TestCPU testcpu = (0xabcddcba * 0x56899865 + 0xccdd) / 0xaabb; testcpu <<= 16; testcpu = ~testcpu; if (testcpu == 0x11DCFFFF) { sendtocom0("Satellite Navigation System Start\n\n"); } //Test Flash if (flash_burn == 1) { Flash_Chip_Erase(); printf("Flash Erase Complete\n"); Flash_Writem(FLASH_BASE_ADDR, 0x000, 0x48); Flash_Writem(FLASH_BASE_ADDR+0x400, (Uint32*)0x400, 0x5b30); printf("Flash Write Complete\n"); } test_entry(); /* printf("TEST SDRAMing... Write 0x00000000\t\n"); for (i=0; i<0x1000000; i++) write16((0x80000000 + i*2), 0x0); for (i=0; i<0x1000000; i++) { tmptest = read16(0x80000000 + i*2); if (tmptest != 0) { printf("SDRAM Check failed...\t\n"); printf("i=0x%x\r\n", i); printf("tmptest=0x%x\r\n", tmptest); printf("testram=0x%x\r\n", testram); } } printf("SDRAM Check 0x00000000 OK\t\n"); printf("TEST SDRAMing... Write 0xFFFFFFFF\t\n"); for (i=0; i<0x1000000; i++) write16((0x80000000 + i*2), 0xffff); for (i=0; i<0x1000000; i++) { tmptest = read16(0x80000000 + i*2); if (tmptest != 0xffff) { printf("SDRAM Check failed...\t\n"); printf("i=0x%x\r\n", i); printf("tmptest=0x%x\r\n", tmptest); printf("testram=0x%x\r\n", testram); } } printf("SDRAM Check 0xFFFFFFFF OK\t\n"); printf("TEST SDRAMing... Write 0xAAAAAAAA\t\n"); for (i=0;i<0x1000000; i++) write16((0x80000000 + i*2), 0xaaaa); for (i=0; i<0x1000000; i++) { tmptest = read16(0x80000000 + i*2); if (tmptest != 0xaaaa) { printf("SDRAM Check failed...\t\n"); printf("i=0x%x\r\n", i); printf("tmptest=0x%x\r\n", tmptest); printf("testram=0x%x\r\n", testram); } } printf("SDRAM Check 0xAAAAAAAA OK\t\n"); printf("TEST SDRAMing... Write 0x55555555\t\n"); for (i=0; i<0x1000000; i++) write16((0x80000000 + i*2), 0x5555); for (i=0; i<0x1000000; i++) { tmptest = read16(0x80000000 + i*2); if (tmptest != 0x5555) { printf("SDRAM Check failed...\t\n"); printf("i=0x%x\r\n", i); printf("tmptest=0x%x\r\n", tmptest); printf("testram=0x%x\r\n", testram); } } printf("SDRAM Check 0x55555555 OK\t\n"); printf("TEST SDRAMing...Write Accumulation \t\n"); for (i=0, testram=TESTCOUNT; i<0x1000000; i++, testram--) write16((0x80000000 + i*2), testram); for (i=0, testram=TESTCOUNT; i<0x1000000; i++, testram--) { tmptest = read16(0x80000000 + i*2); if (tmptest != testram) { printf("SDRAM Check failed...\t\n"); printf("i=0x%x\r\n", i); printf("tmptest=0x%x\r\n", tmptest); printf("testram=0x%x\r\n", testram); } } printf("SDRAM Test good\n"); initsdram(); */ }
int main() { srand((time(0))); int i,j; char again[2],winner,**board,agin='y'; board=(char**)malloc(sizeof(char*)*3); for (i=0; i<3; i++) board[i]=(char*)malloc(sizeof(char)*3); do { board=initboard(board); char first = 'y'; printf("Play first? "); scanf("%c",&first); displayboard(board); if (first == 'y'){ do { board=human_move(board,PLAYER1); displayboard(board); winner=checkwin(board,PLAYER1); if (winner!=PLAYER1 && winner!=' ') { if (computer_move(board,PLAYER2,PLAYER1)) winner=checkwin(board,PLAYER2); else printf("\nComputer passed\n"); displayboard(board); } } while (winner==BLANK); }else{ do{ if (computer_move(board,PLAYER2,PLAYER1)) winner=checkwin(board,PLAYER2); else printf("\nComputer passed\n"); displayboard(board); if (winner!=PLAYER2 && winner!=' ') { board=human_move(board,PLAYER1); winner=checkwin(board,PLAYER1); displayboard(board); } }while (winner == BLANK); } if (winner!=' ') printf("THE WINNER IS %c!\n",winner); else printf("IT'S A TIE.\n"); printf("\nPlay again (y)?: "); scanf("%s",again); getchar(); } while(again[0]=='y'); // getchar(); // scanf("%c",&agin); // } while(agin=='y'); //Free Allocated Space for (i=0; i<3; i++) free(board[i]); free(board); printf("\nThank you for playing.\n\n"); return 0; }