Skip to content

Commit

Permalink
still working on moveAi
Browse files Browse the repository at this point in the history
  • Loading branch information
101itsGabe committed Oct 16, 2023
1 parent 51947ce commit e991e99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Binary file modified main.exe
Binary file not shown.
19 changes: 12 additions & 7 deletions src/gameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void GameManager::MoveAI(vector<Player> *pList)
else
Team2.emplace_back(p);
}
vector<Player> checkedPlayers;
vector<int> checkedPlayerTiles;
for (Player &p1 : Team1)
{
int closestPlayerTile = -1; // Initialize to an invalid value
Expand All @@ -321,16 +321,18 @@ void GameManager::MoveAI(vector<Player> *pList)

if (distance < prevdistance)
{
if (checkedPlayers.empty())
if (checkedPlayerTiles.empty())
{
closestPlayerTile = p2Tile;
prevdistance = distance;
}
else
{
for (Player &p : checkedPlayers)
for (int &t : checkedPlayerTiles)
{
if (p.GetTile() != p2Tile)
cout << "curDistance: " << distance << endl;
cout << "prevDistance: " << distance << endl;
if (distance < prevdistance && find(checkedPlayerTiles.begin(), checkedPlayerTiles.end(), p2Tile) == checkedPlayerTiles.end())
{
closestPlayerTile = p2Tile;
prevdistance = distance;
Expand All @@ -346,15 +348,15 @@ void GameManager::MoveAI(vector<Player> *pList)
{
if (closestPlayerTile == p.GetTile())
{
checkedPlayers.emplace_back(p);
checkedPlayerTiles.emplace_back(p.GetTile());
break;
}
}
// For each closest player move to the best spot
cout << "p1tile outside of loop: ";
cout << p1.GetTile() << endl;
cout << "ClosestPlayerTile: " << closestPlayerTile << endl;
cout << "Distance: " << prevdistance << endl;
cout << "prevDistance: " << prevdistance << endl;
}
}
// If Player 1 is fath
Expand Down Expand Up @@ -416,14 +418,17 @@ void GameManager::renderAllText(SDL_Renderer *renderer, vector<Tile> *tList, TTF

string tileId;
int check = check3(t.getTileId());

/*
if (check == 3)
tileId = "3P";
else if (check == 2)
tileId = "2P";
else if (check == 1)
tileId = "H";
else
tileId = to_string(t.getTileId());
*/
tileId = to_string(t.getTileId());
SDL_Color textColor = {85, 85, 85};
if (font != NULL)
{
Expand Down

0 comments on commit e991e99

Please sign in to comment.