Skip to content

Commit

Permalink
Add Slowmo
Browse files Browse the repository at this point in the history
Added a slowmo feature to provide a way to do an anaylsis while the computer is training
  • Loading branch information
microhacker07 committed Jun 12, 2019
1 parent 36c8cf5 commit d58b493
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit d58b493

Please sign in to comment.