Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def computerVsComputer (board: Array[Int], depth: Int): Unit = {
- var p1 = new RandomPlayer("");
- var p2 = new RandomPlayer("");
- var winners = List[Int]();
- var n = 0;
- println("How many games would you like to play?")
- try {
- n = StdIn.readInt();
- } catch {
- case e: NumberFormatException => println("Error: " + e)
- }
- for (i <- 0 until n) {
- winners = winners :+ play(p1, p2, board, depth, false);
- for (j <- 0 to board.size - 1) {
- board(j) = 0;
- }
- }
- print("P(x vinner) = ")
- val pWin1 = winners.count(_ == 1).toDouble / n.toDouble;
- println(pWin1);
- print("P(o vinner) = ");
- val pWin2 = winners.count(_ == -1).toDouble / n.toDouble;
- println(pWin2);
- print("P(lika) = ");
- val pWin3 = winners.count(_ == 0).toDouble / n.toDouble;
- println(pWin3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement