News for hackers. Stuff that matters.
Re:Deck.of.cards by pkstn on Wednesday April 12, 2023 @12:10AM (#35534911)
Wow, thanks for sharing my Deck.of.Cards project! Just to let you guys know, this one is the old version. Newer version is in the root https://deck.of.cards

Old one has nicer animation treats, but the new one has multiplayer as well :)

Re:Deck.of.cards by perth on Wednesday April 12, 2023 @01:11AM (#35535269)
Old one has better mobile support too
Re:Deck.of.cards by zamnos on Wednesday April 12, 2023 @04:26AM (#35536560)
I couldn't get multiplayer to work for me and I'm not sure why not. Chrome + Incognito Chrome.
Re:Deck.of.cards by pkstn on Wednesday April 12, 2023 @05:12AM (#35536869)
Might be overloaded because of HN, i'll check and add capacity..
Re:Deck.of.cards by graderjs on Wednesday April 12, 2023 @07:37AM (#35538040)
* * *
Re:Deck.of.cards by pkstn on Wednesday April 12, 2023 @10:26AM (#35540258)
It's fisher-yates with multiple iterations, so should be pretty random
Re:Deck.of.cards by graderjs on Wednesday April 12, 2023 @10:53AM (#35540736)
Oh, I don't care how random it is. My interest is when is it random. Do you only shuffle the deck when "shuffle" is performed, and then the shuffled order is preserved until: cards are (re-)moved; deck is shuffled again; etc? (I.e "real world" model).

Or do you shuffle the remaining hidden deck multiple times (so, not when shuffle is explicitly performed, but on other occasions, for example; at intervals; or, after someone pics the top card; etc)?

Re:Deck.of.cards by pkstn on Wednesday April 12, 2023 @12:08PM (#35542010)
Oh, only when pressing shuffle. In the new version in multiplayer mode the order is kept on server-side so that players can't cheat..
Re:Deck.of.cards by globuous on Wednesday April 12, 2023 @11:04AM (#35540960)
It looks like the randomness is generated at shuffle time and then maintained. You can check by hitting « fan » and then « flip » multiple times. It always returns the same card order between shuffles which seems to imply that it’s maintained.
Re:Deck.of.cards by phailhaus on Wednesday April 12, 2023 @11:21AM (#35541285)
Very cool! How did you implement multiplayer?
Re:Deck.of.cards by pkstn on Wednesday April 12, 2023 @12:09PM (#35542030)
It's using socket.io, pretty simple stuff..

Here's the car.js.org server-side for example, as simple example: https://github.com/pakastin/car-ws/blob/master/server/index....

Re:Deck.of.cards by BaRRaKID on Wednesday April 12, 2023 @12:52PM (#35542734)
Bit of a nitpicking but the "sort" order is wrong. New decks come ordered Ace of Spades - King of Spades, Ace of Diamonds - King of Diamonds, King of Clubs - Ace of Clubs, King of Hearts - Ace of Hearts. The deck should start and end with Aces, and have two kings next to each other in the middle.
Re:Deck.of.cards by pkstn on Wednesday April 12, 2023 @02:04PM (#35544058)
That is true, i could actually finally fix that..
Re:Deck.of.cards by ogab on Thursday April 13, 2023 @09:17AM (#35554967)
Any idea why this is the order?
Re:Deck.of.cards by BaRRaKID on Thursday April 13, 2023 @10:44AM (#35556255)
No idea, but it seems like it's intentionally made so that no matter the orientation of the deck (face up or face down), the first card you see (not counting jokers and ad cards) will always de an ace. The two suits of those aces are just the two most liked suits (ace and hearths).

The curious part is that this order doesn't mean anything for card players, in fact it would probably be better for most games if the decks where printed in random order, but for magicians this order is really important for many effects. For example, if you perfectly shuffle the deck 8 times it will go back to it's original order.

Re:Deck.of.cards by Awelton on Sunday April 16, 2023 @08:47PM (#35595569)
I found out that if you add about 60 decks and then hit shuffle it breaks physics, space, and time. I am using it to play solitaire now and it works well.