alexalewis / assignments

0 stars 0 forks source link

03 - Deck shuffler - Loops and Lists #4

Closed alexalewis closed 4 years ago

alexalewis commented 4 years ago

All Cards on Deck!

In this project, you will use C# to model a deck of playing cards. You'll also add functionality to it such as shuffling and dealing.

Shuffling Cards

Computers are notoriously bad at random numbers. This is a pretty deep and complex topic, but it's worth pointing out that most random numbers we use in computing are actually "pseudorandom". For this assignment, you will read about, then implement, a popular algorithm that shuffles the order of a finite set using C#'s built in Random.Next() function as a pseudorandom number generator.

Objectives

Requirements

You will model these in code, in any way you see fit. It may require you to experiment and try a number of techniques. There are many valid solutions.

To shuffle the cards, you should implement the Fisher–Yates shuffle algorithm:

For our purposes, n is 52:

for i from n - 1 down to 1 do:
  j = random integer (where 0 <= j <= i)
  swap items[i] with items[j]

hint: really understand the algorithm before you try to implement it.

Explorer Mode

Adventure Mode

Epic Mode

Resources

Slides

https://slides.com/markdewey-1/arrays-and-loops-csharp

alexalewis commented 4 years ago

https://github.com/alexalewis/DeckShuffler