src/ru/bosony/icfpc/Mine.java
author axmet
Fri, 13 Jul 2012 18:13:05 +0400
changeset 0 80446fa5641a
child 1 f83e1e778061
permissions -rw-r--r--
mine
     1 package ru.bosony.icfpc;
     2 
     3 import java.util.LinkedHashMap;
     4 import java.util.Map;
     5 
     6 import ru.bosony.icfpc.cells.Cell;
     7 import ru.bosony.icfpc.cells.CellTypes;
     8 
     9 /**
    10  * Шахта
    11  * 
    12  * @author akhmetovlz
    13  *
    14  */
    15 public class Mine
    16 {
    17 	private Map<Character, Cell> cellPrototypes = new LinkedHashMap<Character, Cell>();
    18 	
    19 	private Cell cells[][];
    20 	
    21 	public Mine(int n, int m, String content)
    22 	{
    23 		initCellPrototypes();
    24 		
    25 		cells = new Cell[n][m];
    26 		
    27 		int index = 0;
    28 		
    29 		for(int i=0; i<n; ++i)
    30 		for(int j=0; j<m; ++j)
    31 		{
    32 			cells[i][j] = new Cell( cellPrototypes.get(content.charAt(index++)) );
    33 		}
    34 	}
    35 	
    36 	private void initCellPrototypes()
    37 	{
    38 		cellPrototypes.put('*', new Cell(CellTypes.ROCK, '*'));
    39 		cellPrototypes.put('\\', new Cell(CellTypes.LAMBDA, '\\'));
    40 		cellPrototypes.put('#', new Cell(CellTypes.WALL, '#'));
    41 		cellPrototypes.put('R', new Cell(CellTypes.ROBOT, 'R'));
    42 		cellPrototypes.put('L', new Cell(CellTypes.CLOSED_LAMBDA_LIFT, 'L'));
    43 		cellPrototypes.put('O', new Cell(CellTypes.OPEN_LAMBDA_LIFT, 'O'));
    44 		cellPrototypes.put(' ', new Cell(CellTypes.SPACE, ' '));
    45 		cellPrototypes.put('.', new Cell(CellTypes.EARTH, '.'));
    46 	}	
    47 
    48 	void print()
    49 	{
    50 		for(int i=0; i<cells.length; ++i)
    51 		{
    52 			for(int j=0; j<cells[i].length; ++j)
    53 			{
    54 				System.out.print(cells[i][j].getASCII());
    55 			}
    56 			System.out.println();
    57 		}
    58 	}
    59 }