void PlayerMove(int playerId, IGame* game, Move& move, bool& bomb) { XGAME = game; GetChainMatrix(); // fprintf(out,"Turn: %d\n", turn ); // fflush(out); //simulation->BeginTurn(game); ++turn; move = moveNone; float m = -1000; int gata = 0; int killswitch = 0; vector < int > bmbs; memset(heatmap, 0, sizeof(heatmap)); for (int i = 0; i < game->PlayerCount(); ++ i) if(game->PlayerAlive(i) && i!=playerId) { IGame * ngame = game->Clone(); int &x = ngame->Bomb(ngame->PlayerPosX(i), ngame->PlayerPosY(i)); x = 7; simulation->BeginTurn(ngame); simulation->EndTurn(ngame); memset(v2, 0, sizeof(v2)); float f1 = dfs(ngame, i, 6, 0); delete ngame; /* ngame = game->Clone(); simulation->BeginTurn(ngame); simulation->EndTurn(ngame); memset(v2, 0, sizeof(v2)); float f2 = dfs (ngame, i, 6, 0);*/ if (!(f1 <= 0.001)) { bmbs.push_back(i); } //delete ngame; } for (int we = 6; we >=0; we-=6) { for (int i = 0; i < bmbs.size(); ++ i) { int &x = game->Bomb(game->PlayerPosX(bmbs[i]), game->PlayerPosY(bmbs[i])); x = we; } generate_heat_map(game, playerId); for (int k = 1; k >= 0 && !gata; --k) for (Move i = moveUp; i <= moveCount; ++i) { if (k == 0 && m > 0) { gata = 1; break; } if (i == moveCount) i = moveNone; if (simulation->CanMove(game, playerId, i) || game->Bomb(game->PlayerPosX(playerId)+my[i],game->PlayerPosY(playerId)+mx[i]) == -1) { IGame * ngame = game->Clone(); simulation->StoreMove(playerId, i, k); /* for (int h = 0; h < game->PlayerCount(); ++h) if (h!=playerId) simulation->StoreMove(h, moveNone, true); */ simulation->BeginTurn(ngame); simulation->EndTurn(ngame); if (ngame->PlayerAlive(playerId)) { float o; memset(v2, 0, sizeof(v2)); o = dfs(ngame, playerId, 8, i); if (o > m) { m = o; move = i; bomb = k; } } delete ngame; //delete ngame; } if (i == moveNone) break; } if (m <= 0.001) { printf("I can't survive\n"); } else break; } printf("Time left %d\n", GetTimeLeft()); //TODO: add AI code here //TODO: assign values to move and bomb (which represent your move for this step) //HINT: this function is called once for every game step //HINT: you can use the simulation pointer to simulate game states //HINT: you can modify the contents of the game pointer //HINT: you can clone the game state to evolve different scenarios //HINT: this function must return before GetTimeLeft() returns 0 //HINT: the game will evolve 1 step before your character starts moving, so it's useful to // call simulation->BeginTurn(game) to get the state of the game at the time your player // will begin to move or place the bomb. }