int fire_dept_tool(SimView *view, short x, short y) { int result; if ((x < 0) || (x > (WORLD_X - 1)) || (y < 0) || (y > (WORLD_Y - 1))) { return -1; } result = check3x3(view, x, y, FIRESTBASE, fireState); if (result == 1) { DidTool(view, "Fire", x, y); } return result; }
int special_tool(SimView *view, short x, short y) { int result; if ((x < 0) || (x > (WORLD_X - 1)) || (y < 0) || (y > (WORLD_Y - 1))) { return -1; } result = check3x3(view, x, y, specialBase, specialState); if (result == 1) { DidTool(view, "Special", x, y); } return result; }
int police_dept_tool(SimView *view, short x, short y) { int result; if ((x < 0) || (x > (WORLD_X - 1)) || (y < 0) || (y > (WORLD_Y - 1))) { return -1; } result = check3x3(view, x, y, POLICESTBASE, policeState); if (result == 1) { DidTool(view, "Pol", x, y); } return result; }
int industrial_tool(SimView *view, short x, short y) { int result; if ((x < 0) || (x > (WORLD_X - 1)) || (y < 0) || (y > (WORLD_Y - 1))) { return -1; } result = check3x3(view, x, y, INDBASE, industrialState); if (result == 1) { DidTool(view, "Ind", x, y); } return result; }
int commercial_tool(SimView *view, short x, short y) { int result; if ((x < 0) || (x > (WORLD_X - 1)) || (y < 0) || (y > (WORLD_Y - 1))) { return -1; } result = check3x3(view, x, y, COMBASE, commercialState); if (result == 1) { DidTool(view, "Com", x, y); } return result; }
int residential_tool(SimView *view, short x, short y) { int result; if ((x < 0) || (x > (WORLD_X - 1)) || (y < 0) || (y > (WORLD_Y - 1))) { return -1; } result = check3x3(view, x, y, RESBASE, residentialState); if (result == 1) { DidTool(view, "Res", x, y); } return result; }
int main() { // Initialization int lX, lY; board = input4D(&lX, &lY); int i, j, k, l; int t = 0; for (i=0; i<3; i++) { for (j=0; j<3; j++) { smallBval[i][j] = 0; for (k=0; k<3; k++) { for (l=0; l<3; l++) { if (board[i][j][k][l] == 'X') { mat4[i][j][k][l] = 2; } else if (board[i][j][k][l] == 'O') { mat4[i][j][k][l] = 1; } else mat4[i][j][k][l] = 0; } } k=check3x3(board[i][j]); if (k == 2) bigB[i][j] = t = 1; else if (k == 1) bigB[i][j] = t = 2; else bigB[i][j] = 0; } } bigBval = 0; turn = player(); if (t) init(); bot(lX,lY); playmove((player()=='X')+1,lX,lY,xLmove,yLmove,xSmove,ySmove); output2file(board,xSmove,ySmove); deinit(); printf("I play: %d,%d,%d,%d\n\n", xLmove, yLmove, xSmove, ySmove); return 9*(3*xLmove+xSmove) + (3*yLmove+ySmove); }