Probability of getting a particular card in Poker - probability

Suppose, I am playing a poker match. I have a pair of 5 in hand and see that the there is no 5 in the first 3 drawn cards. What is the probability that there will be at least one 5 in the next two cards.
My solution:
{P(5 in the fourth card and a different card in the fifth) = 2/47*45/46}+ {P(different card in fourth and 5 in the fifth)=45/47*2/46}+ {P(5 in both cards)=2/47*1/46}= 0.084
Is it correct? Does it depend on the number of opponents playing?

Related

Can we use Expectiminimax for the card game with 2 teams?

I am going to implement Rang Card Game. it is played between 4 players with 2 on each team? The game will be played between 1 human and 3 ai agents. I want to ask is it possible to implement this game using Expectiminimax, if yes then are we going to put two players as max and the other two as min?

Best matchmaking algorithm for 5v5s within player pools of millions of players [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Suppose that I am trying to create some sort of match making algorithm for my game. The game is similar to League or DOTA, whereby 5 players are pitted against 5 players. Suppose further that the player pool is gigantic (millions of players searching for a game at a time), and the job of the match maker is to put as many players as possible into many instances of 5v5 games. At this point, we do not worry at all about MMR, ELO or any player/party rating coming into play. We just want to place players into 5v5s.
My current brute-force algorithm is absolutely atrocious in scaling. It first tries to find all possible combinations of 5 player parties within the millions of players, then, it tries to find pairs of parties, while removing players from possible party matches if the players have already been used:
So, suppose I have 10 players and I want to find all possible 5v5s, I first transform them into bits and do bit shifting to find all possible combinations.
Players: ABCDEFGHIJ
1111100000 => ABCDE
1111010000 => ABCDF
1111001000 => ABCDG
1111000100 => ABCDH
1111000010 => ABCDI
1111000001 => ABCDJ
1110110000 => ABCEF
and so on...
Then out of all possible parties, I use 2 for loops to start trying to find pairs of parties:
ABCDE vs FGHIJ
ABCDF vs EGHIJ
ABCDG VS EFHIJ
and so on...
This algorithm has run time of O((nCr)^2). Because it tries to find all possible party combinations, just matchmaking 50 players would require 4.4891439e+12 operations, which is insane.
What is a better algorithm that doesn't go through all possible parties and brute-force this problem?
From your example, I gather that you don't care about gathering players by rating classes, but that you do care about balancing the resulting teams. Here's an algorithm that should get you a workable solution. Start by grabbing the first 9 players in the queue; call this the pool.
Compute the average rating of the players, avg = mean(pool)
Compute the target score for a team of 5: team_target = 5*avg
Find the combination of 5 players whose ratings have a sum closest to team_target (solved in several other postings). Make that team1.
Compute total rating of the team: team1_rating = sum(team1)
Remove those five players from the pool. Put the remaining pool players onto team2.
Compute the rating of this remaining team of 4: team2_rating = sum(team2)
Subtract the ratings to get the rating of the needed 10th player: player_target = team1_rating - team2_rating
Grab the next 10 players in the queue; this is the new pool.
Find the pool player with the rating closest to player_target.
Put that player onto team2 and post the match **team1 vs team2*.
There are 9 players left in the pool; go back to step 1. Iterate as necessary.
ADVANTAGES
This is a simple, linear algorithm that can handle a stream of input requests. Since the team size is fixed, it's O(N) on the length of the queue. The only part that's at all time-consuming is finding the team closest to the average rating, checking 9C5 = 126 possibilities, a pretty cheap overhead per match.
The space overhead is trivial: the high-water mark is handling 19 players at once.
PROBLEMS
You can have an unbalanced match if the distribution isn't smooth. For instance, a queue with one star player, such as (100, 5, 5, 5, 5, 6, 6, 6, 6 | 5, 5, 5, 5, 5, 6, 6, 6, 6, 6) will give you team ratings of 120 and 30 for the "best" pairing. If this is a functional problem for you, feel free to adjust, perhaps keeping a pool of outliers to handle until you get 10 high and/or 10 low ones.

Algorithm to Make a Set of Random Outcomes Approach a Specific Percentage

Currently, I have a pool of basketball players where I have a projected total of points for each player. Additionally, I have a normal distribution function that gives me a random drawing from a normal distribution for each player. Currently, I have an algorithm that calculates n unique random lineups of 8 players based on some constraints. Between each lineup, the normal distribution function runs again to produce new predictions for each player. Then the best lineup is produced for that specific set of predictions.
I would like to tweak this algorithm in the following way. I would like to have 4 tiers of maximum and minimum percentages where each player is assigned a tier. Within the number of lineups generated, I would like each specific player to occur with that frequency. So for example if I wanted to generate 10 lineups and player 1 is in tier 1 which requires the player to be between 50-60%, then the player would occur in 5-6 lineups ideally.
I'm struggling with how to modify my current algorithm to include this stipulation. Any thoughts would be greatly appreciated! I just don't know how to force each player within a specific range of percentages.
There are a lot of ways to do it.
Here is an easy approach. Keep a current relative odds of being picked for each player. The actual probability is the relative odds divided by the sum of the odds. Each person starts with the expected number of times be selected. Whenever someone is selected, their relative odds is reduced by 1. If it goes below 0, that person is out of the pool.
This approach guarantees that each player will not be in more than a maximum number of teams. It makes it unlikely, but not impossible, that any given player will be in fewer teams than you want.
An easy way to solve that is to randomly round people's desired frequencies up and down to get the right integer count. And now everything has to come even.
There is yet another problem, though. Which is that it is possible that you'll not succeed in assignment to fill all the teams. But if you go from the most popular player to the least, the odds of such mistakes should be acceptably low. Doubly so if you widen the ranges slightly by populating a few extra teams, then throwing away ones that didn't work out.
First draft
So if I understand correctly, you have N players that might appear in the first
position of the string. But you want them to be selected not at random, but according
to some percentage.
Now the first step is to normalize those percentages:
Alice 20%
Bob 40%
Charlie 10%
Doug 60%
Eric 30%
The sum is 160%, so you generate a random number from 1 to 160; say it's 97.
97 is more than 20, so subtract 20 and ignore Alice.
77 is more than 40, so subtract 40 and ignore Bob.
37 is more than 10, so subtract 10 and ignore Charlie.
27 is less than 60: Doug it is.
You can also pre-populate a 160-element array with 20 "Alice" indexes, 60 "Doug" indexes etc., and your player is players[array[random(160)]].

Complex pairing algorithm - team tournament

I would like to ask for help with an algorithm I’ve been working on for quite some time. I actually programmed it a few years ago using greedy pairing mostly but I’m not satisfied. Any help would be greatly appreciated!
So getting down to business. I have an application for tournament play (beachvolleyball to be precise, but should work for any pair-sport played in tournament format). The players show up on tournament day and gets randomly-ish put together with other participants and against other random teams. Top focus is to play as much as possible, however the number of players aren’t always divisible by the number of simultaneous playing spots. Therefor there will always be a number of players resting, standing the round out that is, and I’m trying to make sure this is as fair as possible by using 2 variables:
Rests (total number of rests during the day)
Rests in a row (Resting several games in a row, obviously)
The original concept of the tournament was mixing the teams with 1 male(m) and 1 female(f) in each team, playing against another team of m/f. However, the resting part is more important and there is often a lot more players of one sex than the other (i.e. 20 f and 7 m). Instead of letting the males play every single round, the program should make teams of f/f playing against f/f. Same-sex vs f/m should be avoided though.
Players should get new partners every round and play against new teams every round. Preferably you should play with all players of the opposite sex before playing with someone again. Players are allowed to come and leave as they like, and also take a break at any time (voluntary rest).
I’ve looked into the unstable marriage problem and the roommate problem, but my problem seems to be a mix of the two. Normally there will be two lists of players (m/f) and pairing, but under certain premises there should be teams made from just one list as described. Let me give you an example:
EXAMPLE:
43 players show up for a tournament with 6 courts.
17 Females (f) and 26 Males (m).
The 6 courts fit 12 teams with a total of 24 players per round.
Round 1
*12 m - 12 f*
*19 resting (5f, 14m)*
Round 2
5f and 14m have 1 rest and should play.
The best solution would be:
*4 f - 4 m*
*1f - 1m*
*4m - 4m*
*1f - 1m* (these players played last round as well).
In this example there will normally not be more than 1 rests in a row, if there woud’ve been 49 players from the start on the other hand..
In future updates, I’m also planning on letting the user choose number of players per team, and also to skip the m/f requisite.
Any thoughts?

Calculate probability of event

Could you please help me with one task, please. I understand Probability theory more or less but cannot solve that one:
Given one deck of 52 playing cards, you draw two random cards. (The cards are drawn at the same time, so the selection is considered without replacement) Assuming a fair deck, what is P({both cards are aces})?
wrong group but...
P(first card is ace) = 4/52
P(second card is ace, when first one was ace) = 3/51
P(two aces) = P(first card is ace) * P(second card is ace, when first one was ace)

Resources