Skip to content

Commit

Permalink
Tweaking AI
Browse files Browse the repository at this point in the history
  • Loading branch information
frranck committed Jan 31, 2018
1 parent 3b67587 commit 2635a3a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Assets/mrboom.6
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ Color team mode.
.B \-n, \-\-noautofire
No autofire for bomb drop.
.TP
.B \-x, \-\-xbrz <x>
Set xBRZ shader factor: from 1 to 6 (default is 2, 1 is off).
.TP
.B \-z, \-\-nomusic
No music.
.TP
Expand Down
10 changes: 9 additions & 1 deletion ai/Bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool Bot::cellSafe(int cell)
int cellX = CELLX(cell);
int cellY = CELLY(cell);

return(!dangerGrid[cellX][cellY] && !flameGrid[cellX][cellY]);
return(!dangerGrid[cellX][cellY] && !flameGrid[cellX][cellY] && !monsterIsComingGrid[cell]);
}

int Bot::bestBonusCell()
Expand Down Expand Up @@ -153,6 +153,10 @@ int Bot::bestCellToDropABomb()
for (int i = 0; i < grid_size_x; i++)
{
int score = bestExplosionsGrid[i][j] * 128;
if (score < 0)
{
score = 0;
}
if (score)
{
score += noise(_playerIndex, i, j);
Expand Down Expand Up @@ -185,6 +189,10 @@ int Bot::bestSafeCell()
if (!somethingThatIsNoTABombAndThatWouldStopPlayer(i, j))
{
int score = TRAVELCOST_CANTGO - travelGrid.cost(i, j);
if (bestExplosionsGrid[i][j])
{
score += TRAVELCOST_CANTGO;
}
if ((score > bestScore) && cellSafe(CELLINDEX(i, j)))
{
int cellIndex = CELLINDEX(i, j);
Expand Down
2 changes: 1 addition & 1 deletion ai/GridFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ void updateBestExplosionGrid(int player,
}
if (!foundSafePlace)
{
score = 0;
score = -score;
}
}
bestExplosionsGrid[i][j] = score;
Expand Down
19 changes: 9 additions & 10 deletions ai/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
![alt tag](../ tests / screenshots / mrboom - 0.gif)
![alt tag](../ tests / screenshots / mrboom - 1.gif)
![alt tag](../ tests / screenshots / mrboom - 2.gif)
![alt tag](../ tests / screenshots / mrboom - 3.gif)
![alt tag](../ tests / screenshots / mrboom - 4.gif)
![alt tag](../ tests / screenshots / mrboom - 5.gif)
![alt tag](../ tests / screenshots / mrboom - 6.gif)
![alt tag](../ tests / screenshots / mrboom - 7.gif)
![alt tag](../tests/screenshots/mrboom-0.gif)
![alt tag](../tests/screenshots/mrboom-1.gif)
![alt tag](../tests/screenshots/mrboom-2.gif)
![alt tag](../tests/screenshots/mrboom-3.gif)
![alt tag](../tests/screenshots/mrboom-4.gif)
![alt tag](../tests/screenshots/mrboom-5.gif)
![alt tag](../tests/screenshots/mrboom-6.gif)
![alt tag](../tests/screenshots/mrboom-7.gif)
![alt tag](bt.png)

Using a c++ 98 port of arvidsson 's [behavior tree library](https://github.com/arvidsson/bt).

Using a c++98 port of arvidsson's [behavior tree library](https://github.com/arvidsson/bt).
4 changes: 2 additions & 2 deletions sdl2/sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void updateKeyboard(Uint8 scancode, int state)
case SDL_SCANCODE_ESCAPE:
if (state)
{
if (beeingPlaying > BEEING_PLAYING_BUFFER)
if ((beeingPlaying > BEEING_PLAYING_BUFFER) || !isGameActive())
{
pressESC();
}
Expand Down Expand Up @@ -992,10 +992,10 @@ main(int argc, char **argv)
log_info(" -c, --color \t\tColor team mode\n");
log_info(" -n, --noautofire \t\tNo autofire for bomb drop\n");
log_info(" -z, --nomusic \t\tNo music\n");
log_info(" -x <x>, --xbrz <x>\t\tSet xBRZ shader factor: from 1 to 6 (default is %d, 1 is off)\n", XBRZ_DEFAULT_FACTOR);
log_info(" -v, --version \t\tDisplay version\n");
#ifdef DEBUG
log_info("Debugging options:\n");
log_info(" -x <x>, --xbrz <x>\t\tSet xBRZ shader factor: from 1 to 6 (default is %d, 1 is off)\n", XBRZ_DEFAULT_FACTOR);
log_info(" -o <x>, --output <x>\t\tDebug traces to <x> file\n");
log_info(" -t <x>, --tracemask <x>\tDebug traces mask <x>:\n");
log_info(" \t\t1 to 128 player selection bit\n");
Expand Down

0 comments on commit 2635a3a

Please sign in to comment.