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