Last active
July 20, 2017 00:20
-
-
Save vingkan/996d8f79456e6cdd94594cd9a16fb722 to your computer and use it in GitHub Desktop.
Terminal commands for syncing repositories
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
/* | |
* Example of how not to shoot your teammates | |
*/ | |
// Get all nearby ships | |
List<Ship> nearby = this.getNearbyShips(arena); | |
// Loop over all the ships | |
for (int i = 0; i < nearby.size(); i++) { | |
Ship ship = nearby.get(i); | |
// Call the getTeam() method on any ship to get its team name | |
String myTeam = this.getTeam(); | |
String theirTeam = ship.getTeam(); | |
// To compare Strings, we have to use the special .equals() method | |
// It will return true if the strings are equal and false if they are not | |
if (theirTeam.equals(myTeam)) { | |
// Don't shoot! | |
} else { | |
// In the new version of battleship, you can get any ship's coordinate, even if it is out of your range | |
// But, snce we used getNearbyShips(), all ships in this loop are in range | |
Coord coord = ship.getCoord(); | |
int x = coord.getX(); | |
int y = coord.getY(); | |
// If you run out of firepower on a turn, you can still call fire(), but your ship won't actually fire | |
this.fire(arena, x, y); | |
} | |
} |
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
Initial Map | |
00 01 02 03 04 05 06 07 08 09 | |
00 ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ | |
01 [V2] ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ [C1] | |
02 [D7] ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ [C1] | |
03 [D7] ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ [C1] | |
04 ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ |
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
# Link to the Docs | |
https://illinoistechesi.github.io/battleship/ | |
# Instructions to run a team battle | |
# Open battlehub/TeamMain.java and change the ship classes to the ones you want to use | |
# You must be in the folder that contains the battleship, battlehub, and esi17 folders to run this | |
javac battlehub/TeamMain.java | |
java battlehub.TeamMain | |
# Do the following commands for both the battleship and battlehub folders: | |
# If you run into problems, call a TA over to help you! | |
cd foldername | |
git stash save | |
git stash drop | |
git pull | |
# OPTIONAL: If you want to get the latest version of esi17, do this: | |
# WARNING: commit all your changes before doing this | |
cd esi17 | |
git remote -v | |
git remote add upstream https://github.com/illinoistechesi/esi17.git | |
git remote -v | |
git fetch upstream | |
git pull |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment