Package game

Examples of game.RunTree


 
  public static double bruteForce(PlayingField pf, int level, double probability, int type, int rootlvl){
    double sum = 0;
    if(level > 0){     
      if(type==1){
        RunTree R1 = null;
        RunTree R2 = null;
        RunTree R3 = null;
        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{
            sum += bruteForce(pdown, level, probability*1,2,rootlvl);
            dirs++;
          }
        }
       
        if(level == rootlvl){
          while((R1!=null && R1.isAlive()) || (R2!=null && R2.isAlive()) || (R3!=null &&R3.isAlive()) || (R4!=null &&R4.isAlive())){
           
          }
          double a = 0; if(R1 != null) a = R1.getResult();
          double b = 0; if(R2 != null) b = R2.getResult();
          double c = 0; if(R3 != null) c = R3.getResult();
          double d = 0; if(R4 != null) d = R4.getResult();
         
          double [] sums = new double []{ a, b, c, d };
          double best=-1;
          int index=-1;
          for(int i=0;i<sums.length;i++){
View Full Code Here

TOP

Related Classes of game.RunTree

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.