Questions Regarding Poker Game Code

Hi all, I am making a texas holdem poker game. In the CompareHandValues() function, I would like to check for who won the game, or if there is a tie. I am using an external namespace called HoldemHand, which allows me to use “Hand”. We can compare different Hands to see which has the higher rank, or a tie.

        string board = "2d kh qh 3h qc";
        // Create a hand with AKs plus board
        Hand h1 = new Hand("ad kd", board);
        // Create a hand with 23 unsuited plus board
        Hand h2 = new Hand("2h 3d", board);

        // Find stronger hand and print results
        if (h1 > h2)
        {
            Console.WriteLine("{0} greater than \n\t{1}", h1.Description, h2.Description);
        }
        else
        {
            Console.WriteLine("{0} less than or equal \n\t{1}", h1.Description, h2.Description);
        }

What is the best way I can do to return if there is a tie between players or there is a winner?
I am planning to do that in the CompareHandValues() function. Is it optimal to use a dictionary, or what other ways can I carry out this operation?

Some examples: ( Players)
If P1 & P2 have same hand ranks: P1 & P2 split pot
If P3 & P4 have same but higher rank than PI & P2 which also have same rank: P3 & P4 split pot

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoldemHand;

public class GameManager : MonoBehaviour
{
    public DeckScript deckScript;
    private CardScript[] allCards = new CardScript[7];
    private CardScript[] boardCards = new CardScript[5];
    private List<Hand> equalHands = new List<Hand>();
    private string boardString = "";
    private List<Hand> handList = new List<Hand>();
    [SerializeField]
    private List<PlayerScript> playerScripts = new List<PlayerScript>();

    public void DealClicked()
    {
        ResetGame();
        for (int i = 0; i < playerScripts.Count - 1; i++)
            playerScripts[i].StartHand();// player gets cards
        deckScript.DealCommunityCards();
    }
    public void Check()
    {
       
        for (int i = 0; i < deckScript.communityCards.Length; i++)
        {
            boardCards[i] = deckScript.communityCards[i];
            boardString += boardCards[i].Formatting();
            if (!(i == allCards.Length)) boardString += " ";
        }

        //Hand h1 = new Hand(player1Script.GenerateFormatting(), boardString);
        //Hand h2 = new Hand(player2Script.GenerateFormatting(), boardString);

        StoreHandValues();
        CompareHandValues();
       
        /*       
                for(int i = 0; i < boardCards.Length; i++)
                {
                    boardString += boardCards[i].Formatting();
                    if (!(i == allCards.Length)) boardString += " ";
                }
        */

        //Debug.Log("h1: " + h1.HandTypeValue);
        //Debug.Log("h2: " + h2.HandTypeValue);
        //if (h1 > h2) Debug.Log("h1 > h2");
        //else Debug.Log("h2 > h1");
    }

    private void StoreHandValues()
    {
        for (int i = 0; i < playerScripts.Count; i++)
            handList.Add(new Hand(playerScripts[i].GenerateFormatting(), boardString));
    }

    private Hand CompareHandValues()
    {
        Hand largestHand = handList[0];

        Debug.Log(largestHand.HandTypeValue);
        Debug.Log(largestHand.ToString());
        return largestHand;
    }

    private void ResetGame()
    {
        deckScript.Shuffle();
        foreach (PlayerScript playerScript in playerScripts)
            playerScript.ResetHand();
        deckScript.ResetDeck();
    }
}

Isn’t this just an extension of the question you already asked here ?

I guess it is still the same script but it is a different question this time, which is why I asked in a different thread

Do you need code or are you looking for a suggestion on what to do when there is a tie?

I assume the cards have a value, as a deck of cards would basically equate to values up to 13 int. to check for a tie is a simple question of mathematics. If you are accounting for previous games; like I don’t know how to play poker exactly, but let’s say you’re defining the tie on the result of many previous games (idk if this happens) you’ll have to keep track of all of these scores, probably giving each player a list of results. But in theory, you’re creating values

So like say 4 aces (idk if it does) beats 3 queens and a king, the math won’t exactly work. So you’ll have to figure out if two aces = 26 or if two aces should = 13 + (13 x 2)

I think in some situations like four 2’s (8) would be greater than two 4’s and two 7’s

it’ll really take a lot of thinking about to figure out whether or not to multiply on the basis of the presence of duplicate card values of different suit

you’ve really gotta be a pro poker player to kno this stuff unfortunately this is all the theory I got for you.