示例#1
0
    public void PerformAutoBalance()
    {
        _blueTeamSizeAdvantage = _observation.GetBlueTeamSizeAdvantage();
        if (_autobalance)
        {
            if (_observation.GetTeamsAreBalanced())
            {
                EndAutoBalance();
            }
            else
            {
                //Wait for death
                if (DateTime.Now.Subtract(_autobalanceStartTime).TotalSeconds < 15)
                {
                    List <int> slots;
                    List <int> empties;
                    if (_blueTeamSizeAdvantage > 0)
                    {
                        slots   = _cg.BlueSlots;
                        empties = _observation.EmptyRedSlots();
                    }
                    else
                    {
                        slots   = _cg.RedSlots;
                        empties = _observation.EmptyBlueSlots();
                    }


                    List <int> dead = _cg.PlayerInfo.GetDeadSlots();
                    foreach (int deadSlot in dead)
                    {
                        if (slots.Contains(deadSlot))
                        {
                            if (empties.Count > 0)
                            {
                                int lastEmpty = empties[empties.Count - 1];
                                _cg.Interact.Move(deadSlot, lastEmpty);
                            }
                        }
                    }
                }
                else
                {
                    //Swap anyone
                    _manipulation.SwapToBalance();
                }
            }
        }
    }
示例#2
0
    public void SwapWithEmpty(int slot, Team toSwapTo)
    {
        List <int> empties;

        if (toSwapTo == Team.Blue)
        {
            empties = _observation.EmptyBlueSlots();
        }
        else if (toSwapTo == Team.Red)
        {
            empties = _observation.EmptyRedSlots();
        }
        else
        {
            throw new ArgumentException("toSwapTo must be Red or Blue");
        }

        if (empties.Count > 0)
        {
            int lastEmpty = empties[empties.Count - 1];
            _interact.Move(slot, lastEmpty);
        }
    }