Presentation is loading. Please wait.

Presentation is loading. Please wait.

2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207.

Similar presentations


Presentation on theme: "2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207."— Presentation transcript:

1 2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 XO Sample Answer

2 2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.2 TO DO - Probability and statistics for game analysis In a game of noughts and crosses. If 2 players play completely randomly (correctly following the rules of the game, but showing no other intelligence regarding where/how to play at each turn) then : What is the probability that the player who starts wins the game? What is probability that the player who goes second wins the game? What is probability that the game ends in a draw? Calculate the probabilities (+/- 0.1), and test your answer through a computer simulation

3 2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.3 Number of random games = Number of wins for X (starting)= Number of wins for O (second) = My results by Java simulation of random game 1 million times My results by Java simulation of all possible games: Number of games = Number of wins for X (starting)= Number of wins for O (second) = Wins after rounds = 5 : : : : : Prob(X wins) = Prob(O wins) = Prob(draw) = 0,127 NOTE: I did not simplify for symmetry

4 2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.4 do{ permutation =gameIterator.next(); XOBoard game = new XOBoard(); gameCount++; gameOver = false; game = new XOBoard(); int playCount =0; do { game.playX(permutation[playCount]+1); playCount++; if (game.checkFull() || game.checkWinX()) gameOver = true; if (!gameOver){ game.playO(permutation[playCount]+1); playCount++; if (game.checkFull() || game.checkWinO()) gameOver = true; } } while (!gameOver); if (game.checkWinX() ) {winXCount++; winCount[playCount]++;} if (game.checkWinO() ) {winOCount++; winCount[playCount]++;} gameOver = false; } while (gameIterator.hasNext() && !gameOver); Test_Complete_Play.java (main algorithm)

5 2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.5 int winXCount =0; int winOCount =0; int NUMBER_GAMES = ; boolean gameOver = false; XOBoard game = new XOBoard(); XORandomPlay rules = new XORandomPlay(); for (int gamecount =0; gamecount< NUMBER_GAMES; gamecount++){ gameOver = false; game = new XOBoard(); do { rules.apply(game, 'X'); if (game.checkFull() || game.checkWinX()) gameOver = true; if (!gameOver){ rules.apply(game, 'O'); if (game.checkFull() || game.checkWinO()) gameOver = true; } } while (!gameOver); if (game.checkWinX() ) winXCount++; if (game.checkWinO() ) winOCount++; } Test_Statistics_RandomPlay.java (main algorithm)

6 2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.6 Probabilistic Analysis Has Been Published Elsewhere: Scientific American, Mathematical Recreations, Tic-Tac-Toe (January 2002) Steve Schaefer How many Tic-Tac-Toe (noughts and crosses) games are possible? Henry Bottomley


Download ppt "2012 J Paul GibsonTSP: Mathematical FoundationsMAT7003/L6-XO-Answer.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207."

Similar presentations


Ads by Google