rendered paste body/*Main Mapper Class*/import java.util.*;public class Mapper { static Scanner ReadUserInput = new Scanner(System.in); /** * @param args */ public static void main(String[] args) { //I know...Looks stupid, but we're gonna make sure java works first =P //(Besides....Saying "Hello" is always more interesting than "Initializing Java..." Right?) System.out.println("Hello Java!"); for (int i=0; i<10; i++){ System.out.println(i); } Map_Builder builder=new Map_Builder(); builder.Build_Map(50, 50); } } /*End of Class*//*Map Class*/import java.util.Random;public class Map { private int size = 0; Cell[][] map_cells; public void set_size(int x, int y){ size = x*y; } public int get_size(){ return size; } public char get_cell_data(int x, int y){ return map_cells[x][y].getTerrain_Char(); } public void print(String s){ System.out.println(s); } /*This Comment Intentionally Left Blank*/ } /*Just trying to tidy up the close Braces*/ /*You know...Make it look all Pretty*/ /*Before you get to........*/ /************The Very End!*//*End of Class*//*Map Builder Class*/import java.util.Random;public class Map_Builder { /** * Initialize map as ocean. **/ Map world_Map = new Map(); public void Build_Map(int x, int y){ world_Map.set_size(x - 1, y - 1); world_Map.map_cells= new Cell[x][]; for (int i=0; i < world_Map.map_cells.length;i++){ world_Map.map_cells[i] = new Cell[y]; for (int j = 0; j < world_Map.map_cells[i].length; j++){ world_Map.map_cells[i][j]=new Cell(); world_Map.map_cells[i][j].set_terrain(0); } } print("Got Here!"); Populate_Grass(world_Map); } /* * Populate the map with Grass patches. * */ public void Populate_Grass(Map pass_world_Map){ double grass_Count = 0; double grass_Percent = 0; Random generator = new Random(); for (int i =1; i < world_Map.map_cells.length -1; i++){ for (int j = 1; j < world_Map.map_cells[i].length - 1; j++){ int x = generator.nextInt(100); System.out.println(x); if (x >=75){ world_Map.map_cells[i][j].set_terrain(3); } } } for (int i = 1; i < world_Map.map_cells.length - 1; i++){ for (int j = 1; j < world_Map.map_cells[i].length - 1; j++){ int NORTH = i - 1; int SOUTH = i + 1; int EAST = j + 1; int WEST = j - 1; if ((!world_Map.map_cells[i][j].isVisited()) && (world_Map.map_cells[i][j].get_terrain()==3)){ world_Map.map_cells[i][j].setVisited(true); //check surrounding cells... for (int ii = NORTH; ii < SOUTH; ii++){ for (int jj= WEST; jj < EAST; jj++){ int x = generator.nextInt(100); if (x > 20){ if ((world_Map.map_cells[ii][jj].get_terrain() != 3)){ System.out.println("x: "+ x); world_Map.map_cells[ii][jj].setVisited(true); world_Map.map_cells[ii][jj].set_terrain(3); grass_Count +=1; } } } } } } } grass_Percent=((grass_Count/ world_Map.get_size())); System.out.println("Grass_Count: " + grass_Count + " Grass_Percent: " + grass_Percent + " Size: "+ world_Map.get_size()); print("Grass Percentages calculated"); print("Map Built Sucessfully!"); Populate_Shores(world_Map); } public void Populate_Shores(Map pass_world_Map){ for (int i = 1; i < world_Map.map_cells.length - 1; i++){ for(int j = 1; j < world_Map.map_cells[i].length - 1; j++){ int NORTH = i - 1; int SOUTH = i + 1; int EAST = j + 1; int WEST = j - 1; if ((world_Map.map_cells[NORTH][j].get_terrain()==0)&&(world_Map.map_cells[SOUTH][j].get_terrain()==3)){ world_Map.map_cells[i][j].set_terrain(1); } else if ((world_Map.map_cells[SOUTH][j].get_terrain()==0)&&(world_Map.map_cells[NORTH][j].get_terrain()==3)){ world_Map.map_cells[i][j].set_terrain(1); } else if((world_Map.map_cells[i][WEST].get_terrain()==0)&&(world_Map.map_cells[i][EAST].get_terrain()==3)){ world_Map.map_cells[i][j].set_terrain(1); } else if ((world_Map.map_cells[i][EAST].get_terrain()==0)&&(world_Map.map_cells[i][WEST].get_terrain()==3)){ world_Map.map_cells[i][j].set_terrain(1); } } } Print_Map(world_Map); } public void Print_Map(Map pass_world_Map){ Map world_Map = pass_world_Map; for (int i = 0; i < world_Map.map_cells.length - 1; i++){ for (int j = 0; j < world_Map.map_cells[i].length - 1; j++){ System.out.print(world_Map.map_cells[i][j].getTerrain_Char()); } System.out.print("\n"); } } //Just a clever little Print function(); public void print(String s){ System.out.println(s); }}/*End of Class*//*Cell Class*/public class Cell { /********************Getters and Setters**********************************************/ public int get_terrain(){ return terrain_type; } public void setTerrain_Name(String terrain_Name) { Terrain_Name = terrain_Name; } public String getTerrain_Name() { return Terrain_Name; } public void setTerrain_Char(char terrain_Char) { Terrain_Char = terrain_Char; } public char getTerrain_Char() { return Terrain_Char; } public void setPassable(boolean passable) { this.passable = passable; } public boolean isPassable() { return passable; } public void setShip_pass(boolean ship_pass) { this.ship_pass = ship_pass; } public boolean isShip_pass() { return ship_pass; } public void setBuildible(boolean buildible) { this.buildible = buildible; } public boolean isBuildible() { return buildible; } public void setVisited(boolean visited) { this.visited = visited; } public boolean isVisited() { return visited; } public void setCell_weight(float cell_weight) { this.cell_weight = cell_weight; } public float getCell_weight() { return cell_weight; }/***********************************************************************************************************/ private boolean passable = false; private boolean ship_pass = false; private boolean buildible = false; private boolean visited = false; private int terrain_type; private String Terrain_Name; private char Terrain_Char; private float cell_weight=0; private String[] aterrain_name = {"Ocean", "Shore", "River", "Grassland", "Forest","Mineable Stone","Non-Mineable Stone"}; private char[] aterrain_char= {'~',',','=','-','*','%','^'}; private boolean[] apassable = {false,true,false,true,true,false,false}; private boolean[] aship_pass ={true,false,false,false,false,false,false}; private boolean[] abuildible={false, false, false, true, true, false, false}; /**Should be a number between 0 and 6 * @0 = Ocean = '~' * @1 = Shore = '$' * @2 = River = '=' * @3 = Grassland = '`' * @4 = Forest = '*' * @5 = Minable stone = '%' * @6 = Non-Minable stone = '^' */ public void set_terrain(int x){ terrain_type = x; setTerrain_Name(aterrain_name[terrain_type]); setTerrain_Char(aterrain_char[terrain_type]); setPassable(apassable[terrain_type]); setShip_pass(aship_pass[terrain_type]); setBuildible(abuildible[terrain_type]); }} /*End of Class*/