diff --git a/README.md b/README.md index 0d2b669..6f40623 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,10 @@ Also the program has it so it will weight moves it has never done before greatly * Numpad 1-9 => number position is coordinated to the same spot on the board. * 1-9 => (For non-numpads devices) 1-3 is the top row, 4-6 is the middle, and 7-9 is bottom row all going from left to right. -* t => toggle computer vs computer mode for training -* r => clear/reset the tic-tac-toe board +* t => toggle computer vs computer mode for training. +* r => clear/reset the tic-tac-toe board. * c => clear the statistics of number of games, wins, etc +* s => toggles 'slowmo' mode. Useful for viewing training. * F1 => saves the 'brain' of both machine learning players under the filenames of "MLplayer_1.txt" and "MLplayer_2.txt" * F2 => loads the 'brain' of both machine learning players from the files "MLplayer_1.txt" and "MLplayer_2.txt" * F3 => makes both machine learning players 'forget' everything they know diff --git a/source/main.cpp b/source/main.cpp index 49ec72d..d3e1cb3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,6 +9,7 @@ sf::Font font; int selectedTile = -1; bool currentPlayer = 0; bool sleep = false; +bool slowmo = false; int line = -1; int gameResults[2]; int playingGame = -1; @@ -72,6 +73,10 @@ void input(sf::RenderWindow* window, int keycode) { clear(); break; + case sf::Keyboard::S: + slowmo = !slowmo; + break; + case sf::Keyboard::T: if (humanPlayer == 0) { humanPlayer = 2; @@ -466,6 +471,11 @@ int main(int argc, char const *argv[]) { } // End of First Learner + if (slowmo == true && humanPlayer == 0) { + draw(&window); + sf::sleep(sf::milliseconds(200)); + } + // Start of Second Learner if (playingGame == 1 && humanPlayer != 2) { for (int i = 0; i < 9; i++) currentGameState[i] = grid[i]+48; @@ -484,7 +494,10 @@ int main(int argc, char const *argv[]) { afterGame = true; } - if (humanPlayer != 0||wait==1) draw(&window); + if ((humanPlayer != 0 || slowmo == true) || wait == 1) draw(&window); + if (slowmo == true && humanPlayer == 0) { + sf::sleep(sf::milliseconds(200)); + } if (playingGame == -1) wait++; if (wait > 30 || (humanPlayer==0&&wait>2)) { if (humanPlayer == 0) {