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

Method main

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

Callers

nothing calls this directly

Calls 4

toStringMethod · 0.95
addMethod · 0.95
roundMethod · 0.95
idMethod · 0.95

Tested by

no test coverage detected