Categories > Board > rex_monopoly_movement

Introduction

Get forwarding path using Monopoly-like behavior.

Links


Categories > Board > rex_monopoly_movementIntroductionLinksDependenceUsageGet moving pathMain flowFlow chart of getting solid propertyFlow chart of getting next face (moving direction)Flow chart of getting costGet moving cost of a tileFaceMove chess alone pathMove to last tile of path

Dependence

None

Usage

Sample capx

Get moving path

Main flow

Get pathNoYesYesNoRemaining moving point =parameter 'Moving points'Get a 'Not solid' neighbor tile----Custom solidGet cost of this neighbor----+Condition:On get moving costCost =Expression:STOPRemaining moving point =Remaining moving point - costRemaining moving point >= 0Remaining moving point =0Move to this neighbor----Add the neighbor tile into resultFinish----Result pathAction:Get forwarding pathMove chess along result path----+Condition:Pop tile

Flow chart of getting solid property

YesNoGet solid of tile+Condition:On get solid----Tile Expression:TileUIDat (Expression:TileLX, Expression:TileLY)----Action:Set solid, orAction:Set move-ableHasAction:Set solid, orAction:Set move-ableSolid =Return valueSolid behavior

Flow chart of getting next face (moving direction)

012> 2Forked roadYesNoRandomForwardingYesNoGet next tileNumber of'Not solid'neighborsStopFace tothis neighborFace tonew neighbor+Condition:On forked road----Tile Expression:TileUIDat (Expression:TileLX, Expression:TileLY)-----Action:Set faceHasAction:Set faceFace =Return valueProperty:Forked roadFace toRandom neighbor,except backward oneHasforward neighbor?Face toForward neighbor

Flow chart of getting cost

Cost functionNoYesYesNo+Condition:On get moving costTile Expression:TileUIDat (Expression:TileLX, Expression:TileLY)Has-Action:Set costin sub-event-Action:Set costGet cost of tileHas+Condition:On get moving costin event sheetCost =1Cost =Return value

Calls Action:Get forwarding path to get path

  1. Get Not solid neighbors

    1. trigger Condition:On get solid ,
    2. pick tile Expression:TileUID, at LXYZ (Expression:TileLX, Expression:TileLY, 0),
    3. get custom solid by Action:Set solid, or Action:Set move-able
    4. if custom solid is NOT assigned by Action:Set solid, or Action:Set move-able, try get solid property from official solid behavior.
  2. Get next tile

    1. if no neighbor found

      1. stop, could not move to any tile
    2. if 1 neighbor found

      1. try move to this neighbor if remaining moving cost is enough (i.e. remaining moving cost >= 0)
    3. if 2 neighbors found

      1. try move to a new neighbor if remaining moving cost is enough, for example
      'TileA - TileB - TileC' are a sequence of tiles on the board,
      Chess move from tileA to tileB in previous step,
      now tileA and tileC are the neighbors of this step,
      Chess will try to move to tileC in this step.
    4. if more then 2 neighbors (i.e. forked road) found

      1. try get moving direction (face) from Action:Set face under Condition:On forked road

        1. trigger Condition:On forked road

        2. pick tile Expression:TileUID, at LXYZ (Expression:TileLX, Expression:TileLY, 0),

        3. get new face by Action:Set face

        4. if new face is NOT assigned in event

          1. If property Forked road is Forwarding

            1. if forward neighbor found

              1. try move to forward neighbor if remaining moving cost is enough (i.e. remaining moving cost >= 0)
            2. else, pick a random neighbor, except backward one

              1. try move to this neighbor if remaining moving cost is enough (i.e. remaining moving cost >= 0)
          2. If property Forked road is Random

            1. pick a random neighbor, except backward one

              1. try move to a random neighbor if remaining moving cost is enough (i.e. remaining moving cost >= 0)

Expression:TotalMovingPoints is the moving points input parameter of last Action:Get forwarding path.

Get moving cost of a tile

  1. if Condition:On get moving cost is in event sheet

    1. trigger Condition:On get moving cost
    2. pick tile Expression:TileUID, at LXYZ (Expression:TileLX, Expression:TileLY, 0),
    3. get moving cost by Action:Set cost
    4. if moving cost is NOT assigned in event, moving cost = 1
  2. else, moving cost = 1

Set moving cost to Expression:STOP will consume remaining moving cost, to stop at this tile.

Face

Face is the moving direction, each kind of layout (rex_board_squareTx, rex_board_hexTx) has different directions definition.

Move chess alone path

Using rex_grid_move behavior to move chess alone path after Action:Get forwarding path.

  1. Get path by Action:Get forwarding path
  2. Call C2 function Move to next tile

Add events of C2 function Move to next tile :

  1. Pick next tile by Condition:Pop tile
  2. Move to tile by Action:Move to chess of grid move behavior
  3. chess has moved to the last tile of the path If picking nothing (system condition:Else)

Add events to move to next tile when reached to target tile by Condition:On hit target position of grid move behavior

  1. Call C2 function Move to next tile
Function: Move to next tile On moved to tileElseOn function: 'Move to next tile'Monopoly movement behavior+Condition:Pop tileGrid move behavior-Action:Move to chessGrid move behavior+Condition:On hit target position-Call function: 'Move to next tile'Monopoly movement behaviorAction:Get forwarding path----Pick path of tiles-Call function: 'Move to next tile'Moved tothe last tile of path

Sets propertyForce move toYes in grid move behavior, since the move-able (solid) had been determined by this Action:Get forwarding path.

Condition:Empty returns true after all tiles of path are popped by Condition:Pop tile.

Move to last tile of path

Get the last tile instance by Condition:Pop the last tile to move to it, or pick this tile by LXYZ (Expression:TargetLX, Expression:TargetLY, 0). And the face at last tile is Expression:TargetFaceDir.