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

Examples of ee.ttu.cs.iti0011.iabb104231.k1.Board.Board


   */
  public AbstractPlayer getWinner()
  {
    // Process each player moves.
    for(Map.Entry<AbstractPlayer, BitSet> entry: moves.entrySet()){
      AbstractPlayer player = entry.getKey();
      BitSet bitset = entry.getValue();
     
      // Now parse all possibilities and apply to given player moves.
      // if intersect with winning move, then we have a winner.
      for(BitSet win: getWinning()){
View Full Code Here


  public AbstractPlayer getWinner()
  {
    Map<AbstractPlayer, ArrayList<Integer>> playerMoves = new HashMap<AbstractPlayer, ArrayList<Integer>>();
   
    for (Map.Entry<Integer, AbstractPlayer> entry : moves.entrySet()) {
      AbstractPlayer _player = entry.getValue();
      Integer cell = entry.getKey();
     
      if (!playerMoves.containsKey(_player)) playerMoves.put(_player, new ArrayList<Integer>());
      playerMoves.get(_player).add(cell);
      playerMoves.put(_player, playerMoves.get(_player));
View Full Code Here

public class BoardTests {

  @Test(expected = PlayerCantMoveTwice.class
  public void oneUserCantMoveTwiceInARow() throws PlayerCantMoveTwice, Exception
  {
    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);
   
View Full Code Here

  }
 
  @Test(expected = PositionIsAlreadyTaken.class
  public void positionIsAlreadtTaken() throws PositionIsAlreadyTaken, Exception
  {
    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);
   
View Full Code Here

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

    Board b = new Board();
    b.addPlayer(u1);
   
    try{
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

 
  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

    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));
//    }
View Full Code Here

TOP

Related Classes of ee.ttu.cs.iti0011.iabb104231.k1.Board.Board

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.