001 /* 002 * Created on Feb 15, 2005 003 * 004 */ 005 package aima.games; 006 007 /** 008 * @author Ravi Mohan 009 * 010 */ 011 public class TicTacToeDemo { 012 public static void main(String[] args) { 013 System.out.println("TicTacToe Demo"); 014 System.out.println(""); 015 minimaxDemo(); 016 017 alphaBetaDemo(); 018 019 } 020 021 private static void alphaBetaDemo() { 022 System.out.println("ALPHA BETA "); 023 System.out.println(""); 024 TicTacToe t4 = new TicTacToe(); 025 while (!(t4.hasEnded())) { 026 System.out.println("\n" + t4.getPlayerToMove(t4.getState()) 027 + " playing ... "); 028 029 t4.makeAlphaBetaMove(); 030 GameState presentState = t4.getState(); 031 TicTacToeBoard board = t4.getBoard(presentState); 032 board.print(); 033 } 034 System.out.println("ALPHA BETA DEMO done"); 035 } 036 037 private static void minimaxDemo() { 038 System.out.println("MINI MAX "); 039 System.out.println(""); 040 TicTacToe t3 = new TicTacToe(); 041 while (!(t3.hasEnded())) { 042 System.out.println("\n" + t3.getPlayerToMove(t3.getState()) 043 + " playing"); 044 System.out.println(""); 045 t3.makeMiniMaxMove(); 046 GameState presentState = t3.getState(); 047 TicTacToeBoard board = t3.getBoard(presentState); 048 System.out.println(""); 049 board.print(); 050 051 } 052 System.out.println("Mini MAX DEMO done"); 053 } 054 }