Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- class LinkedList {
- Node head;
- public boolean turn;
- public static int search=6;
- public static Model model;
- public static Update update;
- public int [][]game;
- public static int t=0;
- LinkedList(Model model, Update update) {
- this.model = model;
- this.update = update;
- head = new Node();
- game=model.getGridAllDiscs();
- turn=model.isPlayerTurn();
- if(turn==false){
- createTree(game);
- }
- }
- LinkedList(int[][]grid){
- createTree(grid);
- }
- void createTree(int[][]grid){
- game=grid;
- addAtColumn(grid,head);
- }
- void addAtColumn( int[][]grid,Node node) {
- Node pointer=node;
- if(search>0) {
- for (int i = 0; i < model.getXLength(); i++) {
- t=t+1;
- System.out.println(t);
- Node tmp = new Node();
- tmp.coordinate = getCoordinate(grid, i);
- System.out.println(tmp.coordinate);
- tmp.currentGame = placeDisc(tmp.coordinate, grid);
- pointer.moves[i] = tmp;
- addAtColumn(tmp.currentGame, tmp );
- }
- search=search-1;
- }
- System.out.println(t);
- }
- public int getHeight(int[][] grid, int column){
- int height=5;
- for (int i = 0; i < model.getYLength(); i++) {
- if (grid[column][i] != 0) {
- height=height-1;
- }
- }
- return height;
- }
- public String getCoordinate(int[][]grid,int n){
- String coords=n+","+getHeight(grid,n);
- return coords;
- }
- public int[][]placeDisc(String coords, int[][]grid){
- int[][]game=grid;
- String temp[]=coords.split(",");
- if(turn==false){
- game[Integer.parseInt(temp[0])][Integer.parseInt(temp[1])]=2;
- }else{
- game[Integer.parseInt(temp[0])][Integer.parseInt(temp[1])]=1;
- }
- return game;
- }
- }
- class Node{
- String coordinate;
- int value;
- int[][]currentGame=new int[7][6];
- Node moves[]=new Node[7];
- public void setGame(int[][]grid){
- System.out.println(coordinate);
- currentGame=grid;
- }
- public int[][]getCurrentGame(){
- return currentGame;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement