@@ -0,0 +1,3149 @@
+package wumpus;%0A%0Aimport java.util.ArrayList;%0A%0Aimport wumpus.Environment.*;%0A%0A/**%0A *%0A */%0Apublic class Agent %7B%0A    public enum Direction %7B%0A        N, E, S, W%0A    %7D%0A%0A    int x, y;%0A    World world;%0A%0A    Block block;%0A    ArrayList%3CPerceptions%3E perceptions = new ArrayList%3CPerceptions%3E();%0A    Direction direction = Direction.N;%0A%0A    /**%0A     * Creates a new Agent for the given World;%0A     * @param world%0A     */%0A    public Agent(World world) %7B%0A        this.world = world;%0A    %7D%0A%0A    /**%0A     * Set the current block of the agent, un-setting the last one and recalculating all perceptions%0A     * sensed from the new block.%0A     * @param x The horizontal position at the board%0A     * @param y The vertical position at the board%0A     */%0A    public void setBlock(int x, int y) %7B%0A        // Remove the Hunter from the%0A        if (block != null) %7B%0A            block.reset(Items.HUNTER);%0A        %7D%0A        block = world.getPosition(x, y);%0A        block.setItem(Items.HUNTER);%0A        // Reset senses%0A        perceptions.clear();%0A        // Senses in the current block%0A        if (block.contains(Items.GOLD)) %7B%0A            perceptions.add(Perceptions.GLITTER);%0A        %7D%0A        // Get the neighbors and find the senses%0A        int%5B%5D neighbors = block.getNeighbors();%0A        for (int i = 0; i %3C neighbors.length; i++) %7B%0A            if (neighbors%5Bi%5D %3E -1) %7B%0A                Block neighbor = world.getPosition(neighbors%5Bi%5D);%0A                // Sense a breeze when near a pit%0A                if (neighbor.contains(Items.PIT)) %7B%0A                    perceptions.add(Perceptions.BREEZE);%0A                %7D%0A                // Sense a stench when near a Wumpus%0A                if (neighbor.contains(Items.WUMPUS)) %7B%0A                    perceptions.add(Perceptions.STENCH);%0A                %7D%0A            %7D else %7B%0A                // Sense bumps%0A                if (i == 0 && direction == Direction.N %7C%7C i == 1 && direction == Direction.E %7C%7C%0A                        i == 2 && direction == Direction.S %7C%7C i == 3 && direction == Direction.W) %7B%0A                    perceptions.add(Perceptions.BUMP);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    public Direction getDirection() %7B return direction; %7D%0A%0A    /**%0A     * Returns the current block instance.%0A     * @return The Block instance%0A     */%0A    public Block getBlock() %7B%0A        return block;%0A    %7D%0A%0A    /**%0A     * Returns the list of perceptions sensed from the current block.%0A     * @return The list of perceptions%0A     */%0A    public ArrayList%3CPerceptions%3E getPerceptions() %7B%0A        return perceptions;%0A    %7D%0A%0A    /**%0A     * Returns if agent senses or not a bump.%0A     * @return If has a bump perception%0A     */%0A    public boolean hasBump() %7B%0A        return perceptions.contains(Perceptions.BUMP);%0A    %7D%0A%0A    /**%0A     * Returns if agent senses or not a breeze.%0A     * @return If has a breeze perception%0A     */%0A    public boolean hasBreeze() %7B%0A        return perceptions.contains(Perceptions.BREEZE);%0A    %7D%0A%0A    /**%0A     * Returns if agent senses or not a stenche.%0A     * @return If has a stench perception%0A     */%0A    public boolean hasStench() %7B%0A        return perceptions.contains(Perceptions.STENCH);%0A    %7D%0A%7D%0A

Create an Agent class that interacts with the board