当前位置: 首页>>代码示例>>Java>>正文


Java TurnEndedEvent类代码示例

本文整理汇总了Java中robocode.control.events.TurnEndedEvent的典型用法代码示例。如果您正苦于以下问题:Java TurnEndedEvent类的具体用法?Java TurnEndedEvent怎么用?Java TurnEndedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TurnEndedEvent类属于robocode.control.events包,在下文中一共展示了TurnEndedEvent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
/**
 * Tests that a bullet is fire every turn.
 * 
 * @param event {@link TurnEndedEvent}
 */
@Override
public void onTurnEnded(TurnEndedEvent event) {

  checkBullet(event);
  checkPosition(event);

  checkEnemyDeath(event);
}
 
开发者ID:bretkikehara,项目名称:robocode-bki-hunter,代码行数:14,代码来源:TestHunter.java

示例2: checkPosition

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
/**
 * Checks Hunter's position.
 * 
 * @param event {@link TurnEndedEvent}
 */
private void checkPosition(TurnEndedEvent event) {
  ITurnSnapshot turn = event.getTurnSnapshot();

  // test to ensure we aren't in the same place.
  for (IRobotSnapshot robot : turn.getRobots()) {
    if (myRobotName.equals(robot.getName())) {
      if (this.positionX == -1) {
        // default position.
        this.positionX = robot.getX();
        this.positionY = robot.getY();
      }
      else {
        // check previous position with current position.
        boolean checkX = testDouble(this.positionX, robot.getX(), 5.0);
        boolean checkY = testDouble(this.positionY, robot.getY(), 5.0);
        if (checkX && checkY) {
          positionCheckCount += 1;
        }
        else {
          positionCheckCount = 0;
        }

        // same position for more than 10 turns.
        if (positionCheckCount > 10) {
          fail("Robot got stuck on the wall.");
        }
      }
    }
  }
}
 
开发者ID:bretkikehara,项目名称:robocode-bki-hunter,代码行数:36,代码来源:TestHunter.java

示例3: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
/**
 * Keep track of how many of WrathOfPele's bullets actually hit a target versus not hitting
 * a target.
 * 
 * @param event Info about the current state of the battle.
 */
@Override
public void onTurnEnded(TurnEndedEvent event) {
  // All active bullets belong to WrathOfPele since SittingDuck does not fire.
  IBulletSnapshot bullets[] = event.getTurnSnapshot().getBullets();
  
  for (int i = 0; i < bullets.length; i++) {
    if (bullets[i].getState().equals(BulletState.HIT_WALL)) {
      bulletsHitWall++;
    }
    if (bullets[i].getState().equals(BulletState.HIT_VICTIM)) {
      bulletsHitEnemy++;
    }
  }
}
 
开发者ID:anthonyjchriste,项目名称:robocode-ajc-wrathofpele,代码行数:21,代码来源:TestWrathOfPeleTargeting.java

示例4: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
/**
 * Keep track of how the amount of power enemy expended against WrathOfPele in bullets.
 * 
 * @param event Info about the current state of the battle.
 */
@Override
public void onTurnEnded(TurnEndedEvent event) {
  IBulletSnapshot bullets[] = event.getTurnSnapshot().getBullets();

  for (int i = 0; i < bullets.length; i++) {
    if (bullets[i].getOwnerIndex() == 0) {
      totalPower += bullets[i].getPower();
    }
  }
}
 
开发者ID:anthonyjchriste,项目名称:robocode-ajc-wrathofpele,代码行数:16,代码来源:TestWrathOfPeleBulletAvoidance.java

示例5: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
/**
 * Adds all of the bullets' powers to a sorted set. This will allow us to see how many different
 * powers were used and also what the range of powers look like. 
 * 
 * @param event Info about the current state of the battle.
 */
@Override
public void onTurnEnded(TurnEndedEvent event) {
  // All active bullets belong to WrathOfPele since SittingDuck does not fire.
  IBulletSnapshot bullets[] = event.getTurnSnapshot().getBullets();

  for (int i = 0; i < bullets.length; i++) {
    powers.add(bullets[i].getPower());
  }
}
 
开发者ID:anthonyjchriste,项目名称:robocode-ajc-wrathofpele,代码行数:16,代码来源:TestWrathOfPeleFiring.java

示例6: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
/**
 * Count the number of terms WrathOfPele hits a wall.
 * 
 * @param event Info about the current state of the battle.
 */
@Override
public void onTurnEnded(TurnEndedEvent event) {
  // All active bullets belong to WrathOfPele since SittingDuck does not fire.
  IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
  totalTurns++;
  if (robot.getState().isHitWall()) {
    turnsHitWall++;
  }
}
 
开发者ID:anthonyjchriste,项目名称:robocode-ajc-wrathofpele,代码行数:15,代码来源:TestWrathOfPeleWallAvoidance.java

示例7: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
@Override
public void onTurnEnded(TurnEndedEvent arg0) {
	// TODO Auto-generated method stub

}
 
开发者ID:atyndall,项目名称:cits4404,代码行数:6,代码来源:BattleListener.java

示例8: onTurnEnded

import robocode.control.events.TurnEndedEvent; //导入依赖的package包/类
@Override
public void onTurnEnded(TurnEndedEvent arg0) {
	// TODO Auto-generated method stub
	
}
 
开发者ID:atyndall,项目名称:cits4404,代码行数:6,代码来源:Playback.java


注:本文中的robocode.control.events.TurnEndedEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。