private static byte[] CreateShuffledByteArray() { var values = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray(); FisherYates.Shuffle(values); return(values); }
static void FisherYateShuffle() { var dat = new int[5] { 99, 98, 92, 97, 95 }; var result = new FisherYates().Shuffle(dat); foreach (var item in result) { Console.Write(item + "\n"); } }
public bool ShaffleDeck(string nameDeck, ShuffleAlgo algo) { var currentDeck = GetDeckByName(nameDeck); var currentIndex = decks.IndexOf(currentDeck); List <TCard> shiffled = null; if (algo == ShuffleAlgo.Simple) { shiffled = FisherYates <TCard> .Shuffle(currentDeck.cards); } decks[currentIndex].ChangeCards(shiffled); return(true); }
public static long TimeOfSortingAlgorithm <T>(IList <T> collection, Action <IList <T> > sorting, int executionCounter) where T : IComparable <T> { var watch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < executionCounter; i++) { watch.Stop(); FisherYates.Shuffle(collection); watch.Start(); sorting(collection); } watch.Stop(); return(watch.ElapsedMilliseconds); }
public void lb_SelectedIndexChanged(object sender, System.EventArgs e) { if (lb.SelectedKey == null) { return; } SortingAlgorithm algorithm = AlgorithmDictionary[lb.SelectedKey.ToString()]; instance = algorithm; //CachingList list = new CachingList(1000); CachingList list = new NoGetCachingList(1000); FisherYates.Shuffle <Int32>(list); int shuffleCount = list.Cache.Count; Console.WriteLine(string.Join <int>(",", list)); instance.Sort <Int32>(list); Console.WriteLine(string.Join <int>(",", list)); DisparityCachedList disparities = new DisparityCachedList(list); DisparityDots dots = new DisparityDots(disparities, shuffleCount, 10, 10 * algorithm.SpeedMultiplier); drawable = new Drawable(); drawable.Paint += dots.OnPaint; UITimer timer = new UITimer(); timer.Interval = 0.0005; //Drawable.RegisterEvent(dots.OnPaint,) timer.Elapsed += (ts, te) => { drawable.Update(new Rectangle(0, 0, drawable.Width, drawable.Height)); }; timer.Start(); splitter.Panel1 = lb; splitter.Panel2 = drawable; }
public ActionResult ConfirmChoice() { var val = Request.Form["Choices"].ToString(); if (val == "1") { foreach (DeckModel deck in _decks) { HidePulledCard(); FisherYates.Shuffle(deck.Cards); } } if (val == "2") { var dm = new DeckModel(); foreach (DeckModel deck in _decks) { HidePulledCard(); deck.Cards = dm.Cards; } } if (val == "3") { foreach (DeckModel deck in _decks) { TempData["Card"] = deck.card; deck.ShowFirstCard = true; deck.RemoveCard(); } } if (val == "4") { HidePulledCard(); var newDeck = new DeckModel(); _decks.Add(newDeck); } return(RedirectToAction("Index", "Home")); }
public static void Shuffle <T>(IList <T> deck) { FisherYates.Shuffle <T>(deck); }
private void shuffleCards() //either default or custom mode, it shuffles the the main list of pictures that will be used for displaying the images in the pictureboxes { FisherYates.Shuffle <picture>(listOfPictures_Doubled); }
public void Shuffle() { FisherYates.Shuffle(cards); }