Package pdp.scrabble.game

Examples of pdp.scrabble.game.GameEnvironment


     * @param args
     */
    public static void main(String[] args) {
 
  //preparing environment
  GameEnvironment env = new GameEnvImpl(null, 2, "Francais");
  env.bag().fill();
  b = env.board();
  ia = new DecoAI(env, "trololol", 0, null);
  DecoAI ia2 = new DecoAI(env, "loiloiloi", 1, null);
  ia2.getRack().fill();
  ia.getRack().fill();
  env.addPlayer(ia);
  env.addPlayer(ia2);
  algo = new SimpleSimulator(
    new DawgMoveGen(env, ia,(DAWGItf) env.getDictionary(),
      new BestMoves(new EvaluatorImpl(env, null), 5))
    , env, ia);
  //preparing GUI
  JButton bouton = new JButton("Continuer");
  pan = new BoardPanel(b);
View Full Code Here


  /*   give him unseen letters
  /*   run simulation
  /*   get result
  /* return average */

  GameEnvironment localEnv = internalEnv.clone();
  Player simPlayer = localEnv.getPlayer(usedPlayer.getID());

  //filling opponents racks with unseen letters
  for (Player p : localEnv.getPlayerList())
      if (p.getID()!=simPlayer.getID())
    p.getRack().fill();

  //playing submitted move
  move.play(localEnv.board(), simPlayer);
  simPlayer.addScore(localEnv.board().getWordPoints());
  try {
      localEnv.board().validate(true);
  } catch (BoardWrongWordPlace e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  simPlayer.getRack().fill();
 
  //completing first turn
  for (Player p : localEnv.getPlayerList()) {
      if (p.getID()!=simPlayer.getID()) {
    generationAlgo.generate(localEnv.board(), p.getRack());
    generationAlgo.getBestMove().play(localEnv.board(), p);
    p.addScore(localEnv.board().getWordPoints());
    try {
        localEnv.board().validate(true);
    } catch (BoardWrongWordPlace e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
      }
  }

  //playing remaining turns
  for (int i=0 ; i<simulationDepth ; i++) {
      for (Player p : localEnv.getPlayerList()) {
    generationAlgo.generate(localEnv.board(), p.getRack());
    generationAlgo.getBestMove().play(localEnv.board(), p);
    p.addScore(localEnv.board().getWordPoints());
    try {
        localEnv.board().validate(true);
    } catch (BoardWrongWordPlace e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
      }
  }

  //computing point differences
  Player first=localEnv.getPlayer((simPlayer.getID()==0?1:0));
  for (Player p : localEnv.getPlayerList()) {
      if (p!=simPlayer && p.getScore()>first.getScore())
    first=p;
  }
 
  return simPlayer.getScore()-first.getScore();
View Full Code Here

TOP

Related Classes of pdp.scrabble.game.GameEnvironment

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.