A cool card shuffling routine 'without using condition statements'
Hi friends. This is a good card shuffling routine. Basically, what it does is it takes an aray containing the numbers form 1 to 52 and shuffles the array. This can be used for any purpose including shuffling cards.
AI
Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Zdrojový kód
Dim deck(1 To 52) As Integer 'the array which holds the cards 'the following are just a few counters Dim n As Integer Dim temp As Integer Dim i As Integer Dim temp1 As Integer 'this statement is used to return different random numbers each time we run the application Randomize Timer 'the following loop assigns the numbers 1 to 52 to the array in that order. For n = 1 To 52 deck(n) = n Next n 'time to do the shuffling For i = 0 To 9'this llop just repeats the shuffling process 10 times For temp = 1 To 52 n = Int((52 * Rnd) + 1) this generates a random number in the range 1 to 52 'the following block of code interchanges the values of deck(temp) & deck(n). This is a very simple method of shuffling the array. If you read it carefully you will be able to understabd the logic. temp1 = deck(temp) deck(temp) = deck(n) deck(n) = temp1 Next temp Next i
Původní komentáře (3)
Obnoveno z Wayback Machine