alice.kareltherobot
Class Philosopher

java.lang.Object
  extended by edu.cmu.cs.dennisc.pattern.DefaultReleasable
      extended by edu.cmu.cs.dennisc.pattern.AbstractElement
          extended by edu.cmu.cs.dennisc.pattern.DefaultInstancePropertyOwner
              extended by org.alice.apis.moveandturn.Element
                  extended by org.alice.apis.moveandturn.Composite
                      extended by org.alice.apis.moveandturn.AbstractTransformable
                          extended by org.alice.apis.moveandturn.Transformable
                              extended by org.alice.apis.moveandturn.Model
                                  extended by org.alice.apis.moveandturn.PolygonalModel
                                      extended by org.alice.apis.moveandturn.gallery.GalleryModel
                                          extended by org.alice.apis.moveandturn.gallery.scifi.KoalaRobot
                                              extended by alice.kareltherobot.UrRobot
                                                  extended by alice.kareltherobot.Robot
                                                      extended by alice.kareltherobot.Philosopher
All Implemented Interfaces:
edu.cmu.cs.dennisc.codec.ReferenceableBinaryEncodableAndDecodable, edu.cmu.cs.dennisc.pattern.Nameable, edu.cmu.cs.dennisc.pattern.NameChangeListenable, edu.cmu.cs.dennisc.pattern.Releasable, edu.cmu.cs.dennisc.property.InstancePropertyOwner, edu.cmu.cs.dennisc.property.PropertyOwner, java.lang.Runnable, org.alice.apis.moveandturn.ReferenceFrame

public class Philosopher
extends alice.kareltherobot.Robot
implements java.lang.Runnable

A class of philosopher robots designed to simulate the classic Dining Philosophers simulation (with 4 philosophers).

Author:
Joseph Bergin

Nested Class Summary
 
Nested classes/interfaces inherited from class org.alice.apis.moveandturn.gallery.scifi.KoalaRobot
org.alice.apis.moveandturn.gallery.scifi.KoalaRobot.Part
 
Field Summary
 
Fields inherited from class org.alice.apis.moveandturn.gallery.GalleryModel
MODELED_BY_CREDIT_PROPERTY, PAINTED_BY_CREDIT_PROPERTY, PROGRAMMED_BY_CREDIT_PROPERTY
 
Fields inherited from class org.alice.apis.moveandturn.PolygonalModel
POLYGONS_PROPERTY
 
Fields inherited from class org.alice.apis.moveandturn.Model
COLOR_PROPERTY, FILLING_STYLE_PROPERTY, IS_BOUNDING_BOX_SHOWING_PROPERTY, IS_BOUNDING_SPHERE_SHOWING_PROPERTY, IS_SHOWING_PROPERTY, OPACITY_PROPERTY, POTENTIAL_SURFACE_TEXTURES_PROPERTY, SHADING_STYLE_PROPERTY, SURFACE_TEXTURE_PROPERTY, VISUAL_SCALE_PROPERTY
 
Fields inherited from class org.alice.apis.moveandturn.Transformable
DEFAULT_ORIGIN_INCLUSION_POLICY, DEFAULT_RESIZE_POLICY, DEFAULT_SET_SIZE_POLICY
 
Fields inherited from class org.alice.apis.moveandturn.AbstractTransformable
LOCAL_POINT_OF_VIEW_PROPERTY
 
Fields inherited from class org.alice.apis.moveandturn.Composite
COMPONENTS_PROPERTY, DEFAULT_DURATION, DEFAULT_HOW_MUCH, DEFAULT_SPEED_STYLE, DEFAULT_STYLE, RIGHT_NOW
 
Fields inherited from class org.alice.apis.moveandturn.Element
NAME_PROPERTY
 
Constructor Summary
Philosopher(int street, int avenue, alice.kareltherobot.Direction direction)
           
Philosopher(int street, int avenue, alice.kareltherobot.Direction direction, int beepers)
           
Philosopher(int street, int avenue, alice.kareltherobot.Direction direction, int beepers, org.alice.apis.moveandturn.Color color)
           
 
Method Summary
 void backUp()
          Back up one block and face the original direction.
 void run()
          This is the method used by the thread system (doTogether).
 void turnAround()
          Turn around by making two left turns
 void turnRight()
          Turn right by making three left turns
 
Methods inherited from class alice.kareltherobot.Robot
anyBeepersInBeeperBag, facingEast, facingNorth, facingSouth, facingWest, frontIsClear, nextToABeeper, nextToARobot
 
Methods inherited from class alice.kareltherobot.UrRobot
addToWorld, assertFacingEast, assertFacingNorth, assertFacingSouth, assertFacingWest, assertFrontIsBlocked, assertFrontIsClear, assertHasBeepers, assertHasNoBeepers, assertNextToABeeper, assertNextToARobot, assertOnAvenue, assertOnStreet, draw, getCamera, move, pickBeeper, putBeeper, setTracing, toString, turnLeft, turnOff
 
Methods inherited from class org.alice.apis.moveandturn.gallery.scifi.KoalaRobot
getPart
 
Methods inherited from class org.alice.apis.moveandturn.gallery.GalleryModel
getGalleryRootDirectory, getModeledByCredit, getPaintedByCredit, getProgrammedByCredit, main, setModeledByCredit, setPaintedByCredit, setProgrammedByCredit
 
Methods inherited from class org.alice.apis.moveandturn.PolygonalModel
getPolygons, setPolygons
 
Methods inherited from class org.alice.apis.moveandturn.Model
addMouseButtonListener, addPotentialSurfaceTexture, clearPotentialSurfaceTextures, getColor, getFillingStyle, getMouseButtonListeners, getOpacity, getOriginalScale, getPart, getPotentialSurfaceTextureIterable, getPotentialSurfaceTextures, getResizeDepthAmount, getResizeHeightAmount, getResizeWidthAmount, getSGSingleAppearance, getSGVisual, getShadingStyle, getSurfaceTexture, getVisualScale, isShowing, removeMouseButtonListener, removePotentialSurfaceTexture, setColor, setColor, setColor, setColor, setFillingStyle, setName, setOpacity, setOpacity, setOpacity, setOpacity, setPotentialSurfaceTextures, setShadingStyle, setShowing, setSurfaceTexture, setVisualScale
 
Methods inherited from class org.alice.apis.moveandturn.Transformable
addKeyListener, getAxisAlignedMinimumBoundingBox, getAxisAlignedMinimumBoundingBox, getAxisAlignedMinimumBoundingBox, getAxisAlignedMinimumBoundingBox, getBoundingSphere, getBoundingSphere, getBoundingSphere, getBoundingSphere, getDepth, getDistanceAbove, getDistanceBehind, getDistanceBelow, getDistanceInFrontOf, getDistanceTo, getDistanceToTheLeftOf, getDistanceToTheRightOf, getHeight, getKeyListeners, getSGAbstractTransformable, getSGTransformable, getVehicle, getWidth, isAbove, isAbove, isAtLeastThresholdAwayFrom, isBehind, isBehind, isBelow, isBelow, isBoundingBoxShowing, isBoundingSphereShowing, isInFrontOf, isInFrontOf, isLargerThan, isNarrowerThan, isShorterThan, isSmallerThan, isTallerThan, isThickerThan, isThinnerThan, isToTheLeftOf, isToTheLeftOf, isToTheRightOf, isToTheRightOf, isWiderThan, isWithinThresholdOf, realizeIfNecessary, removeKeyListener, resize, resize, resize, resize, resizeDepth, resizeDepth, resizeDepth, resizeDepth, resizeDepth, resizeHeight, resizeHeight, resizeHeight, resizeHeight, resizeHeight, resizeWidth, resizeWidth, resizeWidth, resizeWidth, resizeWidth, say, say, say, say, say, say, setBoundingBoxShowing, setBoundingSphereShowing, setDepth, setDepth, setDepth, setDepth, setDepth, setHeight, setHeight, setHeight, setHeight, setHeight, setVehicle, setWidth, setWidth, setWidth, setWidth, setWidth, think, think, think, think, think, think
 
Methods inherited from class org.alice.apis.moveandturn.AbstractTransformable
getLocalPointOfView, getLocalTransformation, getOrientation, getOwner, getPosition, getScene, getSGComposite, getTransformation, getTransformation, isPivotShowing, move, move, move, move, moveAndOrientTo, moveAndOrientTo, moveAndOrientTo, moveAtSpeed, moveAtSpeed, moveAtSpeed, moveAwayFrom, moveAwayFrom, moveAwayFrom, moveTo, moveTo, moveTo, moveToward, moveToward, moveToward, orientTo, orientTo, orientTo, orientToUpright, orientToUpright, orientToUpright, orientToUpright, pointAt, pointAt, pointAt, roll, roll, roll, roll, rollAtSpeed, rollAtSpeed, rollAtSpeed, setLocalPointOfView, setLocalTransformation, setPivotShowing, turn, turn, turn, turn, turnAtSpeed, turnAtSpeed, turnAtSpeed, turnToFace, turnToFace, turnToFace
 
Methods inherited from class org.alice.apis.moveandturn.Composite
addComponent, clearComponents, createOffsetStandIn, createOffsetStandIn, createOffsetStandIn, createOffsetStandIn, createOffsetStandIn, createOffsetStandIn, createOffsetStandIn, createOffsetStandInIfNecessary, delay, findAllMatches, findAllMatches, findAllMatches, findAllMatches, findAllMatches, findFirstDescendantNamed, findFirstMatch, findFirstMatch, findFirstMatch, findFirstMatch, findPathsToAllDescendants, getActualReferenceFrame, getBooleanFromUser, getComponentIterable, getComponents, getDescendant, getDoubleFromUser, getGlobalSimulationSpeedFactor, getIntegerFromUser, getLookingGlass, getName, getPointOfView, getSGReferenceFrame, getStringFromUser, print, removeComponent, setComponents, setGlobalSimulationSpeedFactor, transformFromAWT, transformFromAWT, transformToAWT, transformToAWT
 
Methods inherited from class org.alice.apis.moveandturn.Element
getElement, isComposedOfGetterAndSetterProperties
 
Methods inherited from class edu.cmu.cs.dennisc.pattern.DefaultInstancePropertyOwner
accessListPropertyListeners, accessPropertyListeners, addListPropertyListener, addPropertyListener, decode, encode, equals, fireAdded, fireAdding, fireCleared, fireClearing, firePropertyChanged, firePropertyChanging, fireRemoved, fireRemoving, fireSet, fireSetting, getInstancePropertyNamed, getProperties, getPropertyNamed, isEquivalentTo, lookupNameFor, removeListPropertyListener, removePropertyListener
 
Methods inherited from class edu.cmu.cs.dennisc.pattern.AbstractElement
accessNameListeners, addNameListener, removeNameListener
 
Methods inherited from class edu.cmu.cs.dennisc.pattern.DefaultReleasable
accessReleaseListeners, addReleaseListener, release, removeReleaseListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Philosopher

public Philosopher(int street,
                   int avenue,
                   alice.kareltherobot.Direction direction)

Philosopher

public Philosopher(int street,
                   int avenue,
                   alice.kareltherobot.Direction direction,
                   int beepers)

Philosopher

public Philosopher(int street,
                   int avenue,
                   alice.kareltherobot.Direction direction,
                   int beepers,
                   org.alice.apis.moveandturn.Color color)
Method Detail

turnRight

public void turnRight()
Turn right by making three left turns


turnAround

public void turnAround()
Turn around by making two left turns


backUp

public void backUp()
Back up one block and face the original direction. Will fail if the rear is blocked by a wall.


run

public void run()
This is the method used by the thread system (doTogether). It will be invoked automatically. This is the task for one Philosopher robot. A robot thinks for a random period, then tries to eat (for a random period), but must first pick up two "forks" (beepers) to its left and right. But there are only four forks.

Specified by:
run in interface java.lang.Runnable