Package ee.ttu.cs.iti0011.iabb104231.k1.Tests

Examples of ee.ttu.cs.iti0011.iabb104231.k1.Tests.BoardTests


    MockupPlayer u1 = new MockupPlayer();
    MockupPlayer u2 = new MockupPlayer();
    u1.setName("mockup 1");
    u2.setName("mockup 2");

    Board b = new Board();
    b.addPlayer(u1);
    b.addPlayer(u2);
   
    try{
      b.makeMove(u1, 1);
      b.makeMove(u1, 1);
    } catch(PlayerCantMoveTwice e){
      throw e;
    } catch(Exception j){
      throw j;
    }
View Full Code Here


    MockupPlayer u1 = new MockupPlayer();
    MockupPlayer u2 = new MockupPlayer();
    u1.setName("mockup 1");
    u2.setName("mockup 2");

    Board b = new Board();
    b.addPlayer(u1);
    b.addPlayer(u2);
   
    try{
      b.makeMove(u1, 1);
      b.makeMove(u2, 1);
    } catch(PositionIsAlreadyTaken e){
      throw e;
    } catch(Exception j){
      throw j;
    }
View Full Code Here

  public void cellNumberOutOfRange() throws NumberOutOfRange, Exception
  {
    MockupPlayer u1 = new MockupPlayer();
    u1.setName("mockup 1");

    Board b = new Board();
    b.addPlayer(u1);
   
    try{
      b.makeMove(u1, 11);
    } catch(NumberOutOfRange e){
      throw e;
    } catch(Exception j){
      throw j;
    }
View Full Code Here

   
  }
 
  public void render()
  {
    Board b = getBoard();
    LineSeparator l = new LineSeparator();
    Row r = new Row();
   
    l.render();
    r.render(cell(b.occupiedBy(1)), cell(b.occupiedBy(2)), cell(b.occupiedBy(3)));
    l.render();
    r.render(cell(b.occupiedBy(4)), cell(b.occupiedBy(5)), cell(b.occupiedBy(6)));
    l.render();
    r.render(cell(b.occupiedBy(7)), cell(b.occupiedBy(8)), cell(b.occupiedBy(9)));
    l.render();
  }
View Full Code Here

//    HumanPlayer ai2 = new HumanPlayer("Eugeni");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");

    // Will create board and add those users here.
    Board b = new Board();
    b.addPlayer(ai1);
    b.addPlayer(ai2);
   
    // Here will create renderer - how the user will see the game.
    // For now the console version is implemented.
    ConsoleRenderer c = new ConsoleRenderer();
   
    // will set marks for users - first user will get X
    // the second one will get O
    // We can set what ever you want - only one char allowed
    c.setPlayerRenderingString(ai1, "o");
    c.setPlayerRenderingString(ai2, "-");
    b.setRenderer(c);
   
//    for(int i=1; i<10; i++) {
//      b.output(i + " : " + Long.toString(b.cellToByte(i).toLongArray()[0], 2));
//    }

    // Starts the game...
    // Now workflow is given to the board and it will manage the game.
    b.startTheGame();
  }
View Full Code Here

    super(new BitSetStateStorage());
  }
 
  public Integer getNextMove(AbstractPlayer player)
  {
    Board board = getPlayer().getBoard();
    if (board.getOpenCells().size() == 0) return null;
   
    return getStorage().getNextMove(player);
  }
View Full Code Here

    super(new BitSetStateStorage());
  }
 
  public Integer getNextMove(AbstractPlayer player)
  {
    Board board = getPlayer().getBoard();
   
    if (board.getOpenCells().size() == 0) return null;
   
    ArrayList<Integer> emptyCells = board.getOpenCells();
   
    Collections.shuffle(emptyCells);
   
    return emptyCells.get(0);
  }
View Full Code Here

    return priority;
  }
 
  public Integer getNextMove(AbstractPlayer player)
  {
    Board board = getPlayer().getBoard();
   
    if (board.getOpenCells().size() == 0) return null;
   
    ArrayList<Integer> emptyCells = board.getOpenCells();

   
    for (Integer i : getPrioritezedMoves()) {
      if (emptyCells.contains(i)) {
        return i;
View Full Code Here

 
 
  public Board()
  {
//    this(new IntegersMapStateStorage());
    this(new BitSetStateStorage());
  }
View Full Code Here

{

  public SimpleAi()
  {
//    super(new SumOf15StateStorage());
    super(new BitSetStateStorage());
  }
View Full Code Here

TOP

Related Classes of ee.ttu.cs.iti0011.iabb104231.k1.Tests.BoardTests

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.