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

Examples of ee.ttu.cs.iti0011.iabb104231.k1.Exceptions.NumberOutOfRange


      throw new NotYourMove(player);
    }
   
    // It's already taken
    if (!getStorage().cellIsEmpty(cell)){
      throw new PositionIsAlreadyTaken();
    }
   
    if (cell < 1 || cell > 9){
      throw new NumberOutOfRange();
    }
View Full Code Here


 
    // Create AI players. Choose AIStrategy.
    // For now we test simple strategy - dumb - random cell picking
    // and CertainCellsFirst strategy - this is for 1 part.
//    AIPlayer ai1 = new AIPlayer(new Dumb(), "AI - Dumbas");
    AIPlayer ai2 = new AIPlayer(new CertainCellsFirstStrategy(), "AI - 2 lisaosa");
//    AIPlayer ai2 = new AIPlayer(new SimpleAi(), "AI - 2 lisaosa");
    AIPlayer ai1 = new AIPlayer(new SimpleAi(), "AI - 1");
//    HumanPlayer ai1 = new HumanPlayer("Priit");
//    HumanPlayer ai2 = new HumanPlayer("Eugeni");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");
View Full Code Here

 
    // Create AI players. Choose AIStrategy.
    // For now we test simple strategy - dumb - random cell picking
    // and CertainCellsFirst strategy - this is for 1 part.
//    AIPlayer ai1 = new AIPlayer(new Dumb(), "AI - Dumbas");
    AIPlayer ai2 = new AIPlayer(new CertainCellsFirstStrategy(), "AI - 2 lisaosa");
//    AIPlayer ai2 = new AIPlayer(new SimpleAi(), "AI - 2 lisaosa");
    AIPlayer ai1 = new AIPlayer(new SimpleAi(), "AI - 1");
//    HumanPlayer ai1 = new HumanPlayer("Priit");
//    HumanPlayer ai2 = new HumanPlayer("Eugeni");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");
View Full Code Here

    // For now we test simple strategy - dumb - random cell picking
    // and CertainCellsFirst strategy - this is for 1 part.
//    AIPlayer ai1 = new AIPlayer(new Dumb(), "AI - Dumbas");
    AIPlayer ai2 = new AIPlayer(new CertainCellsFirstStrategy(), "AI - 2 lisaosa");
//    AIPlayer ai2 = new AIPlayer(new SimpleAi(), "AI - 2 lisaosa");
    AIPlayer ai1 = new AIPlayer(new SimpleAi(), "AI - 1");
//    HumanPlayer ai1 = new HumanPlayer("Priit");
//    HumanPlayer ai2 = new HumanPlayer("Eugeni");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");
//    AIPlayer ai2 = new AIPlayer(new Dumb(), "AI - 2");
View Full Code Here

   
    Integer i = 0;
    while(!isFinished() && i < 10)
    {
      getRenderer().render();
      AbstractPlayer nextPlayer = whoIsNext();
      try{
        makeMove(nextPlayer, nextPlayer.yourNextMove());
      } catch(Exception e){
        output("ERROR !!!");
        output(e.getMessage());
        output(e.toString());
        e.printStackTrace();
View Full Code Here

   */
  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

TOP

Related Classes of ee.ttu.cs.iti0011.iabb104231.k1.Exceptions.NumberOutOfRange

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.