src/ru/bosony/icfpc/Mine.java
changeset 0 80446fa5641a
child 1 f83e1e778061
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/ru/bosony/icfpc/Mine.java	Fri Jul 13 18:13:05 2012 +0400
     1.3 @@ -0,0 +1,59 @@
     1.4 +package ru.bosony.icfpc;
     1.5 +
     1.6 +import java.util.LinkedHashMap;
     1.7 +import java.util.Map;
     1.8 +
     1.9 +import ru.bosony.icfpc.cells.Cell;
    1.10 +import ru.bosony.icfpc.cells.CellTypes;
    1.11 +
    1.12 +/**
    1.13 + * Шахта
    1.14 + * 
    1.15 + * @author akhmetovlz
    1.16 + *
    1.17 + */
    1.18 +public class Mine
    1.19 +{
    1.20 +	private Map<Character, Cell> cellPrototypes = new LinkedHashMap<Character, Cell>();
    1.21 +	
    1.22 +	private Cell cells[][];
    1.23 +	
    1.24 +	public Mine(int n, int m, String content)
    1.25 +	{
    1.26 +		initCellPrototypes();
    1.27 +		
    1.28 +		cells = new Cell[n][m];
    1.29 +		
    1.30 +		int index = 0;
    1.31 +		
    1.32 +		for(int i=0; i<n; ++i)
    1.33 +		for(int j=0; j<m; ++j)
    1.34 +		{
    1.35 +			cells[i][j] = new Cell( cellPrototypes.get(content.charAt(index++)) );
    1.36 +		}
    1.37 +	}
    1.38 +	
    1.39 +	private void initCellPrototypes()
    1.40 +	{
    1.41 +		cellPrototypes.put('*', new Cell(CellTypes.ROCK, '*'));
    1.42 +		cellPrototypes.put('\\', new Cell(CellTypes.LAMBDA, '\\'));
    1.43 +		cellPrototypes.put('#', new Cell(CellTypes.WALL, '#'));
    1.44 +		cellPrototypes.put('R', new Cell(CellTypes.ROBOT, 'R'));
    1.45 +		cellPrototypes.put('L', new Cell(CellTypes.CLOSED_LAMBDA_LIFT, 'L'));
    1.46 +		cellPrototypes.put('O', new Cell(CellTypes.OPEN_LAMBDA_LIFT, 'O'));
    1.47 +		cellPrototypes.put(' ', new Cell(CellTypes.SPACE, ' '));
    1.48 +		cellPrototypes.put('.', new Cell(CellTypes.EARTH, '.'));
    1.49 +	}	
    1.50 +
    1.51 +	void print()
    1.52 +	{
    1.53 +		for(int i=0; i<cells.length; ++i)
    1.54 +		{
    1.55 +			for(int j=0; j<cells[i].length; ++j)
    1.56 +			{
    1.57 +				System.out.print(cells[i][j].getASCII());
    1.58 +			}
    1.59 +			System.out.println();
    1.60 +		}
    1.61 +	}
    1.62 +}