public override int Rate() { // Final actions if (OpHeroHp < 1) { return(Int32.MaxValue); } if (HeroHp < 1) { return(Int32.MinValue); } int result = 0; result += HeroHp * Values[0]; result -= OpHeroHp * Values[1]; result += BoardZone.Count() * Values[2]; result -= OpBoardZone.Count() * Values[3]; result += MinionTotAtk * Values[4]; result -= OpMinionTotAtk * Values[5]; result += MinionTotHealth * Values[6]; result -= OpMinionTotHealth * Values[7]; result += MinionTotHealthTaunt * Values[8]; result -= OpMinionTotHealthTaunt * Values[9]; return(result); }
public override int Rate() { if (OpHeroHp < 1) { return(int.MaxValue); } if (HeroHp < 1) { return(int.MinValue); } float score = 0; score += HeroHp - OpHeroHp; score += BoardZone.Count() - OpBoardZone.Count(); score += HeroAtk - OpHeroAtk; foreach (Minion Minion in BoardZone) { score += MinionScore(Minion, true); } foreach (Minion Minion in OpBoardZone) { score -= MinionScore(Minion, false); } return((int)Math.Round(score)); }
private double calculateScoreMinions(BoardZone before, BoardZone after) { foreach (Minion m in before.GetAll()) { debug("BEFORE " + stringMinion(m)); } foreach (Minion m in after.GetAll()) { debug("AFTER " + stringMinion(m)); } double scoreHealthReduced = 0; double scoreAttackReduced = 0; //We should add Divine shield removed? double scoreKilled = 0; double scoreAppeared = 0; //Minions modified? foreach (Minion mb in before.GetAll()) { bool survived = false; foreach (Minion ma in after.GetAll()) { if (ma.Id == mb.Id) { scoreHealthReduced = scoreHealthReduced + weights[MINION_HEALTH_REDUCED] * (mb.Health - ma.Health) * scoreMinion(mb); //Positive points if health is reduced scoreAttackReduced = scoreAttackReduced + weights[MINION_ATTACK_REDUCED] * (mb.AttackDamage - ma.AttackDamage) * scoreMinion(mb); //Positive points if attack is reduced survived = true; } } if (survived == false) { debug(stringMinion(mb) + " was killed"); scoreKilled = scoreKilled + scoreMinion(mb) * weights[MINION_KILLED]; //WHATEVER //Positive points if card is dead } } //New Minions on play? foreach (Minion ma in after.GetAll()) { bool existed = false; foreach (Minion mb in before.GetAll()) { if (ma.Id == mb.Id) { existed = true; } } if (existed == false) { debug(stringMinion(ma) + " is NEW!!"); scoreAppeared = scoreAppeared + scoreMinion(ma) * weights[MINION_APPEARED]; //Negative if a minion appeared (below) } } //Think always as positive points if the enemy suffers! return(scoreHealthReduced + scoreAttackReduced + scoreKilled - scoreAppeared); //CHANGE THESE SIGNS ACCORDINGLY!!! }
public override int Rate() { if (HeroHp < 1) { return(Int32.MinValue); } if (OpHeroHp < 1) { return(Int32.MaxValue); } int result = 0; Controller player = Controller; Controller opp = player.Opponent; int heroHp = HeroHp + player.Hero.Armor; int oppHeroHp = OpHeroHp + opp.Hero.Armor; result += (heroHp - oppHeroHp) * 2 * Scale; result += player.NumCardsDrawnThisTurn * Scale; result += player.NumDiscardedThisGame * -5 * Scale; result += player.NumFriendlyMinionsThatAttackedThisTurn * Scale; result += player.NumMinionsPlayerKilledThisTurn * Scale; result += player.RemainingMana * -Scale; Minion[] minions = BoardZone.GetAll(); Minion[] oppMinions = OpBoardZone.GetAll(); result += (minions.Count() - oppMinions.Count()) * 3 * Scale; result += getTotalMinionScore(minions); result -= getTotalMinionScore(oppMinions); return(result); }
private BoardZone GetBoardZone(SabberStoneCore.Model.Zones.BoardZone zone) { var result = new BoardZone(); var span = zone.GetSpan(); for (int i = 0; i < span.Length; i++) { result.Minions.Add(GetMinion(span[i])); } return(result); }
private int getMinionStrehgth(Controller player) { BoardZone boardZone = player.BoardZone; int damage = 0; foreach (Minion m in boardZone.GetAll()) //NOTE: does not get dormant minions { damage += m.AttackDamage; } return(damage); }
private int getMinionHealth(Controller player) { BoardZone boardZone = player.BoardZone; int health = 0; foreach (Minion m in boardZone.GetAll()) //NOTE: does not get dormant minions { health += m.Health; } return(health); }
public override int Rate() { // lose if (HeroHp < 1) { return(Int32.MinValue); } // win if (OpHeroHp < 1) { return(Int32.MaxValue); } int result = 0; int scale = 1000; //if (OpBoardZone.Count == 0 && BoardZone.Count > 0) // result += 1000; //if (OpMinionTotHealthTaunt > 0) // result += OpMinionTotHealthTaunt * -1000; //result += MinionTotAtk; Controller player = Controller; Controller opp = player.Opponent; int heroHp = HeroHp + player.Hero.Armor; int oppHeroHp = OpHeroHp + opp.Hero.Armor; //result += (HeroHp - OpHeroHp) * 1000; //result += (heroHp - oppHeroHp); result += (heroHp - oppHeroHp) * scale; result += HandCnt * 3 * scale; result -= OpHandCnt * 3 * scale; Minion[] minions = BoardZone.GetAll(); result += minions.Count() * 2 * scale; foreach (Minion minion in minions) { result += getMinionScore(minion) * scale; } Minion[] oppMinions = OpBoardZone.GetAll(); result -= oppMinions.Count() * 2 * scale; foreach (Minion oppMinion in oppMinions) { result -= getMinionScore(oppMinion) * scale; } return(result); }
public override int Rate() { if (HeroHp < 1) { return(Int32.MinValue); } if (OpHeroHp < 1) { return(Int32.MaxValue); } int result = 0; if (OpBoardZone.Count == 0 && BoardZone.Count > 0) { result += 7 * Scale; } Controller player = Controller; Controller opp = player.Opponent; result += player.AmountHeroHealedThisTurn * 5; result -= opp.AmountHeroHealedThisTurn * 5; result += player.JadeGolem * 10 * Scale; result += player.NumCardsDrawnThisTurn * Scale; result += player.NumDiscardedThisGame * -5 * Scale; result += player.NumFriendlyMinionsThatAttackedThisTurn * Scale; result += player.NumMinionsPlayerKilledThisTurn * Scale; result += player.RemainingMana * -Scale; int heroHp = HeroHp + player.Hero.Armor; int oppHeroHp = OpHeroHp + opp.Hero.Armor; result += (heroHp - oppHeroHp) * Scale; result += HandCnt * 2 * Scale; result -= OpHandCnt * 2 * Scale; Minion[] minions = BoardZone.GetAll(); Minion[] oppMinions = OpBoardZone.GetAll(); result += (minions.Count() - oppMinions.Count()) * 4 * Scale; result += getTotalMinionScore(minions); result -= getTotalMinionScore(oppMinions); if (OpMinionTotHealthTaunt > 0) { result += OpMinionTotHealthTaunt * -Scale; } return(result); }
public override int Rate() { // lose if (HeroHp < 1) { return(Int32.MinValue); } // win if (OpHeroHp < 1) { return(Int32.MaxValue); } int result = 0; int scale = 1000; Controller player = Controller; Controller opp = player.Opponent; int heroHp = HeroHp + player.Hero.Armor; int oppHeroHp = OpHeroHp + opp.Hero.Armor; // ReSharper disable once UselessBinaryOperation result = (heroHp - oppHeroHp) * scale + result; result += HandCnt * 3 * scale; result -= OpHandCnt * 3 * scale; Minion[] minions = BoardZone.GetAll(); result += minions.Count() * 2 * scale; foreach (Minion minion in minions) { result += getMinionScore(minion) * scale; } Minion[] oppMinions = OpBoardZone.GetAll(); result -= oppMinions.Count() * 2 * scale; foreach (Minion oppMinion in oppMinions) { result -= getMinionScore(oppMinion) * scale; } return(result); }
public static ISimpleTask SummonAllFriendlyDiedThisTurn(SelfCondition condition = null) { return(new CustomTask((g, c, s, t, stack) => { BoardZone board = c.BoardZone; if (board.IsFull) { return; } int num = c.NumFriendlyMinionsThatDiedThisTurn; ReadOnlySpan <IPlayable> graveyard = c.GraveyardZone.GetSpan(); Span <int> buffer = stackalloc int[num]; int k = 0; for (int i = graveyard.Length - 1, j = 0; j < num; --i) { if (!graveyard[i].ToBeDestroyed) { continue; } if (graveyard[i].Card.Type != CardType.MINION) { continue; } j++; if ((!condition?.Eval(graveyard[i]) ?? false)) { continue; } buffer[k++] = i; } for (--k; k >= 0; --k) { Entity.FromCard(in c, graveyard[buffer[k]].Card, zone: board, creator: in s); if (board.IsFull) { return; } } })); }
public override int Rate() { if (HeroHp < 1) { return(Int32.MinValue); } if (OpHeroHp < 1) { return(Int32.MaxValue); } int result = 0; int scale = 1000; Controller player = Controller; Controller opp = player.Opponent; int heroHp = HeroHp + player.Hero.Armor; int oppHeroHp = OpHeroHp + opp.Hero.Armor; result += (heroHp - oppHeroHp) * scale; result += HandCnt * 3 * scale; result -= OpHandCnt * 3 * scale; Minion[] minions = BoardZone.GetAll(); result += minions.Count() * 2 * scale; foreach (Minion minion in minions) { result += MinionScore(minion) * scale; } Minion[] oppMinions = OpBoardZone.GetAll(); result -= oppMinions.Count() * 2 * scale; foreach (Minion oppMinion in oppMinions) { result -= MinionScore(oppMinion) * scale; } return(result); }
private AdjacentAura(AdjacentAura prototype, Minion owner, bool cloning) : this() { EnchantmentCard = prototype.EnchantmentCard; _effects = prototype._effects ?? EnchantmentCard.Power.Enchant.Effects; _owner = owner; _history = owner.Game.History; owner.OngoingEffect = this; owner.Game.Auras.Add(this); _board = owner.Controller.BoardZone; _board.AdjacentAuras.Add(this); if (cloning) { if (prototype._left != null) { _left = (Minion)owner.Game.IdEntityDic[prototype._left.Id]; } if (prototype._right != null) { _right = (Minion)owner.Game.IdEntityDic[prototype._right.Id]; } } }
//Choice cards***can choose a task when you play it private PlayerTask PlayCard(List <PlayerTask> PlayerTaskList, Controller myself, HandZone myHand, BoardZone theBoard, POGame game) { PlayerTask returnTask = null; int maxManaCard = 0; int HighestDamage = 0; int WeaponAttackDamage = 0; //For each valid option, prints all available moves and the cost of the card foreach (PlayerTask task in PlayerTaskList) { if (task.PlayerTaskType == PlayerTaskType.PLAY_CARD) { /*if(task.Target != null){ * Console.WriteLine($"Can Play: {task} Mana: {task.Source.Card.Cost} Target Controller: {task.Target.Controller} Type: {task.Source.Card.Type}"); * } * else{ * Console.WriteLine($"Can Play {task}, {task.Source.Card.Cost} mana. Type: {task.Source.Card.Type}"); * }*/ var cardType = task.Source.Card.Type; if (game.CurrentPlayer.RemainingMana > 0) { if (cardType == CardType.MINION) { //Console.WriteLine(task); //Console.WriteLine($"Entered if statement 0"); if (task.Source.Card.Taunt == true) { //Console.WriteLine($"Entered if statement 1"); if (theBoard.Count() >= 1) { //Console.WriteLine($"Entered if statement 2"); returnTask = task; } } else if (task.Source.Card.Charge == true || task.Source.Card.Rush == true && task.PlayerTaskType == PlayerTaskType.PLAY_CARD && task.Source.Card.Cost >= maxManaCard) { //Adds to the task list because these minions can attack in the same turn //Console.WriteLine($"Entered if statement 3"); maxManaCard = task.Source.Card.Cost; returnTask = task; var mi = new MinionID(); //mi = minion id Minion PlayerMinion = null; Minion OpponentMinion = null; foreach (var x in playerList) { if (x.ToString().Equals(task.Source.ToString())) { PlayerMinion = x; } } int Damage = 0; foreach (var y in opponentList) { if (y.AttackDamage > Damage) { Damage = Damage + y.AttackDamage; OpponentMinion = y; } } mi.playerMinion = PlayerMinion; mi.opponentMinion = OpponentMinion; TurnTaskList.Add(mi); continue; } else { if (task.PlayerTaskType == PlayerTaskType.PLAY_CARD && task.Source.Card.Cost >= maxManaCard) { maxManaCard = task.Source.Card.Cost; returnTask = task; } } } else if (cardType == CardType.SPELL && task.Target != null && task.Target.Controller != myself && task.Target.Health > 0) { //Better way to verify spell target by ID for (int i = 0; i < opponentList.Count(); i++) { if (opponentList[i].Id == task.Target.Id) { returnTask = task; } else if (task.Target.AttackDamage > HighestDamage) { HighestDamage = task.Target.AttackDamage; returnTask = task; } } if (task.Target.Id == game.CurrentOpponent.Hero.Id) { returnTask = task; } continue; } else if (cardType == CardType.WEAPON) { if (task.Source.Card.ATK > WeaponAttackDamage) { WeaponAttackDamage = task.Source.Card.ATK; returnTask = task; } } // can't explicitly target own minions and hero else if (task.Target == null) { maxManaCard = task.Source.Card.Cost; returnTask = task; } } else if (myHand.Count() == 1) { returnTask = task; } else { //Console.WriteLine($"No play card task available"); } } } /*if(returnTask == null){ * Console.WriteLine("Return Playcard task: No card selected"); * } * else{ * Console.WriteLine($"Return PlayCard task: {returnTask}"); * }*/ return(returnTask); }
public override int Rate() { if (OpHeroHp < 1) { return(Int32.MaxValue); } if (HeroHp < 1) { return(Int32.MinValue); } int result = 0; int index = Turn; if (index > 9) { index = 9; } result += BoardCoef[index, RemainingManaCoef] * RemainingMana; result += BoardCoef[index, UsedManaCoef] * UsedMana; result += BoardCoef[index, ArmerCoef] * Armer; result += BoardCoef[index, OpArmerCoef] * OpArmer; result += BoardCoef[index, BoardZoneCntCoef] * BoardZoneCnt; result += BoardCoef[index, OpBoardZoneCntCoef] * OpBoardZoneCnt; result += BoardCoef[index, HeroHpCoef] * HeroHp; result += BoardCoef[index, OpHeroHpCoef] * OpHeroHp; result += BoardCoef[index, HeroAtkCoef] * HeroAtk; result += BoardCoef[index, OpHeroAtkCoef] * OpHeroAtk; result += BoardCoef[index, HandTotCostCoef] * HandTotCost; result += BoardCoef[index, HandCntCoef] * HandCnt; result += BoardCoef[index, OpHandCntCoef] * OpHandCnt; result += BoardCoef[index, DeckCntCoef] * DeckCnt; result += BoardCoef[index, OpDeckCntCoef] * OpDeckCnt; result += BoardCoef[index, MinionTotAtkCoef] * MinionTotAtk; result += BoardCoef[index, OpMinionTotAtkCoef] * OpMinionTotAtk; result += BoardCoef[index, MinionTotHealthCoef] * MinionTotHealth; result += BoardCoef[index, OpMinionTotHealthCoef] * OpMinionTotHealth; result += BoardCoef[index, MinionTotHealthTauntCoef] * MinionTotHealthTaunt; result += BoardCoef[index, OpMinionTotHealthTauntCoef] * OpMinionTotHealthTaunt; foreach (Minion m in BoardZone.GetAll()) { if (m != null) { int cost = m.Cost; if (cost > 10) { cost = 10; } result += MinionsCoef[cost]; } } foreach (Minion m in OpBoardZone.GetAll()) { if (m != null) { int cost = m.Cost; if (cost > 10) { cost = 10; } result += OpMinionsCoef[cost]; } } return(result); }
public void OutputCurrentGameForTrainingData(Game game) { List <int> features = new List <int>(); HandZone Hand = game.CurrentPlayer.HandZone; BoardZone BoardZone = game.CurrentPlayer.BoardZone; BoardZone OpBoardZone = game.CurrentPlayer.Opponent.BoardZone; Minion[] minions = BoardZone.GetAll(); features.Add(game.Turn); features.Add((int)game.CurrentPlayer.HeroClass); features.Add(game.CurrentPlayer.Hero.Weapon == null? 0 : game.CurrentPlayer.Hero.Weapon.Card.AssetId); features.Add(game.CurrentPlayer.Hero.Weapon == null? 0 : game.CurrentPlayer.Hero.Weapon.AttackDamage); features.Add(game.CurrentPlayer.Hero.Weapon == null? 0 : game.CurrentPlayer.Hero.Weapon.Durability); features.Add(game.CurrentPlayer.Hero.Health); features.Add(game.CurrentPlayer.BaseMana); features.Add(game.CurrentPlayer.HandZone.Count); features.Add(game.CurrentPlayer.DeckZone.Count); features.Add(game.CurrentPlayer.BoardZone.Count); for (int i = 0; i < game.CurrentPlayer.HandZone.Count; i++) { features.Add(game.CurrentPlayer.HandZone[i].Card.AssetId); } for (int i = 0; i < 10 - game.CurrentPlayer.HandZone.Count; i++) { features.Add(0); } foreach (Minion minion in minions) { features.Add(minion.Card.AssetId); features.Add(minion[GameTag.ATK]); features.Add(minion[GameTag.HEALTH]); features.Add(minion[GameTag.DAMAGE]); features.Add(minion[GameTag.STEALTH]); features.Add(minion[GameTag.IMMUNE]); features.Add(minion[GameTag.TAUNT]); features.Add(minion[GameTag.CANT_BE_TARGETED_BY_SPELLS]); features.Add(minion[GameTag.NUM_ATTACKS_THIS_TURN]); features.Add(minion.Card.AssetId); } for (int _ = 0; _ < 7 - minions.Length; _++) { features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); } features.Add((int)game.CurrentOpponent.HeroClass); features.Add(game.CurrentOpponent.Hero.Weapon == null ? 0 : game.CurrentOpponent.Hero.Weapon.Card.AssetId); features.Add(game.CurrentOpponent.Hero.Weapon == null ? 0 : game.CurrentOpponent.Hero.Weapon.AttackDamage); features.Add(game.CurrentOpponent.Hero.Weapon == null ? 0 : game.CurrentOpponent.Hero.Weapon.Durability); features.Add(game.CurrentOpponent.Hero.Health); features.Add(game.CurrentOpponent.BaseMana); features.Add(game.CurrentOpponent.HandZone.Count); features.Add(game.CurrentOpponent.DeckZone.Count); features.Add(game.CurrentOpponent.BoardZone.Count); minions = OpBoardZone.GetAll(); foreach (Minion minion in minions) { features.Add(minion.Card.AssetId); features.Add(minion[GameTag.ATK]); features.Add(minion[GameTag.HEALTH]); features.Add(minion[GameTag.DAMAGE]); features.Add(minion[GameTag.STEALTH]); features.Add(minion[GameTag.IMMUNE]); features.Add(minion[GameTag.TAUNT]); features.Add(minion[GameTag.CANT_BE_TARGETED_BY_SPELLS]); features.Add(minion[GameTag.NUM_ATTACKS_THIS_TURN]); features.Add(minion.Card.AssetId); } for (int _ = 0; _ < 7 - minions.Length; _++) { features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); features.Add(0); } tmpData.Enqueue(features); }
public double[] GetFeatureVector() { var features = new double[FACTORS]; features[0] = (HeroHp); features[1] = (OpHeroHp); features[2] = (HeroAtk); features[3] = (OpHeroAtk); features[4] = (HandTotCost); features[5] = (HandCnt); features[6] = (OpHandCnt); features[7] = (DeckCnt); features[8] = (OpDeckCnt); features[9] = (MinionTotAtk); features[10] = (OpMinionTotAtk); features[11] = (MinionTotHealth); features[12] = (OpMinionTotHealth); features[13] = (MinionTotHealthTaunt); features[14] = (OpMinionTotHealthTaunt); features[15] = (Hand.Sum(x => x.IsExhausted ? 1 : 0)); features[16] = (Hand.Sum(x => x.Overload)); features[17] = (Hand.Sum(x => x.HasDeathrattle? 1 : 0)); features[18] = (Hand.Sum(x => x.HasLifeSteal ? 1 : 0)); features[19] = (Hand.Sum(x => x.IsEcho ? 1 : 0)); features[20] = (Hand.Sum(x => x.HasOverkill ? 1 : 0)); features[21] = (Hand.Sum(x => x.Cost)); features[22] = (BoardZone.Sum(x => x.SpellPower)); features[23] = (BoardZone.Sum(x => x.HasCharge ? 1 : 0)); features[24] = (BoardZone.Sum(x => x.HasDivineShield ? 1 : 0)); features[25] = (BoardZone.Sum(x => x.HasWindfury ? 1 : 0)); features[26] = (BoardZone.Sum(x => x.HasBattleCry ? 1 : 0)); features[27] = (BoardZone.Sum(x => x.HasDeathrattle ? 1 : 0)); features[28] = (BoardZone.Sum(x => x.HasInspire ? 1 : 0)); features[29] = (BoardZone.Sum(x => x.IsEnraged ? 1 : 0)); features[30] = (BoardZone.Sum(x => x.Freeze ? 1 : 0)); features[31] = (BoardZone.Sum(x => x.Poisonous ? 1 : 0)); features[32] = (BoardZone.Sum(x => x.HasLifeSteal ? 1 : 0)); features[33] = (BoardZone.Sum(x => x.Untouchable ? 1 : 0)); features[34] = (BoardZone.Sum(x => x.IsRush ? 1 : 0)); features[35] = (BoardZone.Sum(x => x.AttackableByRush ? 1 : 0)); features[36] = (OpBoardZone.Sum(x => x.SpellPower)); features[37] = (OpBoardZone.Sum(x => x.HasCharge ? 1 : 0)); features[38] = (OpBoardZone.Sum(x => x.HasDivineShield ? 1 : 0)); features[39] = (OpBoardZone.Sum(x => x.HasWindfury ? 1 : 0)); features[40] = (OpBoardZone.Sum(x => x.HasBattleCry ? 1 : 0)); features[41] = (OpBoardZone.Sum(x => x.HasDeathrattle ? 1 : 0)); features[42] = (OpBoardZone.Sum(x => x.HasInspire ? 1 : 0)); features[43] = (OpBoardZone.Sum(x => x.IsEnraged ? 1 : 0)); features[44] = (OpBoardZone.Sum(x => x.Freeze ? 1 : 0)); features[45] = (OpBoardZone.Sum(x => x.Poisonous ? 1 : 0)); features[46] = (OpBoardZone.Sum(x => x.HasLifeSteal ? 1 : 0)); features[47] = (OpBoardZone.Sum(x => x.Untouchable ? 1 : 0)); features[48] = (OpBoardZone.Sum(x => x.IsRush ? 1 : 0)); features[49] = (OpBoardZone.Sum(x => x.AttackableByRush ? 1 : 0)); return(features); }
static string FullPrint(this BoardZone b, bool json) { var str = new StringBuilder(); str.AppendLine($"{fiveTabs}\"in-play\": {{"); str.AppendLine($"{sixTabs}\"count\": {b.Count},"); int pos = 0; foreach (Minion m in b) { str.AppendLine($"{sixTabs}\"{pos}\": {{"); str.AppendLine($"{sevenTabs}\"name\": \"{m.Card.Name}\","); str.AppendLine($"{sevenTabs}\"atk\": \"{m.AttackDamage}\","); str.AppendLine($"{sevenTabs}\"health\": \"{m.Health}\""); if (m.HasCharge) { str.AppendLine($"{sevenTabs}\"charge\": \"true\","); } if (m.HasDivineShield) { str.AppendLine($"{sevenTabs}\"divine-shield\": \"true\","); } if (m.HasInspire) { str.AppendLine($"{sevenTabs}\"inspire\": \"true\","); } if (m.HasLifeSteal) { str.AppendLine($"{sevenTabs}\"lifesteal\": \"true\","); } if (m.Poisonous) { str.AppendLine($"{sevenTabs}\"poisonous\": \"true\","); } if (m.IsRush) { str.AppendLine($"{sevenTabs}\"rush\": \"true\","); } if (m.HasStealth) { str.AppendLine($"{sevenTabs}\"stealth\": \"true\","); } if (m.HasTaunt) { str.AppendLine($"{sevenTabs}\"taunt\": \"true\","); } if (m.HasWindfury) { str.AppendLine($"{sevenTabs}\"windfury\": \"true\","); } str.AppendLine($"{sixTabs}}},"); ++pos; } str.AppendLine($"{fiveTabs}}},"); return(str.ToString()); }
public float SocketEvaluate(Game game) { //int[] features = new int[163]; int count = 0; HandZone Hand = game.CurrentPlayer.HandZone; BoardZone BoardZone = game.CurrentPlayer.BoardZone; BoardZone OpBoardZone = game.CurrentPlayer.Opponent.BoardZone; Minion[] minions = BoardZone.GetAll(); features[count++] = (game.Turn); features[count++] = ((int)game.CurrentPlayer.HeroClass); features[count++] = (game.CurrentPlayer.Hero.Weapon == null ? 0 : game.CurrentPlayer.Hero.Weapon.Card.AssetId); features[count++] = (game.CurrentPlayer.Hero.Weapon == null ? 0 : game.CurrentPlayer.Hero.Weapon.AttackDamage); features[count++] = (game.CurrentPlayer.Hero.Weapon == null ? 0 : game.CurrentPlayer.Hero.Weapon.Durability); features[count++] = (game.CurrentPlayer.Hero.Health); features[count++] = (game.CurrentPlayer.BaseMana); features[count++] = (game.CurrentPlayer.HandZone.Count); features[count++] = (game.CurrentPlayer.DeckZone.Count); features[count++] = (game.CurrentPlayer.BoardZone.Count); for (int i = 0; i < game.CurrentPlayer.HandZone.Count; i++) { features[count++] = (game.CurrentPlayer.HandZone[i].Card.AssetId); } for (int i = 0; i < 10 - game.CurrentPlayer.HandZone.Count; i++) { features[count++] = (0); } foreach (Minion minion in minions) { features[count++] = (minion.Card.AssetId); features[count++] = (minion[GameTag.ATK]); features[count++] = (minion[GameTag.HEALTH]); features[count++] = (minion[GameTag.DAMAGE]); features[count++] = (minion[GameTag.STEALTH]); features[count++] = (minion[GameTag.IMMUNE]); features[count++] = (minion[GameTag.TAUNT]); features[count++] = (minion[GameTag.CANT_BE_TARGETED_BY_SPELLS]); features[count++] = (minion[GameTag.NUM_ATTACKS_THIS_TURN]); features[count++] = (minion.Card.AssetId); } for (int _ = 0; _ < 7 - minions.Length; _++) { features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); } features[count++] = ((int)game.CurrentOpponent.HeroClass); features[count++] = (game.CurrentOpponent.Hero.Weapon == null ? 0 : game.CurrentOpponent.Hero.Weapon.Card.AssetId); features[count++] = (game.CurrentOpponent.Hero.Weapon == null ? 0 : game.CurrentOpponent.Hero.Weapon.AttackDamage); features[count++] = (game.CurrentOpponent.Hero.Weapon == null ? 0 : game.CurrentOpponent.Hero.Weapon.Durability); features[count++] = (game.CurrentOpponent.Hero.Health); features[count++] = (game.CurrentOpponent.BaseMana); features[count++] = (game.CurrentOpponent.HandZone.Count); features[count++] = (game.CurrentOpponent.DeckZone.Count); features[count++] = (game.CurrentOpponent.BoardZone.Count); minions = OpBoardZone.GetAll(); foreach (Minion minion in minions) { features[count++] = (minion.Card.AssetId); features[count++] = (minion[GameTag.ATK]); features[count++] = (minion[GameTag.HEALTH]); features[count++] = (minion[GameTag.DAMAGE]); features[count++] = (minion[GameTag.STEALTH]); features[count++] = (minion[GameTag.IMMUNE]); features[count++] = (minion[GameTag.TAUNT]); features[count++] = (minion[GameTag.CANT_BE_TARGETED_BY_SPELLS]); features[count++] = (minion[GameTag.NUM_ATTACKS_THIS_TURN]); features[count++] = (minion.Card.AssetId); } for (int _ = 0; _ < 7 - minions.Length; _++) { features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); features[count++] = (0); } // Safety check if (count != 169) { Console.WriteLine("ERROR: Incorrect parameter size!"); } for (int i = 0; i < features.Length; i++) { byte[] tmpBytes = BitConverter.GetBytes(features[i]); dataBuffer[4 * i + 0] = tmpBytes[0]; dataBuffer[4 * i + 1] = tmpBytes[1]; dataBuffer[4 * i + 2] = tmpBytes[2]; dataBuffer[4 * i + 3] = tmpBytes[3]; } NNSocket.Send(dataBuffer); NNSocket.Receive(receiveBuffer, 4, SocketFlags.None); return(BitConverter.ToSingle(receiveBuffer)); }