-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now you can genreate map json using our fancy scripts. This comes with a base map. Note that this does not support every aspect of the Geographic Directives outlined in http://www.diplom.org/dpjudge/new/?page=Map
- Loading branch information
Showing
2 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
# --------------------------------------------------------------------- | ||
# Official names of each location, with all recognized aliases for each | ||
# The first listed alias is the official dpjudge name of the location, | ||
# and is used down below in the adjacency information, and throughout | ||
# the dpjudge. Upper- and lower-case in this area of the .map file is | ||
# completely unimportant. | ||
# --------------------------------------------------------------------- | ||
Adriatic Sea = adr adriatic | ||
Aegean Sea = aeg aegean | ||
Albania = alb | ||
Ankara = ank | ||
Apulia = apu | ||
Armenia = arm | ||
Baltic Sea = bal baltic | ||
Barents Sea = bar barents | ||
Belgium = bel | ||
Berlin = ber | ||
Black Sea = bla black | ||
Bohemia = boh | ||
Brest = bre | ||
Budapest = bud | ||
Bulgaria (east coast) = bul/ec bul(ec) bulgaria/ec bulgaria(ec) | ||
Bulgaria (south coast) = bul/sc bul(sc) bulgaria/sc bulgaria(sc) | ||
Bulgaria = bul | ||
Burgundy = bur burgandy | ||
Clyde = cly | ||
Constantinople = con | ||
Denmark = den | ||
Eastern Mediterranean = eas emed east eastern eastmed ems eme emd eas+med | ||
Edinburgh = edi | ||
English Channel = eng english channel ech eng+ch | ||
Finland = fin | ||
Galicia = gal galacia | ||
Gascony = gas | ||
Greece = gre | ||
Gulf of Lyon = lyo gol gulfofl lyon | ||
Gulf of Bothnia = bot gob both gulfofb bothnia | ||
Helgoland Bight = hel helgoland heligoland heligoland+bight | ||
Holland = hol | ||
Ionian Sea = ion ionian | ||
Irish Sea = iri irish irs | ||
Kiel = kie | ||
Liverpool = lvp livp lpl | ||
Livonia = lvn livo lvo lva | ||
London = lon | ||
Marseilles = mar mars | ||
Mid-Atlantic Ocean = mao midatlanticocean midatlantic mid mat | ||
Moscow = mos | ||
Munich = mun | ||
Naples = nap | ||
North Atlantic Ocean = nao nat | ||
North Africa = naf nora n+afr | ||
North Sea = nth norsea nts | ||
Norway = nwy nor norw | ||
Norwegian Sea = nwg norwegian norwsea nrg norg | ||
Paris = par | ||
Picardy = pic | ||
Piedmont = pie | ||
Portugal = por | ||
Prussia = pru | ||
Rome = rom | ||
Ruhr = ruh | ||
Rumania = rum | ||
Serbia = ser | ||
Sevastopol = sev sevastapol | ||
Silesia = sil | ||
Skagerrak = ska | ||
Smyrna = smy | ||
Spain (north coast) = spa/nc spa(nc) spain/nc spain(nc) spn/nc spn(nc) spa+(north+coast) | ||
Spain (south coast) = spa/sc spa(sc) spain/sc spain(sc) spn/sc spn(sc) spa+(south+coast) | ||
Spain = spa spn | ||
St Petersburg (north coast) = stp/nc stp(nc) stpete/nc stpete(nc) st.+petersburg/nc stp+(north+coast) | ||
St Petersburg (south coast) = stp/sc stp(sc) stpete/sc stpete(sc) st.+petersburg/sc stp+(south+coast) | ||
St Petersburg = stp stpete st.+petersburg st.petersburg | ||
Sweden = swe | ||
Syria = syr | ||
Trieste = tri | ||
Tunis = tun | ||
Tuscany = tus | ||
Tyrolia = tyr tyl trl tyo | ||
Tyrrhenian Sea = tys tyrr tyrrhenian tyn tyh | ||
Ukraine = ukr | ||
Venice = ven | ||
Vienna = vie | ||
Wales = wal | ||
Warsaw = war | ||
Western Mediterranean = wes wmed west western westmed wms wme wmd west+med wes+med western+med | ||
Yorkshire = yor york yonkers | ||
|
||
# ---------------------------------------------------------------- | ||
# Location adjacency information, keyed off the official dpjudge | ||
# name of the location. Here, upper- and lower-case IS important. | ||
# ---------------------------------------------------------------- | ||
WATER ADR ABUTS ALB APU ION TRI VEN | ||
WATER AEG ABUTS BUL/SC CON EAS GRE ION SMY | ||
COAST ALB ABUTS ADR GRE ION SER TRI | ||
COAST ANK ABUTS ARM BLA CON smy | ||
COAST APU ABUTS ADR ION NAP rom VEN | ||
COAST ARM ABUTS ANK BLA SEV smy syr | ||
WATER BAL ABUTS BER BOT DEN LVN KIE PRU SWE | ||
WATER BAR ABUTS NWY NWG STP/NC | ||
COAST BEL ABUTS bur ENG HOL NTH PIC RUH | ||
COAST BER ABUTS BAL KIE MUN PRU SIL | ||
WATER BLA ABUTS ANK ARM BUL/EC CON RUM SEV | ||
LAND BOH ABUTS GAL MUN SIL TYR VIE | ||
WATER BOT ABUTS BAL FIN LVN STP/SC SWE | ||
COAST BRE ABUTS ENG GAS MAO PAR PIC | ||
LAND BUD ABUTS GAL RUM SER TRI VIE | ||
COAST BUL/EC ABUTS BLA CON RUM | ||
COAST BUL/SC ABUTS AEG CON GRE | ||
COAST bul ABUTS AEG BLA CON GRE RUM SER | ||
LAND BUR ABUTS BEL GAS RUH MAR MUN PAR PIC SWI | ||
COAST CLY ABUTS EDI LVP NAO NWG | ||
COAST CON ABUTS AEG BUL/EC BUL/SC BLA ANK SMY | ||
COAST DEN ABUTS BAL HEL KIE NTH SKA SWE | ||
WATER EAS ABUTS AEG ION SMY SYR | ||
COAST EDI ABUTS CLY lvp NTH NWG YOR | ||
WATER ENG ABUTS BEL BRE IRI LON MAO NTH PIC WAL | ||
COAST FIN ABUTS BOT nwy STP/SC SWE | ||
LAND GAL ABUTS BOH BUD RUM SIL UKR VIE WAR | ||
COAST GAS ABUTS BUR BRE MAO mar PAR SPA/NC | ||
COAST GRE ABUTS AEG ALB BUL/SC ION SER | ||
WATER HEL ABUTS DEN HOL KIE NTH | ||
COAST HOL ABUTS BEL HEL KIE NTH RUH | ||
WATER ION ABUTS ADR AEG ALB APU EAS GRE NAP TUN TYS | ||
WATER IRI ABUTS ENG LVP MAO NAO WAL | ||
COAST KIE ABUTS BAL BER DEN HEL HOL MUN RUH | ||
COAST LON ABUTS ENG NTH YOR WAL | ||
COAST LVN ABUTS BAL BOT MOS PRU STP/SC WAR | ||
COAST LVP ABUTS CLY edi IRI NAO WAL yor | ||
WATER LYO ABUTS MAR PIE SPA/SC TUS TYS WES | ||
WATER MAO ABUTS BRE ENG GAS IRI NAF NAO POR SPA/NC SPA/SC WES | ||
COAST MAR ABUTS BUR gas LYO PIE SPA/SC SWI | ||
LAND MOS ABUTS LVN SEV STP UKR WAR | ||
LAND MUN ABUTS BER BOH BUR KIE RUH SIL TYR SWI | ||
COAST NAF ABUTS MAO TUN WES | ||
WATER NAO ABUTS CLY IRI LVP MAO NWG | ||
COAST NAP ABUTS APU ION ROM TYS | ||
COAST NWY ABUTS BAR fin NTH NWG SKA STP/NC SWE | ||
WATER NTH ABUTS BEL DEN EDI ENG LON HEL HOL NWY NWG SKA YOR | ||
WATER NWG ABUTS BAR CLY EDI NAO NWY NTH | ||
LAND PAR ABUTS BUR BRE GAS PIC | ||
COAST PIC ABUTS BEL BRE BUR ENG PAR | ||
COAST PIE ABUTS LYO MAR TUS TYR ven SWI | ||
COAST POR ABUTS MAO SPA/NC SPA/SC | ||
COAST PRU ABUTS BAL BER LVN SIL WAR | ||
COAST ROM ABUTS apu NAP TUS TYS ven | ||
LAND RUH ABUTS BEL BUR HOL KIE MUN | ||
COAST RUM ABUTS BLA BUD BUL/EC GAL SER SEV UKR | ||
LAND SER ABUTS ALB BUD BUL GRE RUM TRI | ||
COAST SEV ABUTS ARM BLA MOS RUM UKR | ||
LAND SIL ABUTS BER BOH GAL MUN PRU WAR | ||
WATER SKA ABUTS DEN NWY NTH SWE | ||
COAST SMY ABUTS AEG ank arm CON EAS SYR | ||
COAST SPA/NC ABUTS GAS MAO POR | ||
COAST SPA/SC ABUTS LYO MAO MAR POR WES | ||
COAST spa ABUTS GAS LYO MAO MAR POR WES | ||
COAST STP/NC ABUTS BAR NWY | ||
COAST STP/SC ABUTS BOT FIN LVN | ||
COAST stp ABUTS BAR BOT FIN LVN MOS NWY | ||
COAST SWE ABUTS BAL BOT DEN FIN NWY SKA | ||
COAST SYR ABUTS arm EAS SMY | ||
COAST TRI ABUTS ADR ALB BUD SER TYR VEN VIE | ||
COAST TUN ABUTS ION NAF TYS WES | ||
COAST TUS ABUTS LYO PIE ROM TYS ven | ||
LAND TYR ABUTS BOH MUN PIE TRI VEN VIE SWI | ||
WATER TYS ABUTS ION LYO ROM NAP TUN TUS WES | ||
LAND UKR ABUTS GAL MOS RUM SEV WAR | ||
COAST VEN ABUTS ADR APU pie rom TRI tus TYR | ||
LAND VIE ABUTS BOH BUD GAL TRI TYR | ||
COAST WAL ABUTS ENG IRI LON LVP yor | ||
LAND WAR ABUTS GAL LVN MOS PRU SIL UKR | ||
WATER WES ABUTS MAO LYO NAF SPA/SC TUN TYS | ||
COAST YOR ABUTS EDI LON lvp NTH wal | ||
|
||
# ------------------------ | ||
# Switzerland (impassable) | ||
# ------------------------ | ||
Switzerland = swi | ||
SHUT SWI ABUTS MAR BUR MUN TYR PIE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
/* | ||
* There is a great set of resources that have structured | ||
* diplomacy maps: | ||
* | ||
* http://www.diplom.org/dpjudge/new/?page=MapFiles | ||
* | ||
* This script converts .geography files to json | ||
*/ | ||
|
||
if(sizeof($argv) < 3) { | ||
echo("USAGE: php translate_map.php [path/to/input.geography] [path/to/output.json]".PHP_EOL); | ||
echo("e.g. php translate_map.php scripts/maps/base.geography data/maps/base.json".PHP_EOL); | ||
die(); | ||
} | ||
|
||
$geography_path = $argv[1]; | ||
$output_path = $argv[2]; | ||
$geography_handle = fopen($geography_path, "r"); | ||
$spaces = array(); | ||
|
||
// Load in the base data | ||
while (($line = fgets($geography_handle)) !== false) { | ||
// Skip comments | ||
if($line[0] == "#") | ||
continue; | ||
|
||
// Skip blank lines | ||
if(trim($line) == "") | ||
continue; | ||
|
||
if(($wedge = strpos($line, "=")) !== false) { | ||
$name = trim(substr($line, 0, $wedge)); | ||
$abbreviations = explode(" ", trim(substr($line, $wedge + 1))); | ||
$key = strtolower(str_replace("/", "_", $abbreviations[0])); | ||
$spaces[$key] = array( | ||
"name" => $name, | ||
"abbreviations" => $abbreviations, | ||
"type" => "", | ||
"army_moves" => array(), | ||
"fleet_moves" => array(), | ||
); | ||
} else { | ||
$parts = preg_split('/\s+/', trim($line)); | ||
$type = $parts[0]; | ||
$key = strtolower(str_replace("/", "_",$parts[1])); | ||
$moves = array_slice($parts, 3); | ||
$spaces[$key]["type"] = $type; | ||
|
||
// Armies can't be in water | ||
if($type != "WATER") { | ||
$spaces[$key]["army_moves"] = array_reduce($moves, | ||
function($carry, $item) { | ||
// Armies can move to any listed location | ||
$item = str_replace("/", "_", $item); | ||
$carry[] = strtolower($item); | ||
return $carry; | ||
}, | ||
array()); | ||
} | ||
|
||
// Fleets can't be in land | ||
if($type != "LAND") { | ||
$spaces[$key]["fleet_moves"] = array_reduce($moves, | ||
function($carry, $item) { | ||
// Fleets can move to any non-lowercase location | ||
$item = str_replace("/", "_", $item); | ||
if(ctype_upper(str_replace("_","", $item))) | ||
$carry[] = strtolower($item); | ||
return $carry; | ||
}, | ||
array()); | ||
} | ||
} | ||
} | ||
|
||
// Clean the move list to remove land / fleet | ||
// and water / army combinations | ||
foreach($spaces as $key => $space) { | ||
$fleet_moves = array(); | ||
foreach($spaces[$key]["fleet_moves"] as $move) { | ||
if($spaces[$move]["type"] != "LAND") | ||
$fleet_moves[] = $move; | ||
} | ||
$spaces[$key]["fleet_moves"] = $fleet_moves; | ||
|
||
|
||
$army_moves = array(); | ||
foreach($spaces[$key]["army_moves"] as $move) { | ||
if($spaces[$move]["type"] != "WATER") | ||
$army_moves[] = $move; | ||
} | ||
$spaces[$key]["army_moves"] = $army_moves; | ||
} | ||
fclose($geography_handle); | ||
|
||
// Spit out the results | ||
$output_handle = fopen($output_path, "w" ); | ||
fwrite($output_handle, json_encode($spaces, JSON_PRETTY_PRINT)); | ||
?> |