Ejemplo n.º 1
0
        public static CardGameAI TurnProbability(AllTurnProbabilities probability)
        {
            CardGameAI result = new CardGameAI();

            result.winProbability = (me, them, isFirst, bidScalar) => probability.GetWinProbability(them.cardsPlayed, me.visibleScore, isFirst ? 0 : bidScalar, them.visibleScore, them.allMatch);
            result.foldProbaility = (me, them, isFirst, bidScalar) => probability.GetFoldProbability(them.cardsPlayed, me.cardsPlayed, me.visibleScore, me.initialAllMatch, isFirst ? bidScalar : 0, them.visibleScore, them.allMatch);
            result.learn          = (turnResults, amIFirst, myTopScore, theirTopScore, myDouble, theirDouble) => probability.Learn(turnResults, amIFirst, myTopScore, theirTopScore, myDouble, theirDouble);
            return(result);
        }
Ejemplo n.º 2
0
    PlayerLogic BuildPlayerLogic(PlayerHand hand, Text money, CardGameVariables variables, string savedName, TextAsset fallback)
    {
        switch (variables.aiType)
        {
        case CardAIType.NeverFold:
        default:
            shootout.AllTurnProbabilities turnProbs;

            if (loadedAI.ContainsKey(savedName))
            {
                turnProbs = loadedAI[savedName];
            }
            else
            {
                turnProbs           = new shootout.AllTurnProbabilities();
                loadedAI[savedName] = turnProbs;
                string filename = Path.Combine(Application.persistentDataPath, savedName + ".ai");

                DebugLog("Loading AI from " + filename);


                if (File.Exists(filename))
                {
                    DebugLog("Loading from file");
                    using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
                    {
                        turnProbs.Read(reader);
                    }
                }
                else
                {
                    DebugLog("Loading for prefab");
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(fallback.bytes)))
                    {
                        turnProbs.Read(reader);
                    }
                }
            }

            DebugLog("Loaded");


            return(new CalculatedAI(1, hand, money, shootout.CardGameAI.TurnProbability(turnProbs)));
        }
    }