Example #1
0
    public override void OnInspectorGUI()
    {
        WinConditions wc = (WinConditions)target;

        wc.burnTillCompletion = (WinConditions.CompletionAmount)EditorGUILayout.EnumPopup("BurnTillCompletion", wc.burnTillCompletion);
        if (wc.burnTillCompletion == WinConditions.CompletionAmount.Percentage)
        {
            wc.burnCompletion = EditorGUILayout.Slider("CompletionPercentage", wc.burnCompletion, 0, 100);
        }
        EditorGUILayout.Space();

        wc.tasksTillCompletion = (WinConditions.CompletionAmount)EditorGUILayout.EnumPopup("TasksTillCompletion", wc.tasksTillCompletion);
        if (wc.tasksTillCompletion == WinConditions.CompletionAmount.Percentage)
        {
            wc.taskCompletion = EditorGUILayout.Slider("CompletionPercentage", wc.taskCompletion, 0, 100);
        }
        EditorGUILayout.Space();

        wc.timeOutWinner = (WinConditions.Player)EditorGUILayout.EnumPopup("WinnerOnTimeUp", wc.timeOutWinner);
        if (wc.timeOutWinner != WinConditions.Player.No_Condition)
        {
            EditorGUILayout.BeginHorizontal();
            wc.timeCompletion = EditorGUILayout.IntField("TimeTillCompletion", wc.timeCompletion);
            if (wc.timeCompletion < 0)
            {
                wc.timeCompletion = 0;
            }
            EditorGUILayout.LabelField(Mathf.Floor(wc.timeCompletion / 60).ToString().PadLeft(2, '0') + ":" + (wc.timeCompletion % 60).ToString().PadLeft(2, '0'));
            EditorGUILayout.EndHorizontal();
        }
    }
Example #2
0
        public ComputerLogicTest()
        {
            Board board = new Board();

            board.SetMarkers("X", "O");
            WinConditions winConditions = new WinConditions();

            this.computerLogic = new ComputerLogic(winConditions);
        }
Example #3
0
    public void AddCondition()
    {
        WinConditions condition = new WinConditions();

        condition._conditions = new BitArray(new bool[_slotMachine._slotsCount * _slotMachine._rowCount]);
        _slotMachine._conditions.Add(condition);

        Fill();
    }
Example #4
0
        public void WinConditions_CheckWinConditions_ReturnTrueIfRowOfX()
        {
            string[,] rowOfXArray = new string[3, 3] {
                { "X", "X", "X" }, { "*", "*", "*" }, { "*", "*", "*" }
            };
            WinConditions winConditions = new WinConditions();
            bool          result        = winConditions.CheckWinConditions(rowOfXArray);

            Assert.True(result);
        }
Example #5
0
 public void Win(WinConditions winCondition)
 {
     winSound.Play();
     GameController.GameHasStarted = false;
     foreach (var player in playerRefs)
     {
         ScoreSystem.AwardPoints(player.GetComponent <PlayerInput>().PlayerID, winCondition);
     }
     WinActions(Color.white);
 }
Example #6
0
    public void Win(GameObject player, WinConditions winCondition)
    {
        winSound.Play();
        GameController.GameHasStarted = false;
        var playerID = player.GetComponent <PlayerInput>().PlayerID;

        ScoreSystem.AwardPoints(playerID, winCondition);
        var playerColor = PlayerSetup.GetColorFromPlayerID(playerID);

        WinActions(playerColor);
    }
Example #7
0
 public void PickNextGameMode()
 {
     winCondition   = gameModes[gamesModesIterator].winCondition;
     environmentMod = gameModes[gamesModesIterator].environmentMods;
     UIController.GameModeName(gameModes[gamesModesIterator].name);
     gamesModesIterator++;
     if (gamesModesIterator > gameModes.Length - 1)
     {
         gamesModesIterator = 0;
     }
 }
Example #8
0
    public static void AwardPoints(int playerID, WinConditions winCondition)
    {
        var points      = WinCondition2Points(winCondition);
        var playerColor = PlayerSetup.GetColorFromPlayerID(playerID);

        scoreData.Add(new ScoreData
        {
            Color         = playerColor,
            Condition     = winCondition,
            PointsAwarded = points,
        });
        playerID2Score[playerID] += points;
    }
Example #9
0
    private void Awake()
    {
        WinConditions initCondition = new WinConditions();

        initCondition._conditions = new System.Collections.BitArray(new bool[] { false, false, false, false, false,
                                                                                 true, true, true, true, true,
                                                                                 false, false, false, false, false });
        WinRate rate = new WinRate();

        rate.count = 3;
        rate.rate  = 1.5f;
        initCondition._winRate.Add(rate);
        _conditions.Add(initCondition);
    }
Example #10
0
	void OnLevelWasLoaded(int level) {
		currentLevel = level;
		win = Camera.main.GetComponent<WinConditions>();
		EscapeMenu.SetTrigger ("disable");
		LevelMenu.SetTrigger ("disable");
		if (currentLevel == 0) {
			MainMenu.SetTrigger ("enable");
			SpawnUI.Active = false;
		} else { 
			MainMenu.SetTrigger ("disable");
			SpawnUI.Active = true;
		}
		escapeMenuOpen = false;
	}
Example #11
0
 public static void Write(CrcWriter w, WinConditions wc)
 {
     w.Write(wc.LockedDoorCount);
     w.Write(wc.UnlockedDoorCount);
     w.Write(wc.ChestCount);
     w.Write(wc.CubeShardCount);
     w.Write(wc.OtherCollectibleCount);
     w.Write(wc.SplitUpCount);
     w.Write(wc.ScriptIds.Count);
     foreach (int num in wc.ScriptIds)
     {
         w.Write(num);
     }
     w.Write(wc.SecretCount);
 }
Example #12
0
        private bool ThreeOAKToFullHouseOr4OAK(List <Card> street, List <Card> cardHand)
        { // Outs 7
            WinConditions wc   = new WinConditions();
            List <Card>   temp = new List <Card> {
                cardHand[0], cardHand[1]
            };

            foreach (Card card in street)
            {
                temp.Add(card);
            }
            temp.Sort();
            if (wc.HasThreeOfAKind(temp))
            {
                return(true);
            }
            return(false);
        }
Example #13
0
        public List <Card> findMissingCardsForStraight(List <Card> listOfPossibleStraightCards, List <Card> straightCards)
        {
            WinConditions wc = new WinConditions();
            List <Card>   allStraightCards = new List <Card>();


            wc.RemoveDublicateRank(listOfPossibleStraightCards, 0);

            var MinVal = listOfPossibleStraightCards.Min();
            var MaxVal = listOfPossibleStraightCards.Max();

            for (int i = 0; i < (MaxVal.Rank - MinVal.Rank); i++)
            {
                allStraightCards.Add(new Card(Suit.Hearts, listOfPossibleStraightCards[0].Rank + i));
            }

            List <Card> missingCardsStraight = new List <Card>(allStraightCards.Except(listOfPossibleStraightCards));

            return(missingCardsStraight);
        }
Example #14
0
        public static WinConditions ReadWonditions(CrcReader r)
        {
            WinConditions winConditions = new WinConditions();

            winConditions.LockedDoorCount       = r.ReadInt32();
            winConditions.UnlockedDoorCount     = r.ReadInt32();
            winConditions.ChestCount            = r.ReadInt32();
            winConditions.CubeShardCount        = r.ReadInt32();
            winConditions.OtherCollectibleCount = r.ReadInt32();
            winConditions.SplitUpCount          = r.ReadInt32();
            int num;

            winConditions.ScriptIds = new List <int>(num = r.ReadInt32());
            for (int index = 0; index < num; ++index)
            {
                winConditions.ScriptIds.Add(r.ReadInt32());
            }
            winConditions.SecretCount = r.ReadInt32();
            return(winConditions);
        }
Example #15
0
 public static void ScriptReferences()     //Assigns script references
 {
     systemListConstructor = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <SystemListConstructor>();
     cameraFunctionsScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFunctions>();
     turnInfoScript        = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <TurnInfo>();
     playerTurnScript      = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <PlayerTurn>();
     diplomacyScript       = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <DiplomacyControlScript>();
     systemGUI             = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <SystemGUI>();
     heroGUI               = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <HeroGUI>();
     racialTraitScript     = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <RacialTraits> ();
     galaxyGUI             = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <GalaxyGUI>();
     invasionGUI           = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <InvasionGUI> ();
     mapConstructor        = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <MapConstructor> ();
     winConditions         = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <WinConditions> ();
     systemFunctions       = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <SystemFunctions> ();
     systemInvasion        = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <SystemInvasions> ();
     uiObjects             = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <UIObjects> ();
     ambientStarRandomiser = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <AmbientStarRandomiser> ();
     voronoiGenerator      = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <VoronoiGeneratorAndDelaunay> ();
     heroResource          = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <HeroResourceImprovement> ();
     systemPopup           = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <SystemInfoPopup> ();
     triangulation         = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <Triangulation> ();
 }
Example #16
0
    private static int WinCondition2Points(WinConditions winConditions)
    {
        switch (winConditions)
        {
        case WinConditions.OneReachGoal:
            return(1);

        case WinConditions.AllReachGoal:
            return(1);

        case WinConditions.TouchAllPlatforms:
            return(1);

        case WinConditions.LastManStanding:
            return(1);

        case WinConditions.CaptureTheFlag:
            return(1);

        default:
            Debug.LogError($"NYI: {winConditions}");
            return(1);
        }
    }
Example #17
0
 private void Start()
 {
     _gameManager      = GameManager.Instance;
     _gamePieceManager = _gameManager.GetComponent <GamePieceManager>();
     _winConditions    = _gameManager.GetComponent <WinConditions>();
 }
 private void Awake()
 {
     winConditions  = GameObject.FindGameObjectWithTag("WinConditions").GetComponent <WinConditions>();
     conditionsPara = GetComponent <TextMeshProUGUI>();
 }
Example #19
0
        private PlayerAction MonteCarloOld()
        {
            WinConditions  wc = new WinConditions();
            RangeParser    rc = new RangeParser();
            EVCalculator   ev = new EVCalculator(_pokerGame, _settings);
            OutsCalculator oc = new OutsCalculator();

            List <string> RaisePreflop = new List <string>
            {
                "88+", "A2s+", "K5s+", "Q8s+", "J9s+", "T9s+", "98s", "87s", "A10o+", "K9o+", "Q9o+", "J9o+", "T9o"
            };
            List <string> CallPreflop = new List <string>
            {
                "22+", "A2s+", "K2s+", "Q2s+", "J2s+", "T6s+", "97s+", "87s", "A2o+", "K2o+", "Q2o+", "J9o+", "T9o"
            };

            List <Card> cardsToEvaluate = new List <Card>(_player.Cards);

            cardsToEvaluate.AddRange(_street);

            var handsToRaisePreflop = rc.Parse(RaisePreflop);
            var handsToCallPreflop  = rc.Parse(CallPreflop).Except(handsToRaisePreflop).ToList();
            var cardHand            = _player.Cards;

            List <double> ExpectedValues =
                new List <double>(ev.CalculateMonteCarlo(cardHand, _hand, _settings));

            var mtcBet  = ExpectedValues[0];
            var mtcCall = 0.00;

            if (ExpectedValues.Count > 1)
            {
                mtcCall = ExpectedValues[1];
            }

            if (_pokerGame.CurrentRoundNumber() == 1)
            {
                if (ContainsCardHand(handsToRaisePreflop, cardHand))
                {
                    if (_player.IsSmallBlind)
                    {
                        if (_pokerGame.CanRaise())
                        {
                            return(PlayerAction.Raise);
                        }

                        if (_pokerGame.CanCall())
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }

                if (ContainsCardHand(handsToCallPreflop, cardHand))
                {
                    if (_pokerGame.CanCall())
                    {
                        return(PlayerAction.Call);
                    }
                }
            }
            else if (_pokerGame.CurrentRoundNumber() == 2 || _pokerGame.CurrentRoundNumber() == 3)
            {
                // Flop + Turn

                var currentScore = wc.Evaluate(cardsToEvaluate);
                var compareOuts  = oc.CompareOuts(_player.Cards, _street);

                if (currentScore <= Score.Pair)
                {
                    if (_pokerGame.CanCall() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }

                    if (_pokerGame.CanCheck() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }


                    if (_pokerGame.CanCall() && !_pokerGame.CanCheck())
                    {
                        if (mtcBet > 0.00)
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }


                if (compareOuts > 0)
                {
                    if (oc.CompareOuts(cardHand, _street) > 5)
                    {
                        if (_pokerGame.CanRaise())
                        {
                            return(PlayerAction.Raise);
                        }

                        if (_pokerGame.CanCall())
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }
            }
            else if (_pokerGame.CurrentRoundNumber() == 4)
            {
                var currentScore = wc.Evaluate(cardsToEvaluate);

                if (currentScore >= Score.Pair)
                {
                    if (_pokerGame.CanCall() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }

                    if (_pokerGame.CanCheck() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }


                    if (_pokerGame.CanCall() && !_pokerGame.CanCheck())
                    {
                        if (mtcBet > 0.00)
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }
            }

            if (_pokerGame.CanCheck())
            {
                return(PlayerAction.Check);
            }

            return(PlayerAction.Fold);
        }
Example #20
0
        private int GetStraightOuts(List <Card> cardHand, List <Card> street)
        {
            //Checks for cards that are in range of a straight compared to the players hand

            WinConditions wc            = new WinConditions();
            List <Card>   straightCards = new List <Card> {
                cardHand[0], cardHand[1]
            };
            int cardRange = GetRankDifference(cardHand);

            // Inside straight chance

            if (cardRange == 4)
            {
                foreach (var element in street)
                {
                    if (element.Rank >= street.Min(s => s.Rank) && (element.Rank <= street.Max(s => s.Rank)))
                    {
                        straightCards.Add(element);
                    }
                }
            }
            else if (cardRange == 3)
            {
                foreach (var element in street)
                {
                    if (element.Rank >= street.Min(s => s.Rank) && element.Rank <= street.Max(s => s.Rank) ||
                        element.Rank >= street.Min(s => s.Rank - 1) ||
                        element.Rank <= street.Max(s => s.Rank + 1))
                    {
                        straightCards.Add(element);
                    }
                }
            }
            else if (cardRange == 2)
            {
                foreach (var element in street)
                {
                    if (element.Rank >= street.Min(s => s.Rank) &&
                        element.Rank <= street.Max(s => s.Rank) ||
                        element.Rank >= street.Min(s => s.Rank - 2) ||
                        element.Rank <= street.Max(s => s.Rank + 2))
                    {
                        straightCards.Add(element);
                    }
                }
            }
            else if (cardRange == 1)    // Open ended connector
            {
                foreach (var element in street)
                {
                    if (element.Rank >= street.Min(s => s.Rank) &&
                        element.Rank <= street.Max(s => s.Rank) ||
                        element.Rank >= street.Min(s => s.Rank - 3) ||
                        element.Rank <= street.Max(s => s.Rank + 3))
                    {
                        straightCards.Add(element);
                    }
                }
            }

            wc.RemoveDublicateRank(straightCards, 0); // TODO: FIX
            return(5 - straightCards.Count);
        }
Example #21
0
    void CheckWinCondition(WinConditions condition)
    {
        switch (condition)
        {
        case WinConditions.Reach_Turn_Number:
        {
            _missionWin = GameManager.Instance._round >= _goldTurnNum;
            if (_missionWin)
            {
                MissionWinProcessing(2);
            }
        }
        break;

        case WinConditions.Kill_All_Enemies:
        {
            _missionWin = _numEnemies <= 0;
            if (_missionWin)
            {
                MissionWinProcessing(1);
            }
        }
        break;

        case WinConditions.Kill_Certain_Enemy:
        {
            if (_enemyVIPs.Count > 0)
            {
                foreach (string vip in _enemyVIPs)
                {
                    if (!_missionWin)
                    {
                        ChrController chr = GameManager.Instance._enemies.Find(h => h._name == vip);
                        if (chr != null)
                        {
                            if (chr._isDead)
                            {
                                _missionWin = true;
                                MissionWinProcessing(0);
                            }
                        }
                    }
                }
            }
        }
        break;

        case WinConditions.Reach_Certain_Location:
        {
            ChrController chr = GameManager.Instance._heros.Find(e => (e._position == _goalLocation) && !e._isDead);
            if (chr != null)
            {
                _goalReached = true;
            }
            _missionWin = _goalReached;
            if (_missionWin)
            {
                MissionWinProcessing(3);
            }
        }
        break;
        }
    }
        static void Main()
        {
            FastWinCalc   WinCalc1 = new FastWinCalc();
            WinConditions winCalc2 = new WinConditions();
            List <Card>   player1Cards = new List <Card>(), player2Cards = new List <Card>(), Street = new List <Card>(), CardsInPlay = new List <Card>();
            Card          NewCard;
            List <Player> players = new List <Player>()
            {
                new Player(0, 1000), new Player(1, 1000)
            };
            WinCalcVsWinCalc functions = new WinCalcVsWinCalc();

            int resultWinCalc1;
            int resultWinCalc2;
            int counter = 0;

            while (true)
            {
                counter++;
                if (counter % 1000 == 0)
                {
                    Console.WriteLine("Counter: " + counter);
                }
                //if (players[0].Cards.Count < 7 && players[1].Cards.Count < 7 && player1Cards.Count < 7 &&) {
                //    Console.WriteLine("FEJL");
                //    Console.ReadKey();
                //}
                players[0].Cards.Clear();
                players[1].Cards.Clear();
                player1Cards.Clear();
                player2Cards.Clear();
                Street.Clear();
                CardsInPlay.Clear();


                for (int x = 0; x < 2; x++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    player1Cards.Add(NewCard);
                }

                for (int x = 0; x < 2; x++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    player2Cards.Add(NewCard);
                }


                for (int x = 0; x < 5; x++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    Street.Add(NewCard);
                }

                Player resultWinCalc2Player;
                players[0].Cards = new List <Card>(player1Cards.Concat(Street).ToList());
                players[1].Cards = new List <Card>(player2Cards.Concat(Street).ToList());
                players[0].Cards.Sort();
                players[1].Cards.Sort();
                players[0].Score = winCalc2.Evaluate(players[0].Cards);
                players[1].Score = winCalc2.Evaluate(players[1].Cards);

                if (players[0].Score == players[1].Score)
                {
                    resultWinCalc1 = WinCalc1.WhoWins(players[0].Cards, players[1].Cards);
                    winCalc2.GiveScoreHand(players[0]);
                    winCalc2.GiveScoreHand(players[1]);
                    resultWinCalc2Player = winCalc2.WhoWins(players[0], players[1]);
                    if (resultWinCalc2Player == null)
                    {
                        resultWinCalc2 = 0;
                    }
                    else if (resultWinCalc2Player.Id == 0)
                    {
                        resultWinCalc2 = -1;
                    }
                    else
                    {
                        resultWinCalc2 = 1;
                    }
                    if (resultWinCalc1 != resultWinCalc2)
                    {
                        for (int j = 0; j <= players[0].ScoreHand.Count - 1; j++)
                        {
                            Console.WriteLine("Players Cards:" + players[0].ScoreHand[j].Rank + " " + players[0].ScoreHand[j].Suit);
                        }
                        Console.WriteLine("");
                        for (int j = 0; j <= players[1].ScoreHand.Count - 1; j++)
                        {
                            Console.WriteLine("Players Cards:" + players[1].ScoreHand[j].Rank + " " + players[1].ScoreHand[j].Suit);
                        }
                        Console.WriteLine("");
                        Console.WriteLine("player1 hand: " + player1Cards[0].Suit + player1Cards[0].Rank + " " + player1Cards[1].Suit + player1Cards[1].Rank);
                        Console.WriteLine("Street  hand: " + Street[0].Suit + Street[0].Rank + " " + Street[1].Suit + Street[1].Rank + " " + Street[2].Suit + Street[2].Rank + " " + Street[3].Suit + Street[3].Rank + " " + Street[4].Suit + Street[4].Rank);
                        Console.WriteLine("player2 hand: " + player2Cards[0].Suit + player2Cards[0].Rank + " " + player2Cards[1].Suit + player2Cards[1].Rank);
                        Console.WriteLine("\nWinCon1: " + resultWinCalc1);
                        Console.WriteLine("WinCon2: " + resultWinCalc2);
                        Console.WriteLine("\nScore: " + players[0].Score);
                        Console.ReadKey();
                    }
                }
            }
        }
        public Odds TestRunTrails(int NumberOfTrails)
        {
            int           x, n, missingCardsOnStreet = 5 - street.Count;
            int           wins = 0, loses = 0, draws = 0, result;
            WinConditions winCalc = new WinConditions();
            Card          NewCard = new Card(0);
            List <Card>   trailStreet = new List <Card>(), opponantTrailCards = new List <Card>(), CardsInPlay, aiTrailCards;
            List <Player> players = new List <Player>()
            {
                new Player(0, 1000), new Player(1, 1000)
            };

            for (x = 0; x < NumberOfTrails; x++)
            {
                trailStreet = new List <Card>(street);
                CardsInPlay = street.Concat(aiHand).ToList();

                for (n = 0; n < missingCardsOnStreet; n++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    trailStreet.Add(NewCard);
                }

                aiTrailCards       = aiHand.Concat(trailStreet).ToList();
                opponantTrailCards = trailStreet;

                /*
                 * for (n = 0; n < 2; n++)
                 * {
                 *  NewCard = new Card(CardsInPlay);
                 *  CardsInPlay.Add(NewCard);
                 *  opponantTrailCards.Add(NewCard);
                 * }
                 */


                //forced to add to opponent hand
                opponantTrailCards.Add(new Card(Suit.Diamonds, Rank.King));
                opponantTrailCards.Add(new Card(Suit.Diamonds, Rank.Ace));
                players[0].Cards = opponantTrailCards;
                players[1].Cards = aiTrailCards;
                players[0].Cards.Sort();
                players[1].Cards.Sort();
                players[0].Score = winCalc.Evaluate(players[0].Cards);
                players[1].Score = winCalc.Evaluate(players[1].Cards);
                winCalc.GiveScoreHand(players[0]);
                winCalc.GiveScoreHand(players[1]);

                if (players[0].Score > players[1].Score)
                {
                    loses++;
                }
                else if (players[0].Score < players[1].Score)
                {
                    wins++;
                }
                else
                {
                    if (winCalc.WhoWins(players[0], players[1]) == null)
                    {
                        draws++;
                    }
                    else if (winCalc.WhoWins(players[0], players[1]).Id == 1)
                    {
                        wins++;
                    }
                    else
                    {
                        loses++;
                    }
                }

                CardsInPlay.Clear();
                opponantTrailCards.Clear();
                aiTrailCards.Clear();
            }

            Odds Results = new Odds((double)wins / (double)NumberOfTrails * 100,
                                    (double)loses / (double)NumberOfTrails * 100,
                                    (double)draws / (double)NumberOfTrails * 100);

            Console.WriteLine("Wins: {0} , Loses: {1} , Draws: {2}", wins, loses, draws);
            PrintResults(Results);
            Console.WriteLine("");

            return(Results);
        }
Example #24
0
 // Use this for initialization
 void Start()
 {
     wc = GameObject.Find("GameManager").GetComponent <WinConditions>();
     GetComponent <Rigidbody>().velocity = transform.forward * speed;
 }
Example #25
0
 public WinConditionsTest()
 {
     this.winConditions = new WinConditions();
 }
Example #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            List <Player> players = new List <Player>()
            {
                new Player(0, 1000), new Player(1, 1000)
            };
            int           NumberOfCards = 5, TAELLER = 0;
            WinConditions w = new WinConditions();
            int           flush = 0, straight = 0, royalflush = 0, straightflush = 0, four = 0, fullhouse = 0, three = 0, twopair = 0, pair = 0;
            int           wins = 0, loss = 0, draw = 0, result = 0;
            Stopwatch     stopWatch = new Stopwatch();
            string        path      = System.Windows.Forms.Application.StartupPath + "Dataset_1.txt";
            List <string> PrintFile = new List <string>();

            stopWatch.Start();
            FastWinCalc fw       = new FastWinCalc();
            List <Card> allcards = new List <Card>();

            do
            {
                #region problems
                players[0].Cards.Clear();
                players[1].Cards.Clear();
                allcards.Clear();
                for (int i = 0; i < NumberOfCards; i++)
                {
                    allcards.Add(new Card(allcards));
                }
                players[0].Cards.Add(new Card(Suit.Diamonds, Rank.King));
                players[0].Cards.Add(new Card(Suit.Spades, Rank.Ace));
                players[0].Cards.Add(allcards[0]);
                players[0].Cards.Add(allcards[1]);
                players[0].Cards.Add(allcards[2]);
                players[0].Cards.Add(allcards[3]);
                players[0].Cards.Add(allcards[4]);
                players[1].Cards.Add(allcards[0]);
                players[1].Cards.Add(allcards[1]);
                players[1].Cards.Add(allcards[2]);
                players[1].Cards.Add(allcards[3]);
                players[1].Cards.Add(allcards[4]);
                players[1].Cards.Add(new Card(Suit.Hearts, Rank.King));
                players[1].Cards.Add(new Card(Suit.Hearts, Rank.Ace));


                players[0].Score = w.Evaluate(players[0].Cards);
                players[1].Score = w.Evaluate(players[1].Cards);
                w.GiveScoreHand(players[0]);
                w.GiveScoreHand(players[1]);
                if (w.WhoWins(players[0], players[1]) == null)
                {
                    draw++;
                }
                else if (w.WhoWins(players[0], players[1]).Id == 0)
                {
                    wins++;
                }
                else
                {
                    loss++;
                }
                //if (result == -1) {
                //    wins++;
                //}else if (result == 0) {
                //    draw++;
                //} else if (result == 1) {
                //    loss++;
                //}
                TAELLER++;
                #endregion
                #region new card test
                //players[0].Cards.Add(new Card(Suit.Hearts, (Rank)8));
                //players[0].Cards.Add(new Card(Suit.Clubs, (Rank)8));
                //players[0].Cards.Add(new Card(Suit.Diamonds, (Rank)8));
                //players[0].Cards.Add(new Card(Suit.Clubs, Rank.Ace));
                //players[0].Cards.Add(new Card(Suit.Hearts, Rank.Ace));
                //players[0].Cards.Add(new Card(Suit.Diamonds, Rank.Queen));
                //players[0].Cards.Add(new Card(Suit.Diamonds, Rank.King));

                //players[1].Cards.Add(new Card(Suit.Hearts, (Rank)8));
                //players[1].Cards.Add(new Card(Suit.Clubs, (Rank)8));
                //players[1].Cards.Add(new Card(Suit.Diamonds, (Rank)8));
                //players[1].Cards.Add(new Card(Suit.Diamonds, Rank.Ace));
                //players[1].Cards.Add(new Card(Suit.Hearts, Rank.Ace));
                //players[1].Cards.Add(new Card(Suit.Diamonds, Rank.King));
                //players[1].Cards.Add(new Card(Suit.Clubs, Rank.King));


                //players[0].Cards.Sort();
                //players[1].Cards.Sort();
                //TAELLER++;
                ////for (int j = 0; j < players[0].Cards.Count; j++) {
                ////    Console.WriteLine("Players Cards:" + players[0].Cards[j].Rank + " " + players[0].Cards[j].Suit);
                ////}
                //Console.WriteLine("");

                //players[0].Score = w.Evaluate(players[0].Cards);
                //players[1].Score = w.Evaluate(players[1].Cards);
                //Console.WriteLine("player score: " + players[0].Score);

                //w.GiveScoreHand(players[0]);
                //w.GiveScoreHand(players[1]);
                //if (w.WhoWins(players[0], players[1]) != null) {
                //    Console.WriteLine("winner is: " + w.WhoWins(players[0], players[1]).Id);
                //} else {
                //    Console.WriteLine("Draw");
                //}
                #endregion
            } while (TAELLER != 10000);

            Console.WriteLine("Wins: " + wins);
            Console.WriteLine("Loss: " + loss);
            Console.WriteLine("Draw: " + draw);

            //Console.WriteLine("Wins: " + wins/1000);
            //Console.WriteLine("Loss: " + loss/1000);
            //Console.WriteLine("Draw: " + draw/1000);

            //PrintFile.Add("Tid" + stopWatch.ElapsedMilliseconds.ToString());
            //PrintFile.Add("TÆLLER: " + TAELLER.ToString());
            //PrintFile.Add("royalflush: " + royalflush.ToString());
            //PrintFile.Add("straightflush: " + straightflush.ToString());
            //PrintFile.Add("four: " + four.ToString());
            //PrintFile.Add("fullhouse: " + fullhouse.ToString());
            //PrintFile.Add("flush: " + flush.ToString());
            //PrintFile.Add("straight: " + straight.ToString());
            //PrintFile.Add("three: " + three.ToString());
            //PrintFile.Add("twopair: " + twopair.ToString());
            //PrintFile.Add("pair: " + pair.ToString());

            //File.WriteAllLines(path, PrintFile);



            //Console.WriteLine("Time: " + stopWatch.ElapsedMilliseconds.ToString());
            //stopWatch.Stop();
            //Console.WriteLine("TÆLLER: " + TAELLER);
            //Console.WriteLine("royalflush: " + royalflush);
            //Console.WriteLine("straightflush: " + straightflush);
            //Console.WriteLine("four: " + four);
            //Console.WriteLine("fullhouse: " + fullhouse);
            //Console.WriteLine("flush: " + flush);
            //Console.WriteLine("straight: " + straight);
            //Console.WriteLine("three: " + three);
            //Console.WriteLine("twopair: " + twopair);
            //Console.WriteLine("pair: " + pair);

            //for (int j = 0; j <= players[0].ScoreHand.Count - 1; j++) {
            //    Console.WriteLine("Players Cards:" + players[0].ScoreHand[j].Rank + " " + players[0].ScoreHand[j].Suit);
            //}
            //Console.WriteLine("Done!");
            //for (int j = 0; j <= players[1].ScoreHand.Count - 1; j++) {
            //    Console.WriteLine("Players Cards:" + players[1].ScoreHand[j].Rank + " " + players[1].ScoreHand[j].Suit);
            //}
            Console.WriteLine("Done!");
            Console.ReadKey();
        }
Example #27
0
 public GameModes(WinConditions winCondition, EnvironmentMods environmentMods, string name)
 {
     this.winCondition    = winCondition;
     this.environmentMods = environmentMods;
     this.name            = name;
 }
Example #28
0
    public void constructGameBoard(int grid_size)
    {
        showBoard();

        if (m_board_constructed)
        {
            //board is already constructed from a previous game, no need to do it again
            return;
        }

        //Resize the gameboard image to fit all tiles
        float board_side_length = (m_tile_spacing * (grid_size)) + (2 * m_outer_board_buffer_width);

        m_board_rectform.sizeDelta = new Vector2(board_side_length, board_side_length);


        //Fill the board with tiles
        float half_anchor_width = m_tile_spacing * grid_size / 2;

        m_board_tiles = new List <TTT_Tile>();
        for (int n = 0; n < grid_size; n++)
        {
            for (int m = 0; m < grid_size; m++)
            {
                //this will construct the grid left to right, top to bottom (indices increase like a page of text)
                Vector2 tile_position = new Vector2(-half_anchor_width + ((n + 0.5f) * m_tile_spacing), half_anchor_width - ((m + 0.5f) * m_tile_spacing));

                //create tile, set position within grid
                GameObject    new_tile_go = Instantiate(m_tile_prefab, transform);
                RectTransform rectform    = new_tile_go.GetComponent <RectTransform>();
                rectform.anchoredPosition = tile_position;

                //add ref to active list for further access
                TTT_Tile new_tile = new_tile_go.GetComponent <TTT_Tile>();
                m_board_tiles.Add(new_tile);
                new_tile.assignGridIndices(n, m);
            }
        }

        //define the win conditions for this board
        //define win-examination array for reuse based on grid size
        m_possible_winning_tiles = new TTT_Tile[grid_size];
        if (grid_size == 3)
        {
            m_active_win_conditions = m_3x3_winconditions;
        }
        else if (grid_size == 4)
        {
            m_active_win_conditions = m_4x4_winconditions;
        }
        else
        {
            Debug.LogError("No win conditions found for grid size " + grid_size);
        }

        //mark that the board is constructed
        m_board_constructed = true;

#if UNITY_EDITOR
        verifyWinConditions(grid_size);
#endif
    }
Example #29
0
 public void Init(WinConditions conditions, int slotsCount = 5)
 {
     this.conditions = conditions;
     _slotsCount     = slotsCount;
     FillData();
 }