1 / 6

MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207

MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public. it-sudparis.eu /~gibson/Teaching/MAT7003/. XO Sample Answer. TO DO - Probability and statistics for game analysis. In a game of noughts and crosses.

alodie
Download Presentation

MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public.it-sudparis.eu/~gibson/Teaching/MAT7003/ XO SampleAnswer TSP: MathematicalFoundations

  2. TO DO - Probability and statistics for game analysis • In a game of noughts and crosses. • If 2 playersplaycompletelyrandomly (correctlyfollowing the rules of the game, but showing no other intelligence regardingwhere/how to playateachturn) then : • Whatis the probabilitythat the playerwhostartswins the game? • Whatisprobabilitythat the playerwhogoes second wins the game? • Whatisprobabilitythat the gameends in a draw? • Calculate the probabilities (+/- 0.1), and test youranswerthrough a computer simulation TSP: MathematicalFoundations

  3. Myresults by Java simulation of randomgame 1 million times Number of random games = 1000000 Number of wins for X (starting)= 585649 Number of wins for O (second) = 287073 Myresults by Java simulation of all possible games: Number of games = 362880 Number of wins for X (starting)= 212256 Number of wins for O (second) = 104544 Winsafter rounds = 5 : 34560 6 : 31968 7 : 95904 8 : 72576 9 : 81792 NOTE: I did not simplify for symmetry Prob(X wins) = 0.5849 Prob(O wins) = 0.2881 Prob(draw) = 0,127 TSP: MathematicalFoundations

  4. Test_Complete_Play.java (main algorithm) do{ permutation =gameIterator.next(); XOBoardgame = newXOBoard(); gameCount++; gameOver = false; game = newXOBoard(); intplayCount =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); TSP: MathematicalFoundations

  5. Test_Statistics_RandomPlay.java (main algorithm) intwinXCount =0; intwinOCount =0; intNUMBER_GAMES = 1000000; booleangameOver = false; XOBoardgame = newXOBoard(); XORandomPlayrules = newXORandomPlay(); for (intgamecount =0; gamecount< NUMBER_GAMES; gamecount++){ gameOver = false; game = newXOBoard(); 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++; } TSP: MathematicalFoundations

  6. ProbabilisticAnalysis Has Been PublishedElsewhere: Scientific American, MathematicalRecreations, Tic-Tac-Toe (January 2002) Steve Schaefer http://www.mathrec.org/old/2002jan/solutions.html How many Tic-Tac-Toe (noughts and crosses) games are possible? http://www.se16.info/hgb/tictactoe.htm Henry Bottomley TSP: MathematicalFoundations

More Related