src/ru/bosony/icfpc/Mine.java
branchindvdum
changeset 2 be45d8e4c165
parent 1 f83e1e778061
child 3 d001179a2aa4
     1.1 --- a/src/ru/bosony/icfpc/Mine.java	Fri Jul 13 18:45:38 2012 +0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,97 +0,0 @@
     1.4 -package ru.bosony.icfpc;
     1.5 -
     1.6 -import java.nio.file.FileVisitOption;
     1.7 -import java.util.LinkedHashMap;
     1.8 -import java.util.Map;
     1.9 -
    1.10 -import ru.bosony.icfpc.cells.Cell;
    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 -	private int index = 0;
    1.24 -	
    1.25 -	public Mine(int n, int m, String content)
    1.26 -	{
    1.27 -		initCellPrototypes();
    1.28 -		
    1.29 -		cells = new Cell[2][n][m];
    1.30 -		
    1.31 -		int index = 0;
    1.32 -		
    1.33 -		for(int i=0; i<n; ++i)
    1.34 -		for(int j=0; j<m; ++j)
    1.35 -		{
    1.36 -			cells[index][i][j] = cellPrototypes.get(content.charAt(index++));
    1.37 -		}
    1.38 -	}
    1.39 -	
    1.40 -	private Cell[][] firstBuffer()
    1.41 -	{
    1.42 -		return cells[index];
    1.43 -	}
    1.44 -	
    1.45 -	private Cell[][] secondBuffer()
    1.46 -	{
    1.47 -		return cells[index==0 ? 1 : 0];
    1.48 -	}
    1.49 -	
    1.50 -	private void swapBuffers()
    1.51 -	{
    1.52 -		index = index==0 ? 1 : 0;
    1.53 -	}
    1.54 -	
    1.55 -	private void initCellPrototypes()
    1.56 -	{
    1.57 -		for(Cell c : Cell.values())
    1.58 -		{
    1.59 -			cellPrototypes.put(c.getASCII(), c);
    1.60 -		}
    1.61 -	}	
    1.62 -
    1.63 -	public void print()
    1.64 -	{
    1.65 -		for(int i=0; i<cells.length; ++i)
    1.66 -		{
    1.67 -			for(int j=0; j<cells[i].length; ++j)
    1.68 -			{
    1.69 -				System.out.print(firstBuffer()[i][j]);
    1.70 -			}
    1.71 -			System.out.println();
    1.72 -		}
    1.73 -	}
    1.74 -	
    1.75 -	public void updateAfterMove()
    1.76 -	{
    1.77 -		for(int i=0; i<cells.length; ++i)
    1.78 -		for(int j=0; j<cells[i].length; ++j)
    1.79 -		{
    1.80 -			secondBuffer()[i][j] = firstBuffer()[i][j];
    1.81 -		}
    1.82 -		
    1.83 -		for(int i=1; i<cells.length-1; ++i)
    1.84 -		for(int j=cells[i].length-1; j>1; --j)
    1.85 -		{
    1.86 -			switch(firstBuffer()[i][j])
    1.87 -			{
    1.88 -				case ROCK:
    1.89 -				{
    1.90 -					if(firstBuffer()[i][j-1] == Cell.EMPTY)
    1.91 -					{
    1.92 -						secondBuffer()[i][j] = Cell.EMPTY;
    1.93 -					}
    1.94 -				}
    1.95 -				break;
    1.96 -			}
    1.97 -		}
    1.98 -	}
    1.99 -	
   1.100 -}