@Subscribe public void onStart(GameStartedEvent event) { Connect4Board board = Connect4World.getContext().getBoard(); // Velena funktioniert nur bei 2 Spielern ... if (getContext().getEntities(Connect4Player.class).size() != 2) throw new IllegalStateException("players != 2"); // ... 7x6 Spielfeldern ... if (board.getWidth() != Connect4Board.DEFAULT_WIDTH || board.getHeight() != Connect4Board.DEFAULT_HEIGHT) throw new IllegalStateException("board != 7x6"); // ... und genau 4 Sieg-Chips if (Connect4World.getContext().getWin() != 4) throw new IllegalStateException("win != 4"); moveCode = new String(); }
@Override public int move() { Connect4Board board = Connect4World.getContext().getBoard(); int move = random.nextInt(board.getWidth()); return !board.isFull(move) ? move : move(); }