• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RobotType类的典型用法和代码示例

java 1次浏览

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

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

示例1: appendMethod

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
/**
 * Appends a method annotation to the documentation for a variant.
 *
 * @param builder the builder to append to
 * @param variant the variant to document
 * @param methodName the method to document
 */
private static void appendMethod(StringBuilder builder,
                                      RobotType variant,
                                      String methodName)
        throws NoSuchMethodException,IllegalAccessException,InvocationTargetException {

    final Method method = RobotType.class.getMethod(methodName);

    final String value;

    if (method.getReturnType() == boolean.class) {
        value = asCode(method.invoke(variant).toString());
    } else {
        throw new IllegalArgumentException("Add documentation generation for methods" +
                " that return " + method.getReturnType().getSimpleName());
    }

    builder.append(getInlineMethodLink(methodName));
    builder.append(": ");
    builder.append(value);
    builder.append("<br />");
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:29,
代码来源:RobotTypeTaglet.java

示例2: testNotTournamentLegal

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
@Test
public void testNotTournamentLegal() {
    final GameMap asymBots = new TestMapGenerator(2,1, 0)
            .withRobot(RobotType.ARCHON, Team.A, 0,0)
            .getMap("asymBots");

    assertFalse(asymBots.isTournamentLegal());

    final GameMap asymParts = new TestMapGenerator(2,2, 0)
            .withParts(0,0, 1.0)
            .withParts(0,1, 3.0)
            .getMap("asymParts");

    assertFalse(asymParts.isTournamentLegal());

    final GameMap asymRubble = new TestMapGenerator(2,2, 0)
            .withRubble(0,0, 1.0)
            .withRubble(0,1, 3.0)
            .getMap("asymRubble");

    assertFalse(asymRubble.isTournamentLegal());
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:23,
代码来源:GameMapTest.java

示例3: createTeamSpawnMenu

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private JMenu createTeamSpawnMenu(Team team) {
    String menuString = "Spawn ";
    switch (team) {
        case A: menuString += "red"; break;
        case B: menuString += "blue"; break;
        case NEUTRAL: menuString += "neutral"; break;
        case ZOMBIE: menuString += "zombie"; break;
        default: break;
    }
    JMenu menu = new JMenu(menuString);
    for (RobotType type : RobotType.values()) {
        if (type.isZombie && team != Team.ZOMBIE) {
            continue;
        }
        if (!type.isZombie && team == Team.ZOMBIE) {
            continue;
        }
        menu.add(createMenuItem(team, type));
    }
    return menu;
}
 

开发者ID:battlecode,
项目名称:battlecode-client-2016,
代码行数:22,
代码来源:DebugState.java

示例4: draw

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public void draw(Graphics2D g2, boolean focused, boolean lastRow, int
        layer) {
    // Reload the image, in case the screen was resized.
    loadImage(true);
    if (layer == 0) {
        if (RenderConfiguration.showRangeHatch() && focused) {
            drawRangeHatch(g2);
        }
        if (info.type.isBuilding && RenderConfiguration.showDetails()) {
            AffineTransform pushed0 = g2.getTransform();
            g2.translate(getDrawX(), getDrawY());
            drawImageTransformed(g2, new AffineTransform(), creep.image, 2);
            g2.setTransform(pushed0); // pop
        }
    }
    // Draw archons on layer 2 so they show up above other units
    if (layer == 1 || (layer == 2 && info.type == RobotType.ARCHON)) {
        AffineTransform pushed1 = g2.getTransform();
        g2.translate(getDrawX(), getDrawY());
        drawImmediate(g2, focused, lastRow);
        g2.setTransform(pushed1); // pop
    }
}
 

开发者ID:battlecode,
项目名称:battlecode-client-2016,
代码行数:24,
代码来源:DrawObject.java

示例5: drawCount

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public void drawCount(Graphics2D g2) {
    AffineTransform pushed = g2.getTransform();
    {
        g2.scale(spriteScale, spriteScale);

        g2.translate(-0.5, 0);
        {
            int[] counts = ds.getRobotCounts(team);
            for (RobotType rt : RobotType.values()) {
                int count = counts[rt.ordinal()];
                if (count > 0) {
                    drawTypeCount(g2, rImages.get(team).get(rt), count);
                }
            }
        }
    }

    g2.setTransform(pushed);

}
 

开发者ID:battlecode,
项目名称:battlecode-client-2016,
代码行数:21,
代码来源:DrawHUD.java

示例6: soldier_protect_tank_swarm

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public void soldier_protect_tank_swarm(){
	robot_max[RobotType.BEAVER.ordinal()] = 1;
	robot_max[RobotType.MINERFACTORY.ordinal()] = 1;
	robot_max[RobotType.MINER.ordinal()] = 12;
	robot_max[RobotType.TANK.ordinal()] = 9999;
	robot_max[RobotType.SOLDIER.ordinal()] = 12;
	
	if(robot_census[RobotType.MINERFACTORY.ordinal()] > 0)
		robot_max[RobotType.BARRACKS.ordinal()] = 1;

	if(robot_census[RobotType.BARRACKS.ordinal()] > 0)
		robot_max[RobotType.TANKFACTORY.ordinal()] = 1;
	
	if(robot_controller.getTeamOre() > 800 )
		robot_max[RobotType.TANKFACTORY.ordinal()] = 3;

	if(Clock.getRoundNum()> (TEMPORAL_HASH - 110)){
		robot_max[RobotType.HANDWASHSTATION.ordinal()] = 100;
		robot_max[RobotType.DRONE.ordinal()] = 0;
		robot_max[RobotType.LAUNCHER.ordinal()] = 0;
	} 
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:23,
代码来源:Arobot.java

示例7: spawn_robot

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean spawn_robot(RobotType required_type){		
		if(robot_controller.hasSpawnRequirements(required_type))
			for (final Direction direction: directions)
				if(robot_controller.canSpawn(direction, required_type))
					try{
						if(!robot_controller.isCoreReady())
							return true; //quit building as we now have core delay. must have gone over byte boundary
						robot_controller.spawn(direction,required_type);
						send_broadcast(cumulative_ore_spent, read_broadcast(cumulative_ore_spent) + required_type.oreCost);
						send_broadcast(troop_count_channel+required_type.ordinal(), robot_census[required_type.ordinal()]+ 1);
						return true;
					} catch(Exception e){
						Utilities.print_exception(e);
					}
	return false;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:17,
代码来源:Building.java

示例8: construct

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
static void construct(RobotType t) throws GameActionException {
	switch (t) {
	case NOISETOWER:
		add(-1, casteChannel + NTREQ);
		rc.construct(RobotType.NOISETOWER);
		while (true) {
			add(1, QUEUEDNOISETOWER);
			rc.yield();
		}
	default:
		add(-1, casteChannel + PASTRREQ);
		rc.construct(RobotType.PASTR);
		while (true) {
			add(1, QUEUEDPASTR);
			rc.yield();
		}
	}
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:19,
代码来源:Soldier.java

示例9: trySelfDestruct

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static boolean trySelfDestruct() throws GameActionException {
	double maxDamage = GameConstants.SELF_DESTRUCT_BASE_DAMAGE
			+ GameConstants.SELF_DESTRUCT_DAMAGE_FACTOR * health;
	double damageDealt = 0;
	for (RobotInfo info : attackableEnemies) {
		if (info.location.isAdjacentTo(here)
				&& info.type == RobotType.SOLDIER && !info.isConstructing) {
			damageDealt += Math.min(info.health, maxDamage);
		}
	}
	damageDealt -= maxDamage
			* rc.senseNearbyGameObjects(Robot.class, here, 2, us).length;
	if (damageDealt > health * 1.5
			|| (damageDealt > health && health < 1.5
					* RobotType.SOLDIER.attackPower
					* numNonConstructingSoldiersAttackingUs)) {
		MessageBoard.SELF_DESTRUCT_LOCKOUT_ROUND.writeInt(0); // OK to
																// others to
																// self-destruct
																// now
		rc.selfDestruct();
		return true;
	}
	return false;
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:26,
代码来源:BotSoldier.java

示例10: tryToKillCows

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static boolean tryToKillCows() throws GameActionException {
	MapLocation bestTarget = null;
	double mostCows = 300;
	MapLocation[] shootLocs = MapLocation.getAllMapLocationsWithinRadiusSq(
			here, RobotType.SOLDIER.attackRadiusMaxSquared);
	for (int i = shootLocs.length; i-- > 0;) { // 4 per loop
		double cows = rc.senseCowsAtLocation(shootLocs[i]); // 14
		if (cows > mostCows) { // 4
			MapLocation target = shootLocs[i];
			if (target.equals(here))
				continue;
			if (cows > 3000
					|| rc.senseNearbyGameObjects(Robot.class, target, 0, us).length == 0) {
				mostCows = cows;
				bestTarget = target;
			}
		}
	}
	if (bestTarget != null) {
		rc.attackSquare(bestTarget);
		return true;
	} else {
		return false;
	}
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:26,
代码来源:BotSoldier.java

示例11: numOtherNonSelfDestructingAlliedSoldiersAndBuildingsInAttackRange

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static int numOtherNonSelfDestructingAlliedSoldiersAndBuildingsInAttackRange(
		MapLocation loc) throws GameActionException {
	Robot[] allies = rc.senseNearbyGameObjects(Robot.class, loc,
			RobotType.SOLDIER.attackRadiusMaxSquared, us);
	if (Clock.getRoundNum() > MessageBoard.SELF_DESTRUCT_LOCKOUT_ROUND
			.readInt()) {
		return allies.length;
	} else {
		int ret = 0;
		int selfDestructorID = MessageBoard.SELF_DESTRUCT_LOCKOUT_ID
				.readInt();
		for (Robot ally : allies) {
			if (ally.getID() != selfDestructorID)
				ret++;
		}
		return ret;
	}
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:19,
代码来源:BotSoldier.java

示例12: chooseHelplessAttackTarget

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static RobotInfo chooseHelplessAttackTarget()
		throws GameActionException {
	RobotInfo ret = null;
	double bestHealth = 999999;
	RobotType bestType = RobotType.SOLDIER;
	for (int i = attackableEnemies.length; i-- > 0;) {
		RobotInfo info = attackableEnemies[i];
		RobotType targetType = info.type;
		if (targetType == bestType) { // break ties between equal types by
										// health
			double targetHealth = info.health;
			if (targetHealth < bestHealth) {
				bestHealth = targetHealth;
				ret = info;
			}
		} else if (targetType == RobotType.PASTR
				|| bestType == RobotType.SOLDIER) { // prefer pastrs to
													// noise towers to
													// constructing soldiers
			bestType = targetType;
			bestHealth = info.health;
			ret = info;
		}
	}
	return ret;
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:27,
代码来源:BotSoldier.java

示例13: countNumEnemiesAttackingMoveDirs

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static int[] countNumEnemiesAttackingMoveDirs() {
	if (cachedNumEnemiesAttackingMoveDirs == null) {
		cachedNumEnemiesAttackingMoveDirs = new int[8];
		for (int i = visibleEnemies.length; i-- > 0;) {
			RobotInfo info = visibleEnemies[i];
			if (info.type == RobotType.SOLDIER && !info.isConstructing) {
				MapLocation enemyLoc = info.location;
				int[] attackedDirs = attackNotes[5 + enemyLoc.x - here.x][5
						+ enemyLoc.y - here.y];
				for (int j = attackedDirs.length; j-- > 0;) {
					cachedNumEnemiesAttackingMoveDirs[attackedDirs[j]]++;
				}
			}
		}
	}
	return cachedNumEnemiesAttackingMoveDirs;
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:18,
代码来源:BotSoldier.java

示例14: RouteNode

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public RouteNode(MapLocation theLocation,MapLocation theDestination,RobotController theBot,int depth){
	myLocation = theLocation;
	myDestination = theDestination;
	bot = theBot;
	
	if(bot.senseTerrainTile(theDestination)==TerrainTile.OFF_MAP || (bot.senseTerrainTile(theDestination)==TerrainTile.VOID && !(bot.getType() == RobotType.DRONE) ))
		myDestination = myLocation;
	if(myLocation.equals(myDestination))
		return;
	if(depth>MAXDEPTH)
		return;
	myDepth = depth;
	process(myLocation);
	choosePath();
	optimiseMap();
	
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:18,
代码来源:RouteNode.java

示例15: sense_hostile_activity

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean sense_hostile_activity() {
	if(sensed_enemy_robots == null){
		positions_of_close_enemies = null;
		attack_ranges_of_close_enemies = null;
		return false;
	}
	positions_of_close_enemies = new MapLocation[sensed_enemy_robots.length];
	attack_ranges_of_close_enemies = new int[sensed_enemy_robots.length];
	
	boolean I_am_indeed_in_danger = false;
	for(int i=0; i<sensed_enemy_robots.length;i++){
		positions_of_close_enemies[i] = sensed_enemy_robots[i].location;
		attack_ranges_of_close_enemies[i] = get_attack_radius(sensed_enemy_robots[i].type);
		if(sensed_enemy_robots[i].type.equals(RobotType.HQ) || sensed_enemy_robots[i].type.equals(RobotType.TOWER)){
			attack_ranges_of_close_enemies[i] = 0;
		}else{
			if(sensed_enemy_robots[i].type.equals(RobotType.MISSILE))
				missile_exclusion_zone = sensed_enemy_robots[i].location.add(robot_controller.getLocation().directionTo(sensed_enemy_robots[i].location),2);
			modify_attack_range_after_considering_relative_delays(i,sensed_enemy_robots[i]);
		}
		if(positions_of_close_enemies[i].distanceSquaredTo(robot_controller.getLocation()) <= attack_ranges_of_close_enemies[i])
			I_am_indeed_in_danger = true;
	}
	return I_am_indeed_in_danger;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:26,
代码来源:Mobile.java

示例16: turn

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static void turn() throws GameActionException {
	if (rc.getHealth() < lastHealth) {
		MessageBoard.COLLAPSE_TO_PASTR_SIGNAL
				.writeInt(Clock.getRoundNum() + 30);
	}
	lastHealth = rc.getHealth();

	if (rc.getHealth() <= 6 * RobotType.SOLDIER.attackPower) {
		MessageBoard.PASTR_DISTRESS_SIGNAL.writeInt(Clock.getRoundNum());
	}

	// do speculative pathing calculations
	int bytecodeLimit = 9000;
	MapLocation[] enemyPastrs = rc.sensePastrLocations(them);
	for (int i = 0; i < enemyPastrs.length; i++) {
		if (Clock.getBytecodeNum() > bytecodeLimit)
			break;
		Bfs.work(enemyPastrs[i], Bfs.PRIORITY_LOW, bytecodeLimit);
	}
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:21,
代码来源:BotPastr.java

示例17: build_structure

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean build_structure(RobotType required_type){			
		if(robot_controller.hasBuildRequirements(required_type))
			for (final Direction direction: directions){
				MapLocation test_location = robot_controller.getLocation().add(direction);
				if((test_location.x + test_location.y) % 2 == 0 && robot_controller.canBuild(direction, required_type))
					try{
						if(!robot_controller.isCoreReady())
							return true;
						robot_controller.build(direction,required_type);
						send_broadcast(cumulative_ore_spent, read_broadcast(cumulative_ore_spent) + required_type.oreCost);
						send_broadcast(troop_count_channel+required_type.ordinal(), read_broadcast(troop_count_channel+required_type.ordinal()) + 1);
						return true;
					} catch(Exception e){
						Utilities.print_exception(e);
					}
			}
	return false;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:19,
代码来源:Mobile.java

示例18: Arobot

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public Arobot(RobotController rc){
	robot_controller = rc;
	my_range = robot_controller.getType().attackRadiusSquared;
	my_team = robot_controller.getTeam();
	enemy_team = my_team.opponent();	
	my_type = robot_controller.getType();
	sensor_range = my_type.sensorRadiusSquared;
	
	HQ_location = robot_controller.senseHQLocation();
	enemy_HQ_Location = robot_controller.senseEnemyHQLocation();
	
	initialise_default_strategy();
	initialise_spawn_build_list();
		
	int num_of_loops = robot_types_ordinals.length;
	RobotType[] all_robots = RobotType.values();
	for(int i=0; i< num_of_loops;i++){
		robot_types_ordinals[i] = all_robots[i].ordinal();
	}
	
	sensed_enemy_robots = robot_controller.senseNearbyRobots(my_range,enemy_team);
	centre_point = new MapLocation(((HQ_location.x - enemy_HQ_Location.x)/2) + enemy_HQ_Location.x,((HQ_location.y - enemy_HQ_Location.y)/2) + enemy_HQ_Location.y);
	previous_health = robot_controller.getHealth();
	
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:26,
代码来源:Arobot.java

示例19: closestNonHQ

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public static MapLocation closestNonHQ(RobotInfo[] infos, RobotController rc) {
	MapLocation ret = null;
	int bestDistSq = 999999;
	for (int i = infos.length; i-- > 0;) {
		RobotInfo info = infos[i];
		if (info.type == RobotType.HQ)
			continue;
		MapLocation loc = info.location;
		int distSq = loc.distanceSquaredTo(rc.getLocation());
		if (distSq < bestDistSq) {
			bestDistSq = distSq;
			ret = loc;
		}
	}
	return ret;
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:17,
代码来源:Util.java

示例20: closestNonConstructingSoldier

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public static MapLocation closestNonConstructingSoldier(RobotInfo[] infos,
		MapLocation here) {
	MapLocation ret = null;
	int bestDistSq = 999999;
	for (int i = infos.length; i-- > 0;) {
		RobotInfo info = infos[i];
		if (info.type != RobotType.SOLDIER || info.isConstructing)
			continue;
		MapLocation loc = info.location;
		int distSq = loc.distanceSquaredTo(here);
		if (distSq < bestDistSq) {
			bestDistSq = distSq;
			ret = loc;
		}
	}
	return ret;
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:18,
代码来源:Util.java

示例21: findSoldierCenterOfMass

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private static MapLocation findSoldierCenterOfMass() {
	int x = 0;
	int y = 0;
	int N = 0;
	for (int i = allAllies.length; i-- > 0;) {
		RobotInfo ally = allAllies[i];
		if (ally.type == RobotType.SOLDIER && !ally.isConstructing) {
			MapLocation allyLoc = ally.location;
			x += allyLoc.x;
			y += allyLoc.y;
			N++;
		}
	}
	if (N == 0)
		return null;
	return new MapLocation(x / N, y / N);
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:18,
代码来源:BotHQ.java

示例22: init

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
@Override
protected void init() throws GameActionException {
	Channel.announceSoldierType(rc, RobotType.SOLDIER);
	id = Channel.requestSoldierId(rc);
	Channel.signalAlive(rc, id);

	teamId = Channel.requestTeamId(rc);
	Channel.announceTeamId(rc, id, teamId);
	rc.setIndicatorString(0, "SOLDIER [" + id + "] TEAM [" + teamId + "]");
	target = Channel.getTarget(rc, teamId);
	task = Channel.getTask(rc, teamId);

	us = rc.getTeam();
	opponent = us.opponent();
	pathFinderAStar = new PathFinderAStarFast(rc, id);
	pathFinderMLineBug = new PathFinderMLineBug(rc, pathFinderAStar.map,
			pathFinderAStar.hqSelfLoc, pathFinderAStar.hqEnemLoc,
			pathFinderAStar.ySize, pathFinderAStar.xSize);
	pathFinderMLineBug.setTarget(target);
	pathFinderGreedy = new PathFinderGreedy(rc, randall);
	enemyHq = pathFinderAStar.hqEnemLoc;
}
 

开发者ID:fabian-braun,
项目名称:reignOfDke,
代码行数:23,
代码来源:Soldier.java

示例23: i_do_more_ore_damage

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean i_do_more_ore_damage(RobotInfo robot_to_examine){
	//TODO should this be DPS as it is now, or should it be shot damage?? (DPS seems to make more sense, but I'm worried properly coded drones
	//can hit and run, keeping their DPS at max, but reducing mine as a result. therefore reducing my_ore_damage to below theirs.

	double my_delay_reduction_rate = (robot_controller.getSupplyLevel() > my_type.supplyUpkeep ? 1 : 0.5);
	double enemy_delay_reduction_rate = (robot_to_examine.supplyLevel > 0 ? 1 : 0.5);
	
	double my_ore_damage = Utilities.get_ore_per_HP_amount(robot_to_examine.type) * ((my_type.attackPower / my_type.attackDelay) * my_delay_reduction_rate);
	double enemy_ore_damage = Utilities.get_ore_per_HP_amount(my_type) * ((robot_to_examine.type.attackPower / robot_to_examine.type.attackDelay)*enemy_delay_reduction_rate);
	if(robot_to_examine.type.equals(RobotType.MINER))
		enemy_ore_damage = 0;
	
	if(my_type.equals(RobotType.MINER))
		my_ore_damage = 0;
	
	if(my_ore_damage > enemy_ore_damage)
		return true;
	return false;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:20,
代码来源:Mobile.java

示例24: dish_out_supply

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public void dish_out_supply(){	
	int start_turn = Clock.getRoundNum();
	double dish_out_amount;
	if(all_out_attack){
		dish_out_amount = robot_controller.getSupplyLevel();
	}else{
		dish_out_amount = 0;
	}
	RobotInfo[] sensed_friendly_robots = robot_controller.senseNearbyRobots(GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED, my_team);	
	
	if(sensed_friendly_robots.length < 1)
		return;
	
	dish_out_amount /= sensed_friendly_robots.length;
	for (final RobotInfo sensed_friendly_robot: sensed_friendly_robots){
		if(robot_mobile[sensed_friendly_robot.type.ordinal()] || robot_mobile[my_type.ordinal()] ==false){		
			if(!sensed_friendly_robot.type.equals(RobotType.BEAVER) && !sensed_friendly_robot.type.equals(RobotType.MINER) && !sensed_friendly_robot.type.equals(RobotType.HQ)){
				if(Clock.getRoundNum() > start_turn || Clock.getBytecodesLeft() < 550)
					return;					
				send_supply((int)dish_out_amount, sensed_friendly_robot.location);
			}
		}
	}
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:25,
代码来源:Arobot.java

示例25: i_do_more_ore_damage

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean i_do_more_ore_damage(RobotInfo robot_to_examine){
	//TODO should this be DPS as it is now, or should it be shot damage?? (DPS seems to make more sense, but I'm worried properly coded drones
	//can hit and run, keeping their DPS at max, but reducing mine as a result. therefore reducing my_ore_damage to below theirs.

	double my_delay_reduction_rate = (robot_controller.getSupplyLevel() > my_type.supplyUpkeep ? 1 : 0.5);
	double enemy_delay_reduction_rate = (robot_to_examine.supplyLevel > 0 ? 1 : 0.5);
	
	double my_ore_damage = Utilities.get_ore_per_HP_amount(robot_to_examine.type) * ((my_type.attackPower / my_type.attackDelay) * my_delay_reduction_rate);
	double enemy_ore_damage = Utilities.get_ore_per_HP_amount(my_type) * ((robot_to_examine.type.attackPower / robot_to_examine.type.attackDelay)*enemy_delay_reduction_rate);
	if(robot_to_examine.type.equals(RobotType.MINER))
		enemy_ore_damage = 0;
	
	if(my_ore_damage > enemy_ore_damage)
		return true;
	return false;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:17,
代码来源:Mobile.java

示例26: build_structure

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean build_structure(RobotType required_type){			
		if(robot_controller.hasBuildRequirements(required_type))
			for (final Direction direction: directions){
				MapLocation test_location = robot_controller.getLocation().add(direction);
				if((test_location.x + test_location.y) % 2 == 0 && robot_controller.canBuild(direction, required_type))
					try{
						if(!robot_controller.isCoreReady())
							return true;
						robot_controller.build(direction,required_type);
						send_broadcast(cumulative_ore_spent, read_broadcast(cumulative_ore_spent) + required_type.oreCost);
						send_broadcast(troop_count_channel+required_type.ordinal(), read_broadcast(troop_count_channel+required_type.ordinal()) + 1);
						return true;
					} catch(Exception e){
						Utilities.print_exception(e);
					}
			}
	//	location = Utilities.find_closest(HQ_location, robot_controller.senseTowerLocations());
	return false;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:20,
代码来源:Mobile.java

示例27: is_free_from_exclusion

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
public boolean is_free_from_exclusion(MapLocation test_location){
		//HQ
		if(!location.equals(enemy_HQ_Location) && test_location.distanceSquaredTo(enemy_HQ_Location) < get_attack_radius(RobotType.HQ))
			return false;
		//Towers
		for(MapLocation tower:enemy_towers){
			if(!location.equals(tower) && test_location.distanceSquaredTo(tower) < 25)
				return false;
			if(location.equals(tower))
				return true;
		}
	//enemies
	if(positions_of_close_enemies != null){
		int num_of_loops = positions_of_close_enemies.length;
		for(int i=0; i<num_of_loops;i++)
			if(!location.equals(positions_of_close_enemies[i]) && test_location.distanceSquaredTo(positions_of_close_enemies[i]) <= attack_ranges_of_close_enemies[i])
				return false;
	}
	//missiles
	if(!all_out_attack)
		if(missile_exclusion_zone != null && test_location.distanceSquaredTo(missile_exclusion_zone) < 81)
			return false;
	return true;
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:25,
代码来源:Mobile.java

示例28: initialise_default_strategy

点赞 3

import battlecode.common.RobotType; //导入依赖的package包/类
private void initialise_default_strategy() {		
	robot_max[RobotType.AEROSPACELAB.ordinal()] = 0;
	robot_max[RobotType.BARRACKS.ordinal()] = 0;
	robot_max[RobotType.BASHER.ordinal()] = 0;
	robot_max[RobotType.BEAVER.ordinal()] = 1;
	robot_max[RobotType.COMMANDER.ordinal()] = 0;
	robot_max[RobotType.COMPUTER.ordinal()] = 0;
	robot_max[RobotType.DRONE.ordinal()] = 0;
	robot_max[RobotType.HANDWASHSTATION.ordinal()] = 0;
	robot_max[RobotType.HELIPAD.ordinal()] = 0;
	robot_max[RobotType.HQ.ordinal()] = 0;
	robot_max[RobotType.LAUNCHER.ordinal()] = 0;
	robot_max[RobotType.MINER.ordinal()] = 0;
	robot_max[RobotType.MINERFACTORY.ordinal()] = 0;
	robot_max[RobotType.MISSILE.ordinal()] = 0;
	robot_max[RobotType.SOLDIER.ordinal()] = 0;
	robot_max[RobotType.SUPPLYDEPOT.ordinal()] = 0;
	robot_max[RobotType.TANK.ordinal()] = 0;
	robot_max[RobotType.TANKFACTORY.ordinal()] = 0;
	robot_max[RobotType.TECHNOLOGYINSTITUTE.ordinal()] = 0;
	robot_max[RobotType.TOWER.ordinal()] = 0;
	robot_max[RobotType.TRAININGFIELD.ordinal()] = 0;	
}
 

开发者ID:3urningChrome,
项目名称:battlecode2015,
代码行数:24,
代码来源:Arobot.java

示例29: BuildSignal

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
/**
 * Creates a spawn signal for a robot that hasn't been spawned yet.
 */
public BuildSignal(int parentID, MapLocation loc, RobotType type, Team team, int delay) {
    this.parentID = parentID;
    this.loc = loc;
    this.type = type;
    this.team = team;
    this.delay = delay;
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:11,
代码来源:BuildSignal.java

示例30: initXStream

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
static protected void initXStream() {
    if (xstream != null) return;
    xstream = new XStream();
    xstream.registerConverter(new IntArrayConverter());
    xstream.registerConverter(new LongArrayConverter());
    xstream.registerConverter(new DoubleArrayConverter());
    xstream.registerConverter(new MapLocationConverter());
    xstream.registerConverter(new ExtensibleMetadataConverter());
    xstream.registerConverter(new RoundDeltaConverter());
    xstream.registerConverter(new ZombieScheduleConverter());
    xstream.useAttributeFor(int.class);
    xstream.useAttributeFor(int[].class);
    xstream.useAttributeFor(long.class);
    xstream.useAttributeFor(long[].class);
    xstream.useAttributeFor(double.class);
    xstream.useAttributeFor(double[].class);
    xstream.useAttributeFor(boolean.class);
    xstream.useAttributeFor(String.class);
    xstream.useAttributeFor(battlecode.common.Direction.class);
    xstream.useAttributeFor(battlecode.common.MapLocation.class);
    xstream.useAttributeFor(battlecode.common.RobotType.class);
    xstream.useAttributeFor(battlecode.common.Team.class);
    xstream.useAttributeFor(DominationFactor.class);
    xstream.aliasPackage("sig", "battlecode.world.signal");
    xstream.aliasPackage("ser", "battlecode.serial");
    xstream.alias("game-map", GameMap.class);
    xstream.alias("initial-robot", GameMap.InitialRobotInfo.class);
    xstream.alias("zombie-count", ZombieCount.class);
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:30,
代码来源:XStreamSerializerFactory.java

示例31: appendField

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
/**
 * Appends a field annotation to the documentation for a variant.
 *
 * @param builder the builder to append to
 * @param variant the variant to document
 * @param fieldName the field to document
 */
private static void appendField(StringBuilder builder,
                                      RobotType variant,
                                      String fieldName)
        throws NoSuchFieldException, IllegalAccessException {

    final Field field = RobotType.class.getField(fieldName);

    final String value;

    if (field.getType() == int.class) {
        value = asCode(Integer.toString(field.getInt(variant)));
    } else if (field.getType() == double.class) {
        value = asCode(String.format("%1.0f", field.getDouble(variant)));
    } else if (field.getType() == boolean.class) {
        value = asCode(Boolean.toString(field.getBoolean(variant)));
    } else if (field.getType() == RobotType.class) {
        final RobotType targetType = (RobotType) field.get(variant);
        value = getInlineFieldLink(targetType.name());
    } else {
        throw new IllegalArgumentException("Add documentation generation for fields" +
                " of type " + field.getType().getSimpleName());
    }

    builder.append(getInlineFieldLink(fieldName));
    builder.append(": ");
    builder.append(value);
    builder.append("<br />");
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:36,
代码来源:RobotTypeTaglet.java

示例32: testDenBehaviour

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
@Test
public void testDenBehaviour() {
    // . . . Z .
    // S . . D .
    // . . . G .
    final GameMap map = new TestMapGenerator(5, 3, 100)
            .withRobot(RobotType.ZOMBIEDEN, Team.ZOMBIE, 3, 1)
            .withRobot(RobotType.STANDARDZOMBIE, Team.ZOMBIE, 3, 0)
            .withRobot(RobotType.GUARD, Team.A, 3, 2)
            .withRobot(RobotType.SOLDIER, Team.A, 0, 1)
            .withZombieSpawn(0, RobotType.STANDARDZOMBIE, 7)
            .getMap("map");

    final GameWorld world = new GameWorld(map, zombieControlProvider, "", "", new long[2][GameConstants.TEAM_MEMORY_LENGTH]);

    final InternalRobot soldier = world.gameObjectsByID.values().stream()
            .filter(r -> r.getType() == RobotType.SOLDIER).findFirst().get();
    final InternalRobot guard = world.gameObjectsByID.values().stream()
            .filter(r -> r.getType() == RobotType.GUARD).findFirst().get();
    final InternalRobot zombie = world.gameObjectsByID.values().stream()
            .filter(r -> r.getType() == RobotType.STANDARDZOMBIE).findFirst().get();

    world.runRound();

    // There should now be 7 zombies
    assertEquals(7, world.getRobotTypeCount(Team.ZOMBIE, RobotType.STANDARDZOMBIE));

    // guard should take damage
    assertEquals(RobotType.GUARD.maxHealth - GameConstants.DEN_SPAWN_PROXIMITY_DAMAGE,
            guard.getHealthLevel(), 1e-9);

    // soldier and zombie should not
    assertEquals(RobotType.SOLDIER.maxHealth, soldier.getHealthLevel(), 1e-9);
    assertEquals(RobotType.STANDARDZOMBIE.maxHealth, zombie.getHealthLevel(), 1e-9);

}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:37,
代码来源:ZombieControlProviderTest.java

示例33: testRoundTrip

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
/**
 * Writes a map to a file and then reads it. A basic test to make sure
 * GameMapIO reads map files properly.
 *
 * @throws IOException shouldn't happen.
 */
@Test(timeout=5000)
public void testRoundTrip() throws IOException {
    int width = 50;
    int height = 80;
    int rounds = 2123;
    int seed = 1234;

    TestMapGenerator gen = new TestMapGenerator(width, height, rounds)
            .withSeed(seed)
            .withRubble(1, 1, 100)
            .withRubble(48, 78, 100)
            .withParts(0, 1, 111)
            .withParts(1, 0, 111)
            .withParts(49, 78, 111)
            .withParts(48, 79, 111)
            .withZombieSpawn(100, RobotType.FASTZOMBIE, 12)
            .withZombieSpawn(500, RobotType.RANGEDZOMBIE, 15)
            .withZombieSpawn(500, RobotType.FASTZOMBIE, 100)
            .withRobot(RobotType.ARCHON, Team.A, 0, 0)
            .withRobot(RobotType.ARCHON, Team.B, 49, 79)
            .withRobot(RobotType.ZOMBIEDEN, Team.ZOMBIE, 0, 79)
            .withRobot(RobotType.ZOMBIEDEN, Team.ZOMBIE, 49, 0);

    final GameMap inputMap = gen.getMap("basicMap");

    final File tempDir = Files.createTempDirectory("battlecode-test").toFile();
    tempDir.deleteOnExit();

    GameMapIO.writeMap(inputMap, tempDir);

    assertTrue(GameMapIO.getAvailableMaps(tempDir.toString()).contains("basicMap"));

    final GameMap outputMap = GameMapIO.loadMap("basicMap", tempDir);

    assertTrue(inputMap.equals(outputMap));
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:43,
代码来源:GameMapIOTest.java

示例34: setupController

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
@Before
public void setupController() {
    // Uses the "mockito" library to create a mock RobotController object,
    // so that we don't have to create a GameWorld and all that
    rc = mock(RobotController.class);

    // SandboxedRobotPlayer uses rc.getTeam; tell it we're team A
    when(rc.getTeam()).thenReturn(Team.A);
    when(rc.getType()).thenReturn(RobotType.ARCHON);
    when(rc.getID()).thenReturn(0);
    when(rc.getLocation()).thenReturn(new MapLocation(0, 0));
    when(rc.getRoundNum()).thenReturn(0);

    cache = new IndividualClassLoader.Cache();
}
 

开发者ID:battlecode,
项目名称:battlecode-server-2016,
代码行数:16,
代码来源:SandboxedRobotPlayerTest.java

示例35: doPopupAction

点赞 2

import battlecode.common.RobotType; //导入依赖的package包/类
private void doPopupAction(String cmd) {
    switch (cmd) {
        case CONTROL_BITS_CMD:
            String bits = (String) JOptionPane.showInputDialog(modalParent,
                    "Set control bits to (8-byte hexadecimal):", "Input",
                    JOptionPane.PLAIN_MESSAGE, null, null,
                    String.format("%016X", controlBits));
            if (bits == null) {
                return;
            }
            try {
                long value = (new java.math.BigInteger(bits, 16)).longValue();
                proxy.writeNotification(new InjectNotification(new ControlBitsSignal(targetID, value)));
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(modalParent,
                        bits + " is not a valid 8-byte hexadecimal.",
                        "Invalid input",
                        JOptionPane.WARNING_MESSAGE);
            }
            break;
        case KILL_ROBOT_CMD:
            proxy.writeNotification(new InjectNotification(new DeathSignal(targetID)));
            break;
        default:
            String[] split = cmd.split(" ");
            Team team = Enum.valueOf(Team.class, split[0]);
            RobotType type = Enum.valueOf(RobotType.class, split[1]);
            proxy.writeNotification(new InjectNotification(new SpawnSignal(spawnLoc, type, team, null, 0)));
            break;
    }
}
 

开发者ID:battlecode,
项目名称:battlecode-client-2016,
代码行数:32,
代码来源:DebugState.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)