includefilename = "asset\\composition\\AIScript\\LordAICommon.lua" 
includefilename = SYSTEM.RelativeToAbsolutePath(includefilename)
dofile(includefilename)

function Init ()
  Enter_Wander()
end

function Enter_Wander ()
  ARMY.SetBehavior(myArmyID, "WalkTo")
  
  Wander_Goal_PositionX, Wander_Goal_PositionY = MAP.GetRandomPosition()
  
  ARMY.SetGoalPosition(myArmyID, Wander_Goal_PositionX, Wander_Goal_PositionY)
  
  Last_PositionX, Last_PositionY = ARMY.GetPosition(myArmyID)
  Now_PositionX, Now_PositionY = ARMY.GetPosition(myArmyID)
  samePosCount = 0
end

function Update_Wander ()
  Last_PositionX, Last_PositionY = Now_PositionX, Now_PositionY
  Now_PositionX, Now_PositionY = ARMY.GetPosition(myArmyID)

  if (Last_PositionX == Now_PositionX) and (Last_PositionY == Now_PositionY) then
    samePosCount = samePosCount + 1
  else
    samePosCount = 0
  end

  if samePosCount >= 5 then
    Exit_Wander()
    Enter_Wander()
  end  
end

function Exit_Wander()
end

function Update ()
    Update_Wander()
end
