protected override Enum TestImplContext(Context context) { if (!IsPegusus && context.turn.CurrentGod != God.Mars) return TestResult.InvalidGod; gold = Constants.moveArmyCost; if (player.Gold < gold) return TestResult.NotEnoughtGold; if (islandFromID < 0 || islandFromID >= context.map.Islands.Count || islandToID < 0 || islandToID >= context.map.Islands.Count) return TestResult.InvalidIslandID; if (islandFromID == islandToID) return TestResult.FromAndToEqual; if (count < 1 || count > context.map.GetArmyCountByIsland(islandFromID, playerID)) return TestResult.InvalidCount; if (!context.map.HasIslandsShipBrige(islandFromID, islandToID, playerID)) return TestResult.DontConnectIslands; if (context.map.IsThereCreatureOnIsland(Card.Gorgon, islandFromID)) return TestResult.Gorgone; return TestResult.OK; }
protected override bool TestImpl(Context context) { if (context.turn.GetNextPlayerID() != PlayerInfoCM.NoID) return false; return true; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { List<int> turnPlayersOrder = new List<int>(); List<int> golds = new List<int>(context.players.PlayersCount); for (int i = 0; i < context.players.PlayersCount; ++i) golds.Add(0); for (int i = 0; i < context.auction.GodsOrder.Count; ++i) { AuctionCM.Bet bet = context.auction.GetMaxBetForGod(context.auction.GodsOrder[i]); if (bet != null) { golds[bet.playerID] = AuctionCM.GoldForBet(context.players.GetPlayer(bet.playerID), bet.bet); turnPlayersOrder.Add(bet.playerID); } } List<AuctionCM.Bet> apolloBets = context.auction.GetOrderedGodBets(God.Appolon); turnPlayersOrder.AddRange( apolloBets.Select(b => b.playerID).ToList() ); UOW uow = new UOW() { turnPlayersOrder = turnPlayersOrder, golds = golds }; return uow; }
protected override void DoImplContext(Context context) { context.turn.CountTurnActionCounter(); context.players.GetPlayer(playerID).ChangeMarkerValue(PlayerInfoCM.Marker.Philosopher, 1); if (gold > 0) context.players.GetPlayer(playerID).ChangeMarkerValue(PlayerInfoCM.Marker.Gold, -gold); }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { if (playerID == context.armyFight.AttackPlayerID) { UnitOfWork uow = new UOW_AttackRetreat() { playerID = playerID, islandFromID = context.armyFight.DefenceIslandID, islandToID = islandID, count = context.armyFight.AttackCount }; return uow; } else { UnitOfWork uow = new UOW_DefenceRetreat() { playerID = playerID, islandFromID = context.armyFight.DefenceIslandID, islandToID = islandID, count = context.armyFight.DefenceCount, killMinotaurus = context.armyFight.IsMinotaurus, changeOwner = changeOwner }; return uow; } }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { List<God> gods = new List<God>() { God.Mars, God.Sophia, God.Poseidon, God.Zeus }; List<God> godsOrder = new List<God>(); for (int i = 0; i < context.players.PlayersCount - 1; ++i) { int randomGod = context.Randomizer.Range(0, gods.Count-1); godsOrder.Add(gods[randomGod]); gods.RemoveAt(randomGod); } List<int> gold = new List<int>(); for (int i = 0; i < context.players.PlayersCount; ++i ) { gold.Add(context.map.GetIncome(i)); } List<int> random = new List<int>(); int randomCount = context.cards.GetNewCardCountAfterShift(); int cardCount = Enum.GetValues(typeof(Card)).Length - 1; for (int i = 0; i < randomCount; i++) random.Add(context.Randomizer.Range(0, cardCount)); UnitOfWork uow = new UOW() { godsOrder = godsOrder, gold = gold, random = random }; return uow; }
protected override Enum TestImplContext(Context context) { if (god == God.None) return TestResult.GodNoneBet; if (bet < 1) return TestResult.TooSmallBet; if (god != God.Appolon && player.Gold < AuctionCM.GoldForBet(player, bet)) return TestResult.NotEnoughtGold; if (!context.auction.GodPossibleToBet(player.ID, god)) return TestResult.GodDontPossibleToBet; AuctionCM.Bet maxBet = context.auction.GetMaxBetForGod(god); int maxbet = (maxBet == null ? 0 : maxBet.bet); if (god != God.Appolon) { if (bet < maxbet) return TestResult.TooSmallBet; } else { if (bet != maxbet + 1) return TestResult.WrongApolloBet; } return TestResult.OK; }
protected override void DoImplContext(Context context) { for (int i = 0; i < builds.Count; ++i) context.map.DestroyBuild(builds[i]); context.map.BuildMetro(islandID); }
private static VariantOffer CheckBuildAndMoveNavy(Context context, PlayerInfoCM player, AIOptions options, int restOfGold) { VariantOfferPackage package = new VariantOfferPackage(); int restUnits = Math.Min(Constants.maxArmyCount - context.map.Navy.Where(e => e.OwnerID == player.ID).Count(), Constants.armyPrices.Count); if (restUnits < 1) return null; List<IslandCM> enemyNeibourIslands = Library.Map.GetEnemyNeibourIslands(context.map, player.ID, false); float maxNeedBridgeVP = 0; for (int i = 0; i < enemyNeibourIslands.Count; ++i) { IslandCM enemyIsland = enemyNeibourIslands[i]; float vp = Library.Map.GetIslandPriceVP(context.map, enemyIsland.ID, player.ID, options) * options.coefficients.BridgeToIslandPriceCoeff; if (vp > maxNeedBridgeVP) maxNeedBridgeVP = vp; } if (maxNeedBridgeVP > 0) package.Add(new VariantOffer(0, maxNeedBridgeVP)); if (Library.Map.GetAccessibleSeaHorns(context.map, player.ID, false, false).Count > 0) package.Add(new VariantOffer(Constants.moveNavyCost + Constants.navyPrices[1], options.coefficients.HornVPT * options.turnsToEnd)); return package.GetSum(); }
protected override Enum TestImplContext(Context context) { if (islandID < 0 || islandID >= context.map.Islands.Count) return TestResult.InvalidIslandID; IslandCM island = context.map.Islands[islandID]; if (island.OwnerID != playerID) return TestResult.AlienIsland; if (builds.Count == 0) builds = context.map.GetBuildsAddrsForMetro(playerID, islandID); if (builds.Count != 4) return TestResult.WrongBuilds; if (builds.Select(a => context.map.GetBuild(a)).Where(b => b != Build.None).Count() != builds.Count) return TestResult.WrongBuilds; for (int i = 0; i < IslandCM.IslandMetroSizeByIslandSize(island.Size); ++i) { SlotAddr addr = SlotAddr.Create(islandID, i); if (island.Slots[i] != Build.None && !builds.Contains(addr)) return TestResult.WrongBuilds; } return TestResult.OK; }
protected override void DoImplContext(Context context) { if (killNavyCount > 0) context.map.KillNavy(cell, killNavyPlayerID, killNavyCount); context.map.CreateKraken(cell); }
public UseCardSyl() : base() { } //JSON Constructor protected override Enum TestImplContext(Context context) { if (context.cards.ActiveOpenCard != Card.Sylph) return TestResult.WrongCard; return TestResult.OK; }
protected override void DoImplContext(Context context) { context.map.KillNavy(cell, enemyID); if (change) context.map.BuyNavy(playerID, cell); }
protected override Enum TestImplContext(Context context) { if (context.turn.CurrentGod != God.Mars) return TestResult.InvalidGod; gold = Constants.moveNavyCost; if (player.Gold < gold) return TestResult.NotEnoughtGold; if (from == to) return TestResult.FromAndToEqual; if (!context.map.IsPointsNeibours(from, to)) return TestResult.NotNeibours; if (count < 1 || count > context.map.GetNavyCountByCell(from, playerID)) return TestResult.InvalidCount; if (context.turn.MoveNavyLastCell != null && context.turn.MoveNavyLastCell != from) return TestResult.BrokenMove; if (!context.map.IsPointAccessibleForShip(to, playerID, true)) return TestResult.ForbiddenHex; return TestResult.OK; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { }; return uow; }
protected override Enum TestImplContext(Context context) { if (context.turn.CurrentGod != God.Poseidon) return TestResult.InvalidGod; if (!context.map.IsPointOnMap(hex)) return TestResult.InvalidHex; if (!context.map.GetNeiborIslandsByMapPos(hex).Any(i => i.OwnerID == playerID)) return TestResult.AlienIsland; if (!context.map.IsPointAccessibleForShip(hex, playerID, false)) return TestResult.ForbiddenHex; if (context.map.Navy.Where(a => a.OwnerID == playerID).Count() >= Constants.maxNavyCount) return TestResult.NotEnouthUnit; if (context.turn.TurnActionCounter >= Constants.navyPrices.Count) return TestResult.NotEnouthActions; gold = Constants.navyPrices[context.turn.TurnActionCounter]; if (player.Gold < gold) return TestResult.NotEnouthGold; return TestResult.OK; }
protected override bool TestImplContextCurrentCard(Context context) { if (context.map.IsThereCreatureOnIsland(Card.Chiron, islandID)) return false; return base.TestImplContextCurrentCard(context); }
protected override void DoImplContext(Context context) { if (isNeedTrashActiveCard) context.cards.TrashActiveCard(); if (isNeedRefreshStack) context.cards.RefreshStack(); }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { move = Constants.sylphNavyMove }; return uow; }
protected override void DoImplContext(Context context) { if (count > 0) { context.players.GetPlayer(enemyID).ChangeMarkerValue(PlayerInfoCM.Marker.Philosopher, -count); context.players.GetPlayer(playerID).ChangeMarkerValue(PlayerInfoCM.Marker.Philosopher, +count); } }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { isNeedTrashActiveCard = (context.cards.ActiveOpenCard != Card.None), isNeedRefreshStack = context.cards.IsNeedRefreshStack }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { islandID = islandID, enemyID = enemyID }; return uow; }
protected override Enum TestImpl(Context context) { if (playerID != context.CurrentPlayerID) return TestResult.NotCurrentPlayer; player = context.players.GetPlayer(playerID); return TestImplContext(context); }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { addr = addr, build = build }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, gold = Constants.sellCost }; return uow; }
private static VariantOffer CheckNeedBuild(Context context, PlayerInfoCM player, AIOptions options, int restOfGold) { VariantOfferPackage package = new VariantOfferPackage(); package.Add(AuctionCommon.CheckNeedBuild(context, player, options, Build.Poseidon, restOfGold)); package.CheckAll(options); return package.GetAvg(); }
protected override void DoImplContext(Context context) { context.players.GetPlayer(playerID).ChangeMarkerValue(PlayerInfoCM.Marker.Philosopher, -Constants.philosophToMetro); for (int i = 0; i < builds.Count; ++i) context.map.DestroyBuild(builds[i]); context.map.BuildMetro(islandID); }
protected override bool TestImpl(Context context) { int playerID = context.CurrentPlayerID; List<IslandCM> playerIslands = context.map.GetIslandsByOwner(playerID); int playerBuildingsCount = playerIslands.SelectMany(i => i.Slots.Where(b => b != Build.None)).Distinct().Count(); return (playerBuildingsCount == Enum.GetValues(typeof(Build)).Length - 1); }
private static Context MakeContext() { Context context = new Cyclades.Context(5, 0); Serialization.Serialize(context, "context.txt"); context = Serialization.DeSerializeFile<Cyclades.Context>("context.txt"); return context; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, gold = gold }; return uow; }