Package game

Examples of game.PlayingField


* Copyright (c) 2014 Felix Neutatz
*/

public class Test {
  public static void main(String[] args) {
    PlayingField pf = new PlayingField(4,4);
    pf.initialize(2);
    System.out.println(pf);
    pf.up();
    System.out.println(pf);
   
   
    int[][] matrix = new int[][] {
            new int[] { 0, 0, 2, 0},
            new int[] { 0, 0, 2, 1},
            new int[] { 0, 0, 1, 2},
            new int[] { 0, 0, 0, 2}
        };

    PlayingField pf1 = new PlayingField(matrix);
    System.out.println(pf1);
    pf1.up();
    System.out.println(pf1);
  }
View Full Code Here


* Copyright (c) 2014 Felix Neutatz
*/

public class Game2048 {
  public static void main(String[] args) throws IOException {
    PlayingField pf = new PlayingField(4,4);
    pf.initialize(2);
    System.out.println(pf);
   
    while(pf.movesAvailable()){
      System.out.print("Enter direction (u,d,l,r): ");
          // Read the char
      Scanner s = new Scanner(System.in);
      String str = s.nextLine();
     
      int moved = pf.moveByString(str);
          if(moved>0) pf.insertRandCell();
          System.out.println(pf);
    }
  }
View Full Code Here

*/

public class Tree {
  public static void main(String[] args) throws IOException, CloneNotSupportedException {
   
    PlayingField pf = new PlayingField(4,4);
    pf.initialize(2);
   
    /*
    int[][] matrix = new int[][] {
            new int[] { 0, 0, 0, 2},
            new int[] { 2, 0, 0, 0},
            new int[] { 0, 0, 0, 0},
            new int[] { 0, 0, 0, 0}
        };
    PlayingField pf = new PlayingField(matrix);*/
    System.out.println(pf);
   
    int level=3;
   
    int numberOfRounds=0;
    while(pf.movesAvailable()){
      int index = (int)bruteForce(pf, level, 1, 1,level);

      pf.moveByInt(index);
      System.out.println(pf);
     
     
      pf.insertRandCell(); //insert new tile
      System.out.println(pf);
     
      numberOfRounds++;
     
    }
View Full Code Here

        RunTree R4 = null;
     
        int numMoves;
        int dirs = 0;
       
        PlayingField pleft = ((PlayingField)pf.makeCopy());
        numMoves = pleft.left()
        if(numMoves>0){
          if(rootlvl == level){
            R1 = new RunTree(pleft, level);
              R1.start();             
          }else{
            sum += bruteForce(pleft, level, probability*1,2,rootlvl)
            dirs++;
          }
        }
       
        PlayingField pright = ((PlayingField)pf.makeCopy());
        numMoves = pright.right();
        if(numMoves>0){
          if(rootlvl == level){
            R2 = new RunTree(pright, level);
              R2.start();             
          }else{
            sum += bruteForce(pright, level, probability*1,2,rootlvl);
            dirs++;
          }
        }
       
        PlayingField pup = ((PlayingField)pf.makeCopy());
        numMoves = pup.up();
        if(numMoves>0){
          if(rootlvl == level){
            R3 = new RunTree(pup, level);
              R3.start();             
          }else{
            sum += bruteForce(pup, level, probability*1,2,rootlvl);
            dirs++;
          }
        }
       
        PlayingField pdown = ((PlayingField)pf.makeCopy());
        numMoves = pdown.down();
        if(numMoves>0){
          if(rootlvl == level){
            R4 = new RunTree(pdown, level);
              R4.start();             
          }else{
View Full Code Here

TOP

Related Classes of game.PlayingField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.