All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.learning.reinforcement.example.CellWorldPercept Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
package aima.core.learning.reinforcement.example;

import aima.core.environment.cellworld.Cell;
import aima.core.learning.reinforcement.PerceptStateReward;

/**
 * An implementation of the PerceptStateReward interface for the cell world
 * environment. Note: The getCell() and setCell() methods allow a single percept
 * to be instantiated per agent within the environment. However, if an agent
 * tracks its perceived percepts it will need to explicitly copy the relevant
 * information.
 * 
 * @author oreilly
 * 
 */
public class CellWorldPercept implements PerceptStateReward> {
	private Cell cell = null;

	/**
	 * Constructor.
	 * 
	 * @param cell
	 *            the cell within the environment that the percept refers to.
	 */
	public CellWorldPercept(Cell cell) {
		this.cell = cell;
	}

	/**
	 * 
	 * @return the cell within the environment that the percept refers to.
	 */
	public Cell getCell() {
		return cell;
	}

	/**
	 * Set the cell within the environment that the percept refers to.
	 * 
	 * @param cell
	 *            the cell within the environment that the percept refers to.
	 */
	public void setCell(Cell cell) {
		this.cell = cell;
	}

	//
	// START-PerceptStateReward

	@Override
	public double reward() {
		return cell.getContent().doubleValue();
	}

	@Override
	public Cell state() {
		return cell;
	}

	// END-PerceptStateReward
	//
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy