/*---------------------------------------------------------------------------- File: NESW.java ----------------------------------------------------------------------------*/ import java.util.Vector; /** * The NESW mouse will use a strategy that moves in the order of North * East South West. Because it is derived from the base class Smarty, * it has a memory. * * @version 1.0 11/11/2000 * * @author Andrew Bridges ... Copyright (c) 2001 * */ public class NESW extends Smarty { ////////////////////////////////////////////////////////////////////////////// // makeAMove ///////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// /** * For each turn the makeAMove method is called. The NESW mouse * will use a strategy that moves in the order of North East South * West. * * @return the direction that we should move. * */ protected Direction makeAMove() { /*------------------------------------------------------------------------ 1. This mouses strategy (NESW) will use a specific order to turn. ------------------------------------------------------------------------*/ if (passagewayOpenAt(Direction.North)) return Direction.North; if (passagewayOpenAt(Direction.East)) return Direction.East; if (passagewayOpenAt(Direction.South)) return Direction.South; if (passagewayOpenAt(Direction.West)) return Direction.West; /*------------------------------------------------------------------------ 2. If all the passagways are closed then you retreat. ------------------------------------------------------------------------*/ return Direction.Retreat; /*------------------------------------------------------------------------ Processing End (makeAMove) ------------------------------------------------------------------------*/ } } // end of ... NESW class definition