GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — battlecode-2018/examplefuncsplayer-java/Player.java at master · battlecode/battlecode-2018

Expand file tree

/

Player.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
42 lines (35 loc) · 1.72 KB
/

Player.java

Copy path

File metadata and controls

42 lines (35 loc) · 1.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// import the API.
// See xxx for the javadocs.
import bc.*;
public class Player {
public static void main(String[] args) {
// You can use other files in this directory, and in subdirectories.
Extra extra = new Extra(27);
System.out.println(extra.toString());
// MapLocation is a data structure you'll use a lot.
MapLocation loc = new MapLocation(Planet.Earth, 10, 20);
System.out.println("loc: "+loc+", one step to the Northwest: "+loc.add(Direction.Northwest));
System.out.println("loc x: "+loc.getX());
// One slightly weird thing: some methods are currently static methods on a static class called bc.
// This will eventually be fixed :/
System.out.println("Opposite of " + Direction.North + ": " + bc.bcDirectionOpposite(Direction.North));
// Connect to the manager, starting the game
GameController gc = new GameController();
// Direction is a normal java enum.
Direction[] directions = Direction.values();
while (true) {
System.out.println("Current round: "+gc.round());
// VecUnit is a class that you can think of as similar to ArrayList<Unit>, but immutable.
VecUnit units = gc.myUnits();
for (int i = 0; i < units.size(); i++) {
Unit unit = units.get(i);
// Most methods on gc take unit IDs, instead of the unit objects themselves.
if (gc.isMoveReady(unit.id()) && gc.canMove(unit.id(), Direction.Southeast)) {
gc.moveRobot(unit.id(), Direction.Southeast);
}
}
// Submit the actions we've done, and wait for our next turn.
gc.nextTurn();
}
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.