MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / main

Method main

examplefuncsplayer-java-old/Player.java:6–37  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

4
5public class Player {
6 public static void main(String[] args) {
7 // MapLocation is a data structure you'll use a lot.
8 MapLocation loc = new MapLocation(Planet.Earth, 10, 20);
9 System.out.println("loc: "+loc+", one step to the Northwest: "+loc.add(Direction.Northwest));
10 System.out.println("loc x: "+loc.getX());
11
12 // One slightly weird thing: some methods are currently static methods on a static class called bc.
13 // This will eventually be fixed :/
14 System.out.println("Opposite of " + Direction.North + ": " + bc.bcDirectionOpposite(Direction.North));
15
16 // Connect to the manager, starting the game
17 GameController gc = new GameController();
18
19 // Direction is a normal java enum.
20 Direction[] directions = Direction.values();
21
22 while (true) {
23 System.out.println("Current round: "+gc.round());
24 // VecUnit is a class that you can think of as similar to ArrayList<Unit>, but immutable.
25 VecUnit units = gc.myUnits();
26 for (int i = 0; i < units.size(); i++) {
27 Unit unit = units.get(i);
28
29 // Most methods on gc take unit IDs, instead of the unit objects themselves.
30 if (gc.isMoveReady(unit.id()) && gc.canMove(unit.id(), Direction.Southeast)) {
31 gc.moveRobot(unit.id(), Direction.Southeast);
32 }
33 }
34 // Submit the actions we've done, and wait for our next turn.
35 gc.nextTurn();
36 }
37 }
38}

Callers

nothing calls this directly

Calls 3

addMethod · 0.95
roundMethod · 0.95
idMethod · 0.95

Tested by

no test coverage detected