package wumpus;

import java.util.ArrayList;

import wumpus.Environment.*;

/**
 * Describes a single board block, that holds information on what have in.
 */
public class Block {
    private int x, y, w, h, boundry;
    private ArrayList<Items> items = new ArrayList<Items>();

    public Block(int position, int width, int height) {
        x = position % width;
        y = position / width;
        w = width;
        h = height;
        boundry = w * h;
        reset();
    }

    public int getPosition() { return x + y * w; }
    public int getPosition(int x, int y) { return x + y * w; }

    public int getX() { return x; }
    public int getY() { return y; }

    public int[] getNeighbors() {
        int[] neighbors = {-1, -1, -1, 1};

        int north = y - 1;
        int south = y + 1;
        int west = x - 1;
        int east = x + 1;

        if (north >= 0) neighbors[0] = getPosition(x, north);
        if (south < h) neighbors[1] = getPosition(x, south);
        if (west >= 0) neighbors[2] = getPosition(west, y);
        if (east < w) neighbors[2] = getPosition(east, y);

        return neighbors;
    }

    public void reset() {
        items.clear();
    }

    public void reset(Items item) {
        if (items.contains(item)) {
            items.remove(item);
        }
    }

    public boolean isEmpty() {
        return items.isEmpty();
    }

    public boolean contains(Items item) {
        return items.contains(item);
    }

    public void setItem(Items item)  {
        items.add(item);
    }
}

@@ -27,24 +27,22 @@
 va.util.
-ArrayLis
+HashSe
 t;%0A%0Aimpo
@@ -63,17 +63,21 @@
 ronment.
-*
+Items
 ;%0A%0A/**%0A 
@@ -205,17 +205,8 @@
 w, h
-, boundry
 ;%0A  
@@ -215,24 +215,22 @@
 private 
-ArrayLis
+HashSe
 t%3CItems%3E
@@ -246,16 +246,14 @@
 new 
-ArrayLis
+HashSe
 t%3CIt
@@ -257,24 +257,214 @@
 %3CItems%3E();%0A%0A
+    /**%0A     * The Block constructor.%0A     * @param position The linear position in the board%0A     * @param width The width of the board%0A     * @param height The height of the board%0A     */%0A
     public B
@@ -618,48 +618,127 @@
     
-boundry = w * h;%0A        reset();%0A
+reset();%0A    %7D%0A%0A    /**%0A     * Returns this block linear position at the board.%0A     * @return The linear index%0A 
     
-%7D%0A
+*/
 %0A   
@@ -789,144 +789,601 @@
 ; %7D%0A
-    public int getPosition(int x, int y) %7B return x + y * w; %7D%0A%0A    public int getX() %7B return x; %7D%0A    public int getY() %7B return y; %7D%0A
+%0A    /**%0A     * Returns some block linear position from a 2D position.%0A     * @return The linear index%0A     */%0A    public int getPosition(int x, int y) %7B return x + y * w; %7D%0A%0A    /**%0A     * Returns the horizontal position of this block at the board.%0A     * @return The X position%0A     */%0A    public int getX() %7B return x; %7D%0A%0A    /**%0A     * Returns the vertical position of this block at the board.%0A     * @return The Y position%0A     */%0A    public int getY() %7B return y; %7D%0A%0A    /**%0A     * Returns the blocks linear position that share the same borders%0A     * @return The neighbors array%0A     */
 %0A   
@@ -1832,32 +1832,87 @@
 ighbors;%0A    %7D%0A%0A
+    /**%0A     * Resets all items on this block.%0A     */%0A
     public void 
@@ -1943,32 +1943,145 @@
 clear();%0A    %7D%0A%0A
+    /**%0A     * Resets some type of item on this block if has on it.%0A     * @param item The item to reset%0A     */%0A
     public void 
@@ -2193,73 +2193,362 @@
     
-public boolean isEmpty() %7B%0A        return items.isEmpty();%0A    %7D%0A
+/**%0A     * Returns weather this block is empty or not.%0A     * @return %3Ctt%3Etrue%3C/tt%3E if contains no items%0A     */%0A    public boolean isEmpty() %7B%0A        return items.isEmpty();%0A    %7D%0A%0A    /**%0A     * Returns weather this block contains the item or not.%0A     * @param item The item to find%0A     * @return %3Ctt%3Etrue%3C/tt%3E if not contains the given item%0A     */
 %0A   
@@ -2626,24 +2626,103 @@
 em);%0A    %7D%0A%0A
+    /**%0A     * Adds an item to this block.%0A     * @param item The item%0A     */%0A
     public v

Add docstrings to Block class