dip.process
Class OrderState

java.lang.Object
  extended bydip.process.OrderState

public final class OrderState
extends java.lang.Object

OrderState objects keep track of the state of an order, during adjudication. OrderStates are not designed to be serialized.

Each OrderState represents a decision. All OrderStates initially start out with an evaluation state of Tristate.UNCERTAIN. Once a decision has been made, based upon the internal state, the evaluation state is finalized (Tristate.SUCCESS or Tristate.FAILURE). Ince finalized, a decision can never be reversed. Irreversibility is enforced by the OrderState object.

_max values only become smaller.
_certain values only become larger.

defense: the strength to stay in the same position (hold strength)
attack: the strength required to dislodge a defender from it's position; a separate value is computed for "self" attacks.

Dependent lists include OrderStates representing:

In Java code, OrderState variables typically have the suffix "OS".

NOTE: When debugging, assertions should be enabled.

DESIGN NOTE: this class is currently marked final but may not be in future versions.


Field Summary
static int MAX_VALUE
          NOTE: 'max' values start at an arbitrarily high value (something that is so large that it could never occur in a game) and move down.
static int MIN_VALUE
          MINIMUM value for a strength.
 
Constructor Summary
protected OrderState(Order order)
          Create an OrderState.
 
Method Summary
 int getAtkCertain()
          Get certain attack value
 int getAtkMax()
          Get maximum attack value
 int getAtkSelfSupportCertain()
          Get certain self-support attack value.
 int getAtkSelfSupportMax()
          Get maximum self-support attack value
 int getDefCertain()
          Get certain defense value
 int getDefMax()
          Get maximum defense value
 OrderState[] getDependentMovesToDestination()
          Get the Move orders that are moving to the Destination Location of this order.
 OrderState[] getDependentMovesToSource()
          Get the Move orders that are moving to the Source Location of this order.
 OrderState[] getDependentSelfSupports()
          Gets the dependent self-Support orders for this order
 OrderState[] getDependentSupports()
          Gets the dependent Support orders for this order
 Tristate getDislodgedState()
          Get dislodged state.
 OrderState getDislodger()
          Get the dislodger, if any.
 Tristate getEvalState()
          Get the evaluation state.
 OrderState getHeadToHead()
          Get the order that we are in a head-to-head Move with.
 Order getOrder()
          Get the Order for this OrderState.
 Power getPower()
          Convenicent method: get the order Power
 int getRetreatStrength()
          Get retreat strength
 int getSelfSupport(boolean isCertain)
          Similar to getSupport(), but, determines self-support (if any).
 Location getSource()
          Convenicent method: get the order source Location
 Province getSourceProvince()
          Convenicent method: get the order source Province
 int getSupport(boolean isCertain)
          For each support in the dependent list, the total support is determined in the following manner: if isCertain == true: +1 if support evalState == TriSTate.SUCCESS +0 if evalState is UNCERTAIN or FAILURE if isCertain == false; [calculates 'max' support] +1 if support evalState == SUCCESS or UNCERTAIN +0 if support evalState == FAILURE Note:
It is assumed that all support is 'appropriate'; and that invalid supports have already been marked as such (e.g., if order is Move A-B, and we have to supports: support 1: C sup A-B, and support 2: C sup A) that support 2 (illegal for a Move order) is marked FAILURE with it's evalstate.
protected  int getSupport(boolean isCertain, OrderState[] supportList, int defaultStrength)
          Helper method, used by other getSupport() and getSelfSupport() methods.
 boolean hasFoundConvoyPath()
          Get if we have found a convoy path.
 boolean isCircular()
          Get if we are part of a circular movement chain.
 boolean isHeadToHead()
          Determines if this is part of a head-to-head Move.
 boolean isLegal()
          Get the order legality (default is true).
 boolean isRetreatStrengthSet()
          Indicates if the retreat strength has been set.
 boolean isVerified()
          Indicate if Order has been Verified
 void setAtkCertain(int value)
          Set the certain attack value.
 void setAtkMax(int value)
          Set the maximum attack value.
 void setAtkSelfSupportCertain(int value)
          Set the attack certain including self-support
 void setAtkSelfSupportMax(int value)
          Set the attack max including self-support
 void setCircular(boolean value)
          Set if this is part of a chain of circular movements.
 void setDefCertain(int value)
          Set the certain defense.
 void setDefMax(int value)
          Set the maximum defense.
 void setDependentMovesToDestination(java.util.List osList)
          Adds a List of the Dependent Move Orderstates to the Destination Province of this Orderstate If asserts are enabled, all OrderStates are verified to contain only Move orders.
 void setDependentMovesToSource(java.util.List osList)
          Adds a List of the Dependent Move Orderstates to the Source Province of this Orderstate.
 void setDependentSelfSupports(java.util.List osList)
          Criteria: Support order Supported MOVE (not any other) [supportedSrc !
 void setDependentSupports(java.util.List osList)
          Adds the given list, which must only contain Dependent Support OrderStates.
 void setDislodgedState(Tristate value)
          Set the dislodged state.
 void setDislodger(OrderState os)
          Set the dislodger.
 void setEvalState(Tristate value)
          Set the evaluation state.
 void setFoundConvoyPath(boolean value)
          Set if we have found a convoy path
 void setHeadToHead(OrderState os)
          if move is a head-to-head move, set which move we are moving head-to-head against here.
 void setLegal(boolean value)
          Sets if an Order is legal.
protected  void setOrder(Order value)
          Set the Order.
 void setRetreatStrength(int value)
          Set the retreat strength
 void setVerified(boolean value)
          Set if an order has been verified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_VALUE

public static final int MAX_VALUE
NOTE: 'max' values start at an arbitrarily high value (something that is so large that it could never occur in a game) and move down. Note that setting the value to Integer.MAX_VALUE is NOT a good idea, because if we add two max values together (e.g., when calculating support), we will overflow (to negative values) So, we will use our own MAX_VALUE, which is still quite high.

See Also:
Constant Field Values

MIN_VALUE

public static final int MIN_VALUE
MINIMUM value for a strength. Only used for Retreat Strength.

See Also:
Constant Field Values
Constructor Detail

OrderState

protected OrderState(Order order)
Create an OrderState. This is protected, because only subclasses of this and adjudicators should be able to create new OrderState objects, although other classes can definately use them.

Method Detail

getOrder

public Order getOrder()
Get the Order for this OrderState.


isCircular

public boolean isCircular()
Get if we are part of a circular movement chain.


getEvalState

public Tristate getEvalState()
Get the evaluation state.


getDislodgedState

public Tristate getDislodgedState()
Get dislodged state.


getDefMax

public int getDefMax()
Get maximum defense value


getDefCertain

public int getDefCertain()
Get certain defense value


getAtkMax

public int getAtkMax()
Get maximum attack value


getAtkCertain

public int getAtkCertain()
Get certain attack value


getAtkSelfSupportMax

public int getAtkSelfSupportMax()
Get maximum self-support attack value


getAtkSelfSupportCertain

public int getAtkSelfSupportCertain()
Get certain self-support attack value.


isHeadToHead

public boolean isHeadToHead()
Determines if this is part of a head-to-head Move.


getHeadToHead

public OrderState getHeadToHead()
Get the order that we are in a head-to-head Move with.


isLegal

public boolean isLegal()
Get the order legality (default is true).


getDislodger

public OrderState getDislodger()
Get the dislodger, if any.


hasFoundConvoyPath

public boolean hasFoundConvoyPath()
Get if we have found a convoy path.


getRetreatStrength

public int getRetreatStrength()
Get retreat strength


isRetreatStrengthSet

public boolean isRetreatStrengthSet()
Indicates if the retreat strength has been set.


isVerified

public boolean isVerified()
Indicate if Order has been Verified


getDependentSupports

public OrderState[] getDependentSupports()
Gets the dependent Support orders for this order


getDependentMovesToSource

public OrderState[] getDependentMovesToSource()
Get the Move orders that are moving to the Source Location of this order.


getDependentMovesToDestination

public OrderState[] getDependentMovesToDestination()
Get the Move orders that are moving to the Destination Location of this order.


getDependentSelfSupports

public OrderState[] getDependentSelfSupports()
Gets the dependent self-Support orders for this order


setOrder

protected void setOrder(Order value)
Set the Order. NOTE: this may be eliminated/deprecated, as it must be used with extreme care.


setCircular

public void setCircular(boolean value)
Set if this is part of a chain of circular movements.


setDislodgedState

public void setDislodgedState(Tristate value)
Set the dislodged state.


setDefMax

public void setDefMax(int value)
Set the maximum defense.


setDefCertain

public void setDefCertain(int value)
Set the certain defense.


setAtkMax

public void setAtkMax(int value)
Set the maximum attack value.


setAtkCertain

public void setAtkCertain(int value)
Set the certain attack value.


setAtkSelfSupportMax

public void setAtkSelfSupportMax(int value)
Set the attack max including self-support


setAtkSelfSupportCertain

public void setAtkSelfSupportCertain(int value)
Set the attack certain including self-support


setFoundConvoyPath

public void setFoundConvoyPath(boolean value)
Set if we have found a convoy path


setRetreatStrength

public void setRetreatStrength(int value)
Set the retreat strength


setLegal

public void setLegal(boolean value)
Sets if an Order is legal. By default, orders are legal.


setVerified

public void setVerified(boolean value)
Set if an order has been verified. Once set to true, cannot be set to false.


setEvalState

public void setEvalState(Tristate value)
Set the evaluation state. Note that once set (e.g., value != UNCERTAIN), it cannot be altered.


setHeadToHead

public void setHeadToHead(OrderState os)
if move is a head-to-head move, set which move we are moving head-to-head against here.


setDislodger

public void setDislodger(OrderState os)
Set the dislodger. We do some sanity checks; this can only be set if dislodged == MAYBE or YES. Furthermore, dislodger must be a Move order.


setDependentSupports

public void setDependentSupports(java.util.List osList)
Adds the given list, which must only contain Dependent Support OrderStates.

If assertions are enabled, the list is verified to contain only Support OrderStates


setDependentSelfSupports

public void setDependentSelfSupports(java.util.List osList)
Criteria:
  1. Support order
  2. Supported MOVE (not any other) [supportedSrc != supportedDest]
  3. unit in supportedDest must be present
  4. power of unit in supported dest == power of support order
NOTE: OrderState only checks criteria #1 and #2, and only if asserts are enabled.


setDependentMovesToSource

public void setDependentMovesToSource(java.util.List osList)
Adds a List of the Dependent Move Orderstates to the Source Province of this Orderstate.

If asserts are enabled, all OrderStates are verified to contain only Move orders.


setDependentMovesToDestination

public void setDependentMovesToDestination(java.util.List osList)
Adds a List of the Dependent Move Orderstates to the Destination Province of this Orderstate

If asserts are enabled, all OrderStates are verified to contain only Move orders.


getSource

public Location getSource()
Convenicent method: get the order source Location


getSourceProvince

public Province getSourceProvince()
Convenicent method: get the order source Province


getPower

public Power getPower()
Convenicent method: get the order Power


getSupport

public int getSupport(boolean isCertain)
For each support in the dependent list, the total support is determined in the following manner:

Note:
It is assumed that all support is 'appropriate'; and that invalid supports have already been marked as such (e.g., if order is Move A-B, and we have to supports: support 1: C sup A-B, and support 2: C sup A) that support 2 (illegal for a Move order) is marked FAILURE with it's evalstate.

If there is NO support, we return 1 (since all units have a default strength of 1), unless the base move modifier (due to a difficult passable border) changes this amount.


getSelfSupport

public int getSelfSupport(boolean isCertain)
Similar to getSupport(), but, determines self-support (if any). If there is no self support, returns '0'.


getSupport

protected int getSupport(boolean isCertain,
                         OrderState[] supportList,
                         int defaultStrength)
Helper method, used by other getSupport() and getSelfSupport() methods.



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.