/** * Returns true if a position is marked as a terminal position; false otherwise. * @param x the x location of the agent. * @param y the y location of the agent. * @return true if a position is marked as a terminal position; false otherwise. */ public boolean isTerminalPosition(int x, int y){ return this.terminalPositions.contains(new IntPair(x, y)); }
/** * Unmarks an agent position as a terminal position. * @param x the x location of the agent. * @param y the y location of the agent. */ public void unmarkTerminalPosition(int x, int y){ this.terminalPositions.remove(new IntPair(x, y)); }
/** * Marks a position as a terminal position for the agent. * @param x the x location of the agent. * @param y the y location of the agent. */ public void markAsTerminalPosition(int x, int y){ this.terminalPositions.add(new IntPair(x, y)); }
/** * Initializes with a terminal position at the specified agent x and y locaiton. * @param x the x location of the agent * @param y the y location of the agent */ public GridWorldTerminalFunction(int x, int y){ this.terminalPositions.add(new IntPair(x, y)); }
@Override public boolean isTerminal(State s) { int x = ((GridWorldState)s).agent.x; int y = ((GridWorldState)s).agent.y; return this.terminalPositions.contains(new IntPair(x, y)); }