From 2635a3afdf3c4f43bb2cd7bc723067e5de713a40 Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 31 Jan 2018 23:20:06 +0100 Subject: [PATCH] Tweaking AI --- Assets/mrboom.6 | 3 --- ai/Bot.cpp | 10 +++++++++- ai/GridFunctions.cpp | 2 +- ai/README.md | 19 +++++++++---------- sdl2/sdl2.cpp | 4 ++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Assets/mrboom.6 b/Assets/mrboom.6 index f6478782..35c70b66 100644 --- a/Assets/mrboom.6 +++ b/Assets/mrboom.6 @@ -69,9 +69,6 @@ Color team mode. .B \-n, \-\-noautofire No autofire for bomb drop. .TP -.B \-x, \-\-xbrz -Set xBRZ shader factor: from 1 to 6 (default is 2, 1 is off). -.TP .B \-z, \-\-nomusic No music. .TP diff --git a/ai/Bot.cpp b/ai/Bot.cpp index bb81ac04..e6caed6c 100644 --- a/ai/Bot.cpp +++ b/ai/Bot.cpp @@ -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() @@ -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); @@ -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); diff --git a/ai/GridFunctions.cpp b/ai/GridFunctions.cpp index 1bfafe6e..58b9d20a 100644 --- a/ai/GridFunctions.cpp +++ b/ai/GridFunctions.cpp @@ -777,7 +777,7 @@ void updateBestExplosionGrid(int player, } if (!foundSafePlace) { - score = 0; + score = -score; } } bestExplosionsGrid[i][j] = score; diff --git a/ai/README.md b/ai/README.md index 3cfdc2ab..029450d8 100644 --- a/ai/README.md +++ b/ai/README.md @@ -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). diff --git a/sdl2/sdl2.cpp b/sdl2/sdl2.cpp index 6e1b58d7..ba2c29cb 100644 --- a/sdl2/sdl2.cpp +++ b/sdl2/sdl2.cpp @@ -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(); } @@ -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 , --xbrz \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 , --xbrz \t\tSet xBRZ shader factor: from 1 to 6 (default is %d, 1 is off)\n", XBRZ_DEFAULT_FACTOR); log_info(" -o , --output \t\tDebug traces to file\n"); log_info(" -t , --tracemask \tDebug traces mask :\n"); log_info(" \t\t1 to 128 player selection bit\n");