Exemplo n.º 1
0
        public override List <Player> OnPlayerChosen(TrustedAI ai, Player player, List <Player> target, int min, int max)
        {
            List <Player> targets = new List <Player>(target);

            ai.SortByDefense(ref targets, false);
            foreach (Player p in targets)
            {
                if (ai.GetPrioEnemies().Contains(p) && !p.IsKongcheng())
                {
                    return new List <Player> {
                               p
                    }
                }
                ;
            }

            foreach (Player p in targets)
            {
                if (!ai.IsFriend(p) && !p.IsKongcheng())
                {
                    return new List <Player> {
                               p
                    }
                }
                ;
            }

            foreach (Player p in targets)
            {
                if (!ai.IsFriend(p))
                {
                    return new List <Player> {
                               p
                    }
                }
                ;
            }

            return(new List <Player> {
                targets[0]
            });
        }
    }
Exemplo n.º 2
0
        public override List <int> OnDiscard(TrustedAI ai, Player player, List <int> cards, int min, int max, bool option)
        {
            if (!ai.WillShowForAttack())
            {
                return(new List <int>());
            }

            Room       room   = ai.Room;
            Player     target = room.Current;
            List <int> ids    = new List <int>();

            foreach (int id in player.HandCards)
            {
                if (RoomLogic.CanDiscard(room, player, player, id))
                {
                    ids.Add(id);
                }
            }
            ai.SortByKeepValue(ref ids, false);
            double value = ai.GetKeepValue(ids[0], player);

            if (ai.GetOverflow(player) > 1)
            {
                value /= 3;
            }
            DamageStruct damage = new DamageStruct(Name, player, target);

            if (ai.IsFriend(target))
            {
                bool range = false;
                foreach (Player p in room.GetOtherPlayers(target))
                {
                    if (ai.GetPrioEnemies().Contains(p) && RoomLogic.InMyAttackRange(room, target, p))
                    {
                        range = true;
                        break;
                    }
                }

                if (range && target.HandcardNum + target.GetPile("wooden_ox").Count > 3)
                {
                    if (ai.GetDamageScore(damage).Score < -3 && ai.HasSkill("wushuang|jianchu", target) && value < 3)
                    {
                        return new List <int> {
                                   ids[0]
                        }
                    }
                    ;
                }
            }
            else
            {
                if (ai.GetDamageScore(damage).Score > 7 && value < 7)
                {
                    return new List <int> {
                               ids[0]
                    }
                }
                ;
                else if (ai.GetDamageScore(damage).Score > 4 && value < 3)
                {
                    if (ai.IsLackCard(target, Slash.ClassName) || target.HandcardNum + target.GetPile("wooden_ox").Count < 3)
                    {
                        return(new List <int> {
                            ids[0]
                        });
                    }
                    else
                    {
                        bool range = false;
                        foreach (Player p in room.GetOtherPlayers(target))
                        {
                            if (ai.IsFriend(p) && RoomLogic.InMyAttackRange(room, target, p))
                            {
                                range = true;
                                break;
                            }
                        }

                        if (!range)
                        {
                            return new List <int> {
                                       ids[0]
                            }
                        }
                        ;
                    }
                }
            }

            return(new List <int>());
        }
    }
        public override CardUseStruct OnResponding(TrustedAI ai, Player player, string pattern, string prompt, object data)
        {
            Room room = ai.Room;

            string[] strs = prompt.Split(':');

            CardUseStruct use    = new CardUseStruct(null, player, new List <Player>());
            Player        target = room.FindPlayer(strs[1]);

            if (target != null)
            {
                use.To.Add(target);

                List <ScoreStruct> values = ai.CaculateSlashIncome(player, null, new List <Player> {
                    target
                });
                if (values.Count > 0 && values[0].Score > 0)
                {
                    bool will_slash = false;
                    if (values[0].Score >= 10)
                    {
                        will_slash = true;
                    }
                    else if (ai.GetEnemies(player).Count == 1 && ai.GetOverflow(player) > 0)
                    {
                        foreach (int id in values[0].Card.SubCards)
                        {
                            if (room.GetCardPlace(id) == Player.Place.PlaceHand)
                            {
                                will_slash = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        foreach (Player p in values[0].Players)
                        {
                            if (ai.GetPrioEnemies().Contains(p))
                            {
                                will_slash = true;
                                break;
                            }
                        }
                    }

                    //todo: adjust ai personality
                    if (!will_slash && ai.GetOverflow(player) > 0)
                    {
                        foreach (int id in values[0].Card.SubCards)
                        {
                            if (room.GetCardPlace(id) == Player.Place.PlaceHand)
                            {
                                will_slash = true;
                                break;
                            }
                        }
                    }

                    if (will_slash)
                    {
                        use.Card = values[0].Card;
                    }
                }
            }
            return(use);
        }
Exemplo n.º 4
0
        public override void Use(TrustedAI ai, Player player, ref CardUseStruct use, WrappedCard card)
        {
            ai.Choice["shangyi"] = null;
            Room room = ai.Room;

            foreach (Player p in room.GetOtherPlayers(player))
            {
                if (ai.GetPlayerTendency(p) == "unknown")
                {
                    ai.Choice["shangyi"] = "hidden_general";
                    use.Card             = card;
                    use.To = new List <Player> {
                        p
                    };
                    return;
                }
            }

            List <Player> enemies = ai.GetPrioEnemies();

            ai.SortByDefense(ref enemies, false);
            foreach (Player p in enemies)
            {
                if (p.HandcardNum - ai.GetKnownCards(p).Count > 2)
                {
                    ai.Choice[Name] = "handcards";
                    use.Card        = card;
                    use.To          = new List <Player> {
                        p
                    };
                    return;
                }
            }

            enemies = ai.GetEnemies(player);
            ai.SortByDefense(ref enemies, false);
            foreach (Player p in enemies)
            {
                if (p.HandcardNum - ai.GetKnownCards(p).Count > 2)
                {
                    ai.Choice["shangyi"] = "handcards";
                    use.Card             = card;
                    use.To = new List <Player> {
                        p
                    };
                    return;
                }
            }
            foreach (Player p in enemies)
            {
                if (p.HandcardNum > ai.GetKnownCards(p).Count)
                {
                    ai.Choice["shangyi"] = "handcards";
                    use.Card             = card;
                    use.To = new List <Player> {
                        p
                    };
                    return;
                }
            }
        }