This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Battlecode 2021 | |
* Pathfinding Lecture - sample code | |
* | |
* Bug pathing and communication strategies. Run this on the map "Quadrants" for a sense of how | |
* this strategy behaves: watch the red robots in the bottom-left corner. | |
* | |
* https://www.battlecode.org/ | |
* https://github.com/battlecode/battlecode21 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIAL'S ALGORITHM - PSEUDOCODE | |
Input: | |
Source = starting location | |
TimeToTravel[u, v] = how long to travel from u to v | |
C = maximum possible time a single step takes (for example, 10) | |
Initialize Q = list of C+1 collections of locations | |
If a location we want to expand has distance d, it will be stored in Q[d % (C+1)] | |
Initialize Expanded = an array of Booleans for the map, all false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import importlib | |
import sys | |
import threading | |
EXCEPTION_BYTECODE_PENALTY = 500 | |
class Unit: |