/*public void runAI(){ * AIs = new AIs(); * }*/ public IEnumerator runAI() { AIs = new AIs(); int preturing = 0; while (true) { if (turing != preturing) { preturing = turing; Debug.Log(turing); AIs.runAI(turing); } /*if(turing>0){ * AIs.runAI(turing); * } * * if(turing>=3||turing==0) * turing = 0; * else * turing++;*/ yield return(new WaitForSeconds(0.5f)); } }
public Player(PlayerIds pId, PlayerTypes pType, string pPadName, AIs pAI = AIs.Easy) { m_id = pId; m_type = pType; m_padName = pPadName; m_AI = pAI; InitPad(); }
public IUtilityAi Create(Info.AiInfo info) { if (!AIs.Contains(info.Id)) { _CreateAiDynamic(info); } return(AIs.GetAi(info.Id)); }
// 重置角色 ai public void ResetWarriorAI(Warrior warrior) { if (!AIs.ContainsKey(warrior.Team)) { AIs[warrior.Team] = new Dictionary <int, WarriorAI>(); } AIs[warrior.Team][warrior.IDInMap] = warrior.AI; }
public MainWindow() { InitializeComponent(); IsAI.Add(TakPiece.PieceColor.Black, false); IsAI.Add(TakPiece.PieceColor.White, false); AIs.Add(TakPiece.PieceColor.Black, new PlayerAI(TakPiece.PieceColor.Black, new GameState(new TakBoard(3)))); AIs.Add(TakPiece.PieceColor.White, new PlayerAI(TakPiece.PieceColor.White, new GameState(new TakBoard(3)))); DebugArea = DebugTrace; }
private void ExecuteRegisters(int register) { var list = AIs.Where(x => !x.Dead).OrderByDescending(x => x.ProgramCards[register].Priority).ToList(); foreach (var ai in list) { if (!ai.Dead) { Board.ExecuteProgramCard(ai, ai.ProgramCards[register]); } } }
public void StartNextRound(int player) { BeforeStartNextRound1?.Invoke(player); BeforeStartNextRound2?.Invoke(player); // 处理所属当前队伍的 ai if (AIs.ContainsKey(player)) { var ais = AIs[player].Values.ToArray(); ais.Resort(); foreach (var id in AIs[player].Keys.ToArray()) { AIs[player][id].ActFirst?.Invoke(); } } OnNextRoundStarted?.Invoke(player); AfterStartNextRound?.Invoke(player); }
public void ActionDone(int player) { BeforeActionDone?.Invoke(player); OnActionDone?.Invoke(player); // 处理所属当前队伍的 ai if (AIs.ContainsKey(player)) { var ais = AIs[player].Values.ToArray(); ais.Resort(); foreach (var id in AIs[player].Keys.ToArray()) { AIs[player][id].ActLast?.Invoke(); } } AfterActionDone?.Invoke(player); TryBattleEnd(); // 回合结束时检查战斗结束条件 Move2NextPlayer(player); // 行动机会转移至下一队伍 }
public void Generate(int popNumber, double mutationRate, double crossoverRate, double perturbationLimit, int eliteNumber, int eliteCopyNumber) { ga = new GeneticAlgorithm(popNumber, mutationRate, crossoverRate, perturbationLimit, eliteNumber, eliteCopyNumber); for (int i = 0; i < popNumber; i++) { NeuralNet nn = new NeuralNet( 220, 4, 3, 110, 1.0 ); Genome g = new Genome(nn.GetWeigths(), 0); AIs.Add(new ArtificialIntelligence() { NeuralNet = nn, Genome = g, Name = nameGenerator.GenerateRandomFirstName() + " " + CurrentGeneration }); } }
public void PlayTurn() { // Deal Program Cards DealCards(); // Program Registers // Future: Announce Power Down for NEXT turn AskBotActions(); // Complete each register in order: // Execute Program Cards // Complete board movements // Resolve interactions // Touch Flag and Repair sites CompleteRegisters(); // Clean up Cleanup(); // Check if any AIs still in the game finished = finished || AIs.Count(x => !x.Dead) == 0; }
/// <summary> /// Removes the specified <see cref="AI"/> from the register /// </summary> /// <param name="ai">The <see cref="AI"/> to remove</param> public static void RemoveFromRegister(AI ai) { AIs.Remove(ai); }
/// <summary> /// Adds a specified <see cref="AI"/> to the register /// </summary> /// <param name="ai">The <see cref="AI"/> to add</param> public static void AddToRegister(AI ai) { AIs.Add(ai); }
/*public void runAI(){ AIs = new AIs(); }*/ public IEnumerator runAI() { AIs = new AIs(); int preturing = 0; while(true){ if(turing!=preturing){ preturing = turing; Debug.Log(turing); AIs.runAI(turing); } /*if(turing>0){ AIs.runAI(turing); } if(turing>=3||turing==0) turing = 0; else turing++;*/ yield return new WaitForSeconds(0.5f); } }
private void _CreateAiDynamic(Info.AiInfo info) { var actions = new List <IAction>(); foreach (var actioninfo in info.Actions) { var newAction = Actions.Create(actioninfo.RefAction); if (newAction == null) { throw new NullReferenceException(); } newAction.Initialize(actioninfo); actions.Add(newAction); } var considerations = new List <IConsideration>(); foreach (var considerationinfo in info.Considerations) { var newConsideration = Considerations.Create(considerationinfo.RefConsideration); if (newConsideration == null) { throw new NullReferenceException(); } newConsideration.Initialize(considerationinfo); considerations.Add(newConsideration); } var options = new List <IOption>(); foreach (var optionInfo in info.Options) { var action = actions[optionInfo.ActionInfoIndex]; var subConsiderations = new List <IConsideration>(); foreach (var indexConsideration in optionInfo.ConsiderationInfoIndexes) { subConsiderations.Add(considerations[indexConsideration]); } var newOption = new DynamicOption(action, subConsiderations, optionInfo); options.Add(newOption); } var behaviours = new List <IBehaviour>(); foreach (var behaviourInfo in info.Behaviours) { var subOptions = new List <IOption>(); foreach (var indexOption in behaviourInfo.OptionInfoIndexes) { subOptions.Add(options[indexOption]); } var subConsiderations = new List <IConsideration>(); foreach (var indexConsideration in behaviourInfo.ConsiderationInfoIndexes) { subConsiderations.Add(considerations[indexConsideration]); } var newBehaviour = new DynamicBehaviours(subOptions, subConsiderations, behaviourInfo); behaviours.Add(newBehaviour); } var newAi = new DynamicAi(behaviours); AIs.Add(newAi); }
public IUtilityAi Create(string aiId) { return(AIs.CreateAi(aiId)); }
public void ClearAIs() { AIs.Clear(); }
public void AddAI(string name, string location) { AIs.Add(Board, name, location); }