Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8279733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:25:23+00:00 2026-06-08T09:25:23+00:00

I’m making a bot that can test some card tactics on a game, the

  • 0

I’m making a bot that can test some card tactics on a game, the bot works but I have one problem. My card shake method is not very good.
I shake the cards this way:

        public void ShuffelDeck()
        {
            for (int i = 0; i < 5; i++)
                Cards = ShuffelCards(Cards);
        }

        private ArrayList ShuffelCards(ArrayList Cards)
        {
            ArrayList ShuffedCards = new ArrayList();

            Random SeedCreator = new Random();
            Random RandomNumberCreator = new Random(SeedCreator.Next());

            while (Cards.Count != 0)
            {
                int RandomNumber = RandomNumberCreator.Next(0, Cards.Count);
                ShuffedCards.Insert(ShuffedCards.Count, Cards[RandomNumber]);
                Cards.RemoveAt(RandomNumber);
            }

            return ShuffedCards; 
        }

The problem is when I calculate without a pause between the card shake process , a few players will win a lot of games. For example

Player 1: 8 games
Player 2: 2 games
Player 3: 0 games
Player 4: 0 games

But when I add a dialog before the card shake process the wins will get spread over the players:

Player 1: 3 games
Player 2: 2 games
Player 3: 1 game
Player 4: 4 games

I guess that the Random class is not good enough for a brute force like this. How can I shuffle the cards without a problem like this?

Update:
I already tried to use 1 Random class, and I also tried to shake the cards only once.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:25:24+00:00Added an answer on June 8, 2026 at 9:25 am

    When you create a new instance of the Random class it is seeded with the current time, but the current time it’s seeded with only has precision down to 16 ms, meaning if you create a new Random class within the same 16 millisecond interval (that’s a long time for a computer) as another instance you’ll get the same random number sequence.

    One good solution is to just ensure you aren’t creating so many new Randoms. Create one, once, and pass it into the shuffle cards method, or create a static random that is just accessible in a lot of places (just remember that it’s not thread safe).

    On a side note, for your actual shuffling algorithm it’s pretty good. You could make one improvement though. Rather than adding the chosen element to the end and removing it from the middle, you can just swap the element at the end with the one in the middle. This is more efficient since removing from the middle of a List isn’t an efficient operation. Additionally, rather than picking a random number between 0 and the size, pick a number between 0 and (size minus the number of the current iteration). See the wikipedia article on the subject for more details on the algorithm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a bot for a Flash game, and I've figured out how to
Making websites that appear correctly in IE is a big problem. Is there any
Making a flash page that can cycle through these three images on mouseclick. For
alright, so im making an irc bot, and im wondering a few ways that
Making a small WCF test program which is based on a Store that has
making a multi-language site with codeginiter. I have created two folders. One for french
I'm making an IRC bot which will log the hostname of a user that
Making my way through the GAE documents. I have a question I can't find
I'm making a PHP IRC Bot, and it works great. What I want to
I'm making a project using GAE, and have a terrible problem. I wanted to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.