public ArrayList<Integer> getNeighbors(int position)
    {
    	ArrayList<Integer> neighborIndexes = new ArrayList<Integer>();
    	
    	int x = position % columns;
        int y = position / columns;
        
        ArrayList<Point> neighbors = new ArrayList<Point>();
        neighbors.add(new Point(x - 1, y - 1));
        neighbors.add(new Point(x, y - 1));
        neighbors.add(new Point(x + 1, y - 1));
        neighbors.add(new Point(x + 1, y));
        neighbors.add(new Point(x + 1, y + 1));
        neighbors.add(new Point(x, y + 1));
        neighbors.add(new Point(x - 1, y + 1));
        neighbors.add(new Point(x - 1, y));
        
        for (Point p : neighbors) {
            if ((p.x < 0) || (p.x > columns - 1) ||
                (p.y < 0) || (p.y > rows - 1)) {
                continue;
            }
            neighborIndexes.add(p.x + p.y * columns);
        }
        return neighborIndexes;
    }