Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var total_sides = [0,0];
- var buildings = [0,0]
- var road_tiles = [0,0];
- var excluded_types = ["hub_main","hub_part","friends_tavern","outpost_ship","off_grid"]
- for (var i in MainParser.CityMapData){
- if(excluded_types.indexOf(MainParser.CityMapData[i].type) > -1){continue}
- if(MainParser.CityMapData[i].type == "street"){
- var r = 1;
- if(MainParser.CityMapData[i].connected == 2){r = 2;}
- road_tiles[r-1] = road_tiles[r-1] + Math.pow(r,2);
- continue;
- }
- var entity = MainParser.CityEntities[MainParser.CityMapData[i].cityentity_id]
- if(!entity.requirements.hasOwnProperty("street_connection_level") || !MainParser.CityMapData[i].hasOwnProperty("connected")){continue}
- var b = 0;
- if(entity.requirements.street_connection_level == 2){b = 1;}
- total_sides[b] = total_sides[b] + Math.min(entity.length,entity.width)*entity.requirements.street_connection_level;
- buildings[b] += 1
- }
- console.log("Score = 100% * (0.5 * buildings * average_shortest_side / road_tiles)");
- // Explanation: https://old.reddit.com/r/forgeofempires/comments/kr1it0/road_efficiency_a_metric_for_an_efficient_city/gi8h0ut/
- console.log("Without unconnected buildings (that require roads) \n" +
- "1x1 Road -\t" +
- "Score: " + Math.round((1000*0.5*total_sides[0]/road_tiles[0]))/10 + " % \t | Road tiles: " + road_tiles[0] + " \t | Buildings: " + buildings[0] + " \t | Avg. Side: " + Math.round(total_sides[0]/buildings[0]*100)/100 + "\n" +
- "2x2 Road -\t" +
- "Score: " + Math.round((1000*0.5*total_sides[1]/road_tiles[1]))/10 + " % \t | Road tiles: " + road_tiles[1] + " \t | Buildings: " + buildings[1] + " \t | Avg. Side: " + Math.round((total_sides[1]/buildings[1]*100)/100)/2 + "\n" +
- "Combined -\t" +
- "Score: " + Math.round((1000*0.5*(total_sides[0]+total_sides[1])/(road_tiles[0]+road_tiles[1])))/10 + " % \t | Road tiles: " + (road_tiles[0]+road_tiles[1]) + " \t | Buildings: " + (buildings[0]+buildings[1]) + " \t | Avg. Side: " + Math.round((total_sides[0]+total_sides[1]/2)/(buildings[0]+buildings[1])*100)/100);
- total_sides = [0,0];
- buildings = [0,0]
- road_tiles = [0,0];
- excluded_types = ["hub_main","hub_part","friends_tavern","outpost_ship","off_grid"]
- for (var i in MainParser.CityMapData){
- if(excluded_types.indexOf(MainParser.CityMapData[i].type) > -1){continue}
- if(MainParser.CityMapData[i].type == "street"){
- var r = 1;
- if(MainParser.CityMapData[i].connected == 2){r = 2;}
- road_tiles[r-1] = road_tiles[r-1] + Math.pow(r,2);
- continue;
- }
- var entity = MainParser.CityEntities[MainParser.CityMapData[i].cityentity_id]
- if(!entity.requirements.hasOwnProperty("street_connection_level")){continue}
- var b = 0;
- if(entity.requirements.street_connection_level == 2){b = 1;}
- total_sides[b] = total_sides[b] + Math.min(entity.length,entity.width)*entity.requirements.street_connection_level;
- buildings[b] += 1
- }
- console.log("With unconnected buildings (that require roads) \n" +
- "1x1 Road -\t" +
- "Score: " + Math.round((1000*0.5*total_sides[0]/road_tiles[0]))/10 + " % \t | Road tiles: " + road_tiles[0] + " \t | Buildings: " + buildings[0] + " \t | Avg. Side: " + Math.round(total_sides[0]/buildings[0]*100)/100 + "\n" +
- "2x2 Road -\t" +
- "Score: " + Math.round((1000*0.5*total_sides[1]/road_tiles[1]))/10 + " % \t | Road tiles: " + road_tiles[1] + " \t | Buildings: " + buildings[1] + " \t | Avg. Side: " + Math.round((total_sides[1]/buildings[1]*100)/100)/2 + "\n" +
- "Combined -\t" +
- "Score: " + Math.round((1000*0.5*(total_sides[0]+total_sides[1])/(road_tiles[0]+road_tiles[1])))/10 + " % \t | Road tiles: " + (road_tiles[0]+road_tiles[1]) + " \t | Buildings: " + (buildings[0]+buildings[1]) + " \t | Avg. Side: " + Math.round((total_sides[0]+total_sides[1]/2)/(buildings[0]+buildings[1])*100)/100);
- var total = (CityMap.UnlockedAreas.length-1)*16+256;
- var roads = road_tiles[0] + road_tiles[1];
- var cle = Math.round(100*(total-roads)/roads)/100;
- console.log("CLE: " + cle + "\t\t (total tiles - road tiles) / road tiles");
Add Comment
Please, Sign In to add comment