Talk:Card shuffles: Difference between revisions

From Rosetta Code
Content added Content deleted
(Algorithm defs for the ones I did so we can maybe pick one?)
mNo edit summary
Line 5: Line 5:


::So the two I did in Java are the riffle and the overhand. I can explain them both on the page but if you think it'd be better to just require one and leave the rest for bonus then I'll explain them both here to make it easier to decide. The riffle is where you cut the deck in half and "flip" the two halves together in an alternating fashion (sort of like the merge in a merge sort). The "human imperfections" that I thought of with this are an imperfect initial cut and accidentally "flipping" more than one card from one half at a time. The overhand is where you hold the deck in one hand and cut part of the deck (I guessed around 20%) from the top of the deck and move it to your other hand (the top of the pile in that hand if there are already cards there). Repeat until the whole deck has been moved to the other hand. The "human imperfections" I thought of for that one are randomly varying cut sizes and occasionally choosing to add the next cut to the bottom of the deck in the "other hand". Does either one of those sound like a better main method to implement? --[[User:Mwn3d|Mwn3d]] ([[User talk:Mwn3d|talk]]) 16:40, 28 April 2015 (UTC)
::So the two I did in Java are the riffle and the overhand. I can explain them both on the page but if you think it'd be better to just require one and leave the rest for bonus then I'll explain them both here to make it easier to decide. The riffle is where you cut the deck in half and "flip" the two halves together in an alternating fashion (sort of like the merge in a merge sort). The "human imperfections" that I thought of with this are an imperfect initial cut and accidentally "flipping" more than one card from one half at a time. The overhand is where you hold the deck in one hand and cut part of the deck (I guessed around 20%) from the top of the deck and move it to your other hand (the top of the pile in that hand if there are already cards there). Repeat until the whole deck has been moved to the other hand. The "human imperfections" I thought of for that one are randomly varying cut sizes and occasionally choosing to add the next cut to the bottom of the deck in the "other hand". Does either one of those sound like a better main method to implement? --[[User:Mwn3d|Mwn3d]] ([[User talk:Mwn3d|talk]]) 16:40, 28 April 2015 (UTC)

::: For example, let's say the language provides built in "shuffle" or "riffle shuffle" primitives. What else would you want, besides the use of these hypothetical primitive operations? Or, if their unadorned use is acceptable, how would we determine whether or not the language spec satisfies this task?

::: Note that we already have some "Shuffle" tasks, and that "[[Knuth shuffle]]" is very different from "[[Perfect shuffle]]" and that neither of those two in any way matches "[[Best shuffle]]".

::: So one issue is: are you going for a "random process" (which has its own awkwardness) or are you going for a "deterministic process" (such as a card shark might want to employ)? A deterministic "one card from each side" riffle shuffle is going to be different from a "one or two cards randomly" from each side shuffle (and that's going to often have a lump at the end which is more than two cards). Another variant might involve lumps of one to four cards. Another variant might instead do a "0 or 1 card from each side, with 50% odds until one side runs out" type of approach.

::: Or, if you want overhand shuffle, how many times should the deck be cut? Also, do you want to support stacking the deck? Or do you want to leave that as a potential modification for later?

::: Anyways, it's not really my place to tell you what it is that you wanted to say in your definition of this task. All I can do is point out some of the possibilities which the current task suggests to me, and ask you what it was you really wanted to say.

::: It sounds like you've got a decent idea of what you're going for here, though maybe you should split this into two tasks - overhand and riffle shuffles are different algorithms? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 16:43, 28 April 2015 (UTC)

Revision as of 16:43, 28 April 2015

Task needs more definition so we can know whether an implementation is suitable or not. --Rdm (talk) 04:31, 28 April 2015 (UTC)

It's a draft so OK. What do you want to see? --Mwn3d (talk) 16:21, 28 April 2015 (UTC)
+1 to Rdm. It Could do with the algorithm being on the page. Remember we want to be able to compare language examples which can be better done if the algorithm is shown, and maybe restricted to just the one method? --Paddy3118 (talk) 16:24, 28 April 2015 (UTC)
So the two I did in Java are the riffle and the overhand. I can explain them both on the page but if you think it'd be better to just require one and leave the rest for bonus then I'll explain them both here to make it easier to decide. The riffle is where you cut the deck in half and "flip" the two halves together in an alternating fashion (sort of like the merge in a merge sort). The "human imperfections" that I thought of with this are an imperfect initial cut and accidentally "flipping" more than one card from one half at a time. The overhand is where you hold the deck in one hand and cut part of the deck (I guessed around 20%) from the top of the deck and move it to your other hand (the top of the pile in that hand if there are already cards there). Repeat until the whole deck has been moved to the other hand. The "human imperfections" I thought of for that one are randomly varying cut sizes and occasionally choosing to add the next cut to the bottom of the deck in the "other hand". Does either one of those sound like a better main method to implement? --Mwn3d (talk) 16:40, 28 April 2015 (UTC)
For example, let's say the language provides built in "shuffle" or "riffle shuffle" primitives. What else would you want, besides the use of these hypothetical primitive operations? Or, if their unadorned use is acceptable, how would we determine whether or not the language spec satisfies this task?
Note that we already have some "Shuffle" tasks, and that "Knuth shuffle" is very different from "Perfect shuffle" and that neither of those two in any way matches "Best shuffle".
So one issue is: are you going for a "random process" (which has its own awkwardness) or are you going for a "deterministic process" (such as a card shark might want to employ)? A deterministic "one card from each side" riffle shuffle is going to be different from a "one or two cards randomly" from each side shuffle (and that's going to often have a lump at the end which is more than two cards). Another variant might involve lumps of one to four cards. Another variant might instead do a "0 or 1 card from each side, with 50% odds until one side runs out" type of approach.
Or, if you want overhand shuffle, how many times should the deck be cut? Also, do you want to support stacking the deck? Or do you want to leave that as a potential modification for later?
Anyways, it's not really my place to tell you what it is that you wanted to say in your definition of this task. All I can do is point out some of the possibilities which the current task suggests to me, and ask you what it was you really wanted to say.
It sounds like you've got a decent idea of what you're going for here, though maybe you should split this into two tasks - overhand and riffle shuffles are different algorithms? --Rdm (talk) 16:43, 28 April 2015 (UTC)