public List <IUnitCommand> GetCommandsForUnit(IUnit unit, InfluenceMaps maps)
        {
            var unitLocation = UnitPositionCanon.GetOwnerOfPossession(unit);

            var reachableCellsByDistance = HexPathfinder.GetAllCellsReachableIn(
                unitLocation, unit.CurrentMovement, UnitPositionCanon.GetPathfindingCostFunction(unit, false),
                Grid.Cells
                );

            var validCandidates = reachableCellsByDistance.Keys.Where(cell => UnitPositionCanon.CanPlaceUnitAtLocation(unit, cell, false));

            IHexCell bestCandidate = validCandidates.MaxElement(BrainTools.GetFleeWeightFunction(unit, maps));

            var retval = new List <IUnitCommand>();

            if (bestCandidate != null)
            {
                var moveCommand = Container.Instantiate <MoveUnitCommand>();

                moveCommand.UnitToMove      = unit;
                moveCommand.DesiredLocation = bestCandidate;

                retval.Add(moveCommand);
            }

            return(retval);
        }
        public float GetUtilityForUnit(IUnit unit, InfluenceMaps maps)
        {
            var unitPosition = UnitPositionCanon.GetOwnerOfPossession(unit);

            var reachableCells = HexPathfinder.GetAllCellsReachableIn(
                unitPosition, unit.CurrentMovement,
                (current, next) => UnitPositionCanon.GetTraversalCostForUnit(unit, current, next, true),
                Grid.Cells
                );

            if (reachableCells.Keys.Any(FilterLogic.GetCaptureCivilianFilter(unit)))
            {
                return(BarbarianConfig.CaptureCivilianUtility);
            }
            else
            {
                return(0f);
            }
        }