This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.logging.Level; | |
| import java.util.logging.Logger; | |
| public class TicTacToe extends javax.swing.JFrame { | |
| static int winComb[][] = {{1,2,3},{4,5,6},{7,8,9},{1,4,7},{2,5,8},{3,6,9},{1,5,9},{3,5,7}}; | |
| public static int[][] state = {{0,0,0},{0,0,0},{0,0,0}}; | |
| Player pl1 = new Human(); | |
| Player pl2 = new Computer("mind\\layer"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Player { | |
| void playTurn(int pl,int turn){} | |
| void playerInit(){} | |
| void notifyWin(int pl){} | |
| void notifyLose(int pl){} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Human extends Player { | |
| @Override | |
| void playTurn(int pl,int turn){ | |
| while(TicTacToe.butClicked == 0); | |
| switch(TicTacToe.butClicked) | |
| { | |
| case 1 : TicTacToe.state[0][0]=pl;break; | |
| case 2 : TicTacToe.state[0][1]=pl;break; | |
| case 3 : TicTacToe.state[0][2]=pl;break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import java.util.ArrayList; | |
| public class Computer extends Player { | |
| int t=0; | |
| Node begin = new Node("000000000",0,this); | |
| Node current = begin; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| public class Node { | |
| ArrayList<Node> sub_nodes = new ArrayList<Node>(); | |
| String subNodes=""; | |
| String id=""; | |
| int pref = 0; | |
| int n=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| public class Layer { | |
| ArrayList<Node> nodes = new ArrayList<Node>(); | |
| int layerNum = 0; | |
| public Layer(int Num){ | |
| layerNum = Num; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void playTurn(int pl,int turn){ | |
| while(TicTacToe.butClicked == 0); | |
| switch(TicTacToe.butClicked) | |
| { | |
| case 1 : TicTacToe.state[0][0]=pl;break; | |
| case 2 : TicTacToe.state[0][1]=pl;break; | |
| case 3 : TicTacToe.state[0][2]=pl;break; | |
| case 4 : TicTacToe.state[1][0]=pl;break; | |
| case 5 : TicTacToe.state[1][1]=pl;break; | |
| case 6 : TicTacToe.state[1][2]=pl;break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int i=0;i<9;i++) | |
| { | |
| layerFiles[i] = new File(l+(i+1)+".nodes"); | |
| if(!layerFiles[i].exists()) | |
| { | |
| try{ | |
| layerFiles[i].createNewFile(); | |
| } | |
| catch(Exception e) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void playNext1(){ | |
| ArrayList<Node> temp = new ArrayList<Node>(); | |
| //System.out.println(id+" : "+sub_nodes.size()); | |
| long max = sub_nodes.get(0).pref; | |
| for(int i=0;i<sub_nodes.size();i++) | |
| { | |
| if(sub_nodes.get(i).pref > max) | |
| { | |
| temp.clear(); | |
| temp.add(sub_nodes.get(i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0x999Ac312D598Ab0Ac4C09463a6faf5C21A4A47Ec |
OlderNewer