@Test
  public void testMoveStep() {
    robot = new Robot(new Energy(2400, unitOfPower.Ws), Orientation.RIGHT);
    robot.setPosition(Position.newPosition(3, 4, board));

    Program moveProgram = new Program(move, robot);
    robot.setProgram(moveProgram);

    assertEquals(1, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(2400, robot.getAmountOfEnergy(), epsilon);

    moveProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(1900, robot.getAmountOfEnergy(), epsilon);

    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();
    moveProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(1900, robot.getAmountOfEnergy(), epsilon);
  }
  @Test
  public void testWhileInSeqStep() {
    robot = new Robot(new Energy(2400, unitOfPower.Ws), Orientation.RIGHT);
    robot.setPosition(Position.newPosition(3, 4, board));

    Program whileInSeqProgram = new Program(whileinseq, robot);
    robot.setProgram(whileInSeqProgram);

    assertEquals(1, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(2400, robot.getAmountOfEnergy(), epsilon);

    whileInSeqProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(1900, robot.getAmountOfEnergy(), epsilon);

    whileInSeqProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(1400, robot.getAmountOfEnergy(), epsilon);

    whileInSeqProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(900, robot.getAmountOfEnergy(), epsilon);

    whileInSeqProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(800, robot.getAmountOfEnergy(), epsilon);

    whileInSeqProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(800, robot.getAmountOfEnergy(), epsilon);

    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();
    whileInSeqProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(5, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(6, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(7, 4, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(800, robot.getAmountOfEnergy(), epsilon);
  }
  @Test
  public void testExampleInOneLineStep() {
    robot = new Robot(new Energy(3900, unitOfPower.Ws), Orientation.RIGHT);
    robot.setPosition(Position.newPosition(3, 4, board));

    Program exampleInOneLineProgram = new Program(example, robot);
    robot.setProgram(exampleInOneLineProgram);

    assertEquals(1, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(3900, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(3400, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(3300, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(2800, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.LEFT, robot.getOrientation());
    assertEquals(2700, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(1, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.LEFT, robot.getOrientation());
    assertEquals(2200, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(1, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.UP, robot.getOrientation());
    assertEquals(2100, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(1, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.UP, robot.getOrientation());
    assertEquals(1600, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(1, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(1500, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(1000, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(900, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();
    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(900, robot.getAmountOfEnergy(), epsilon);

    exampleInOneLineProgram.step();

    assertEquals(0, Position.newPosition(3, 4, board).getElements().size());
    assertEquals(1, Position.newPosition(4, 4, board).getElements().size());
    assertEquals(0, Position.newPosition(4, 5, board).getElements().size());
    assertEquals(0, Position.newPosition(3, 5, board).getElements().size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(900, robot.getAmountOfEnergy(), epsilon);
  }
  @Test
  public void testCowboyStep() {
    robot = new Robot(new Energy(15700, unitOfPower.Ws), Orientation.RIGHT);
    robot.setPosition(Position.newPosition(3, 4, board));
    board.putElement(
        Position.newPosition(3, 2, board),
        new Robot(new Energy(5000, unitOfPower.Ws), Orientation.LEFT));
    board.putElement(
        Position.newPosition(5, 4, board),
        new Robot(new Energy(5000, unitOfPower.Ws), Orientation.LEFT));
    board.putElement(
        Position.newPosition(3, 6, board),
        new Robot(new Energy(5000, unitOfPower.Ws), Orientation.LEFT));

    Program cowboyProgram = new Program(cowboy, robot);
    robot.setProgram(cowboyProgram);

    assertEquals(4, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(15700, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(4, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(14700, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(4, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(13700, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(4, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(12700, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(4, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(11700, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(3, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.RIGHT, robot.getOrientation());
    assertEquals(10700, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(3, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(10600, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(3, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(9600, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(3, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(8600, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(3, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(7600, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(3, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(6600, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(2, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.DOWN, robot.getOrientation());
    assertEquals(5600, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(2, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.LEFT, robot.getOrientation());
    assertEquals(5500, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();

    assertEquals(2, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.UP, robot.getOrientation());
    assertEquals(5400, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();

    assertEquals(1, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.UP, robot.getOrientation());
    assertEquals(400, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();

    assertEquals(1, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.UP, robot.getOrientation());
    assertEquals(0, robot.getAmountOfEnergy(), epsilon);

    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();
    cowboyProgram.step();

    assertEquals(1, board.getElementsOf(Robot.class).size());
    assertEquals(Orientation.UP, robot.getOrientation());
    assertEquals(0, robot.getAmountOfEnergy(), epsilon);
  }