public override PlayerTask GetMove(POGame game) { var player = game.CurrentPlayer; // Implement a simple Mulligan Rule if (player.MulliganState == Mulligan.INPUT) { List <int> mulligan = new WeightedScore().MulliganRule().Invoke(player.Choice.Choices.Select(p => game.getGame().IdEntityDic[p]).ToList()); return(ChooseTask.Mulligan(player, mulligan)); } //Lookhead n steps and choose the best scoring <PlayerTask> and each depth -> branch ->score->until depth //(DFS search) var validOpts = game.Simulate(player.Options()).Where(x => x.Value != null); var voptcount = validOpts.Count(); if (validOpts.Any()) { var depth = voptcount > 5 ? (voptcount > 25 ? 1: 2) : 3; var scored = validOpts.Select(x => Simulate(x, player.PlayerId, depth)); // Array.ForEach(scored.Select(x=>x.Item1).ToArray(),Console.Write); // Console.Write($"\r{scored.Count()} "); return(scored.OrderBy(x => x.Value).Last().Key); } else { return(player.Options().First(x => x.PlayerTaskType == PlayerTaskType.END_TURN)); } }
public int CompareTo(CodecMatch other) { if (other?.CodecRegistration == null) { return(1); } if (ReferenceEquals(this, other)) { return(0); } if (WeightedScore == other.WeightedScore) { return(MatchingParameterCount == other.MatchingParameterCount ? MediaType.CompareTo(other.MediaType) : MatchingParameterCount.CompareTo(other.MatchingParameterCount)); } return(WeightedScore.CompareTo(other.WeightedScore)); }
/// <summary> /// Returns a instance of a Hearthstone agent based on the profited card class and agent type. /// The card class of the hero is key for configuring the agent correctly, especially the predator MCTS. /// </summary> /// <param name="cardClass">the card class of the agent's hero</param> /// <param name="deck">the deck of the agent</param> /// <param name="type">the type of agent</param> /// <returns></returns> public AbstractAgent GetAgent(CardClass cardClass, List <Card> deck, AgentType type) { double simulationTime = 15000; IScore scoring = new WeightedScore(); AbstractAgent agent = new ExhaustiveSeachAgent(10, 200, scoring); switch (type) { case AgentType.FlatMCTS: agent = new FlatMCAgent(scoring); break; case AgentType.MCTS: /*agent = new MCTSAgent(scoring, * new MCTSParameters * { * SimulationTime = simulationTime, * AggregationTime = 100, * RolloutDepth = 5, * UCTConstant = 9000 * });*/ break; case AgentType.PredatorMCTS: // the default decks if (cardClass == CardClass.WARRIOR) { Console.WriteLine("Aggro Deck"); agent = new PredatorMCTSAgent(scoring, new MCTSParameters { SimulationTime = simulationTime, AggregationTime = 100, RolloutDepth = 5, UCTConstant = 9000 }, new PredictionParameters { File = Environment.CurrentDirectory + @"\src\Bigramms\bigramm_1-2017-12-2016.json.gz", DecayFactor = 1, CardCount = 10, StepWidth = 2, DeckCount = 1, SetCount = 3, LeafCount = 5, SimulationDepth = 1, OverallLeafCount = 5 }); } else if (cardClass == CardClass.SHAMAN) { agent = new PredatorMCTSAgent(scoring, new MCTSParameters { SimulationTime = simulationTime, AggregationTime = 100, RolloutDepth = 5, UCTConstant = 9000 }, new PredictionParameters { File = Environment.CurrentDirectory + @"\src\Bigramms\bigramm_1-2017-12-2016.json.gz", DecayFactor = 1, CardCount = 10, StepWidth = 2, DeckCount = 1, SetCount = 3, LeafCount = 5, SimulationDepth = 3, OverallLeafCount = 5 }); } else if (cardClass == CardClass.MAGE) { agent = new PredatorMCTSAgent(scoring, new MCTSParameters { SimulationTime = simulationTime, AggregationTime = 100, RolloutDepth = 5, UCTConstant = 9000 }, new PredictionParameters { File = Environment.CurrentDirectory + @"\src\Bigramms\bigramm_1-2017-12-2016.json.gz", DecayFactor = 1, CardCount = 10, StepWidth = 2, DeckCount = 1, SetCount = 3, LeafCount = 5, SimulationDepth = 5, OverallLeafCount = 5 }); } else if (cardClass == CardClass.WARLOCK) { agent = new PredatorMCTSAgent(scoring, new MCTSParameters { SimulationTime = simulationTime, AggregationTime = 100, RolloutDepth = 5, UCTConstant = 9000 }, new PredictionParameters { File = Environment.CurrentDirectory + @"\src\Bigramms\bigramm_3-2018-10-2017.json.gz", DecayFactor = 1, CardCount = 10, StepWidth = 2, DeckCount = 1, SetCount = 3, LeafCount = 5, SimulationDepth = 1, OverallLeafCount = 5 }); } break; } ; return(agent); }