38 ms·
I don't know what it is, but I love implementing Solitaire to learn new languages and frameworks. It's always a fun exercise, and the engine gets better with ev
by kyle_u 11y ago
I don't know what it is, but I love implementing Solitaire to learn new languages and frameworks. It's always a fun exercise, and the engine gets better with every iteration. My latest attempt is https://solitaire.gg https://solitaire.gg - it's a Scala/Scala.js WebGL/websocket Phaser web/native app with hundreds of games.
- dnissley 11y agoLooks great! Is this open source?
- kyle_u 11y agoI'll probably open source it in the future, there's a lot of code there, and not much money to be made in Solitaire. I did extract some of the best general parts of the app (the admin, authentication, etc) into a project template I call Boilerplay (https://github.com/KyleU/boilerplay https://github.com/KyleU/boilerplay). If anyone's interested, I could also publish my pipeline to turn the Scala.js webapp into native apps for OSX, Windows, Linux, iOS, and Android.
- matwood 11y agoGreat job! I love the feel while playing with the card movement.
- thomasthomas 11y agoa little off topic but is it possible to truly randomize the 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000 shuffle combinations? edit: also, when i play solitaire via an ipad app there is always a 'top score' by someone for the hand i was dealt. i dont understand how this is probabilistically possible
- teh 11y agoShuffling can be done in linear time, e.g. with https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle so yes.
- gamegoblin 11y agoI believe user thomasthomas was referring to this problem: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Pseudorandom_generators:_problems_involving_state_space.2C_seeding.2C_and_usage https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#P... That is, is there enough entropy in your typical PRNG to actually generate all of those shuffles with equal probability.
- sltkr 11y agoYou can easily seed your PRNG with a cryptographic entropy source which can certainly provide enough entropy. But in reality you don't care. You could seed the PRNG with the current system time in nanoseconds or something, and every game you'll ever play is different. Even if the PRNG has limited state, you'll never notice it as a human player.
- dietrichepp 11y agoI'd like to elaborate. The cryptographic PRNG has lots of entropy, and it probably happens to be enough entropy. You need ~226 bits, and most cryptographic PRNGs will be more than that—but not all! Information-theoretic entropy is actually a stronger requirement, and it's why we use /dev/urandom (which is secure and fast) instead of /dev/random (which is information-theoretic secure, but slow). So it might be possible that your secure PRNG still cannot generate all permutations.
- kyle_u 11y agoDarn it, you hugged it harder than my tiny Amazon box could handle. Resizing the box now.
- kyle_u 11y agoAll good now - thanks, AWS! And thanks to everyone for the feedback. Wasn't expecting to launch my game today, but I'm glad I did.
- voltagex_ 11y agoI'd be interested to know how you got back up and running so quickly.
- rogeryu 11y agoWith AWS it's easy. You stop the machine, resize it to a bigger one with more CPU and/or RAM, then fire it up. This can be done in minutes.
- kyle_u 11y agoYep, this. Went perfectly, and thanks to Akka Persistence, end users (hopefully) just saw a minute of lag before their game resumed.
- bootloop 11y agoClick left on any card, than click right. Use the hint button for your personal floating cards stack.
- proyb2 11y agoI have one concern with framerate, if there is no need to maintain 60fps 100% of the time, Phaser should have a way to lower or pause fps, sadly, there isn't a way to avoid battery drain.
- scrollaway 11y agoSo you know, on my Linux box there is a massive performance difference between Firefox (very sluggish) and Chromium (perfectly fluid). Looks super fun, hope you open source it soon!
- themartorana 11y agoWebGL is terribly different across browsers. I run a small game company and we write our games in Unity3D. Exporting them for the web is an exercise in self-flagellation. Starting with Chrome, browsers are killing plugin support of any kind before a viable alternative is ready - and WebGL is certainly not ready. We still support the Unity plugin on Firefox, but can't do a WebGL fallback yet because the tech just isn't there yet. (Yes, Unity's WebGL exporter is also in the mix, but browser rendering and support for the exported game is still wildly different across browsers.)
- lazerwalker 11y agoOut of curiosity, what are you using WebSockets for?
- kyle_u 11y agoHoly crap, I've been waiting for someone to ask me that (I need more coding friends). The entire game is client/server. The client is pure JavaScript, and communicates with the server using only a few messages (select card, move card, etc). Normally, it connects via WebSocket to my Play Framework/Scala app, and the server processes moves and sends the results and a list of potential moves back to the client. If you download any of the native apps (iOS, Android, Linux, Win, OS X), you can play offline. This is the magic of Scala.js. The same code that my server uses gets compiled down to JS, and the client calls it directly, forgoing the socket connection. You can also see offline mode in the browser by replacing the word 'play' with 'offline'.
- reubenmorais 11y agoHm. This might be why I was getting severe lag while playing. I'm on a relatively laggy connection (from Brazil), so every move had a noticeable delay. I'd suggest doing client-side prediction, even in the online mode. Yep, that was it. Just tried offline mode and it's super snappy.
- kyle_u 11y agoGreat feedback, sorry for your laggy connection. I'm working on a fix now, but glad offline mode is working for you!
- lazerwalker 11y agoThat sounds AWESOME from a technical perspective. Is there a reason that you're doing a client/server thing instead of just having "offline mode" be the default, though? For a solely single-player game, it seems to me like being able to host everything off of a static fileserver instead of a Scala server seems like a scalability win for you and a bandwidth win for users. I don't doubt your choice and your tech stack (you know way more about your project and its needs than I do!), but I'd be super-curious to hear more about the reasoning and process.
- spdustin 11y agoKyle, this is brilliantly done. Honestly, I didn't expect the level of polish and fluidity that I experienced when I tapped that link on my iPad. The slight "lean" when cards are dragged around, butter-smooth animations... Well done. I'd love to see some of your notes behind wiring up the pseudo-physics of the cards. Or was that provided by a library? EDIT: I need to read more carefully - looks like it's part of http://www.phaser.io http://www.phaser.io, and now I've just wrecked my productivity for the day! Great job on the solitaire game.
- kyle_u 11y agoThanks! Phaser.io has a great tweening/animation system I use for some things, but the momentum animation was just a few lines of custom code. You basically just set the angle to a smoothed (distance travelled in last 500ms).
- tempestn 11y agoWould it be possible/difficult to reverse the direction of the lean if the card is 'grabbed' on the bottom half?
- kyle_u 11y agoGood idea, and a simple change. Thanks!
- tempestn 11y agoNo problem! Of course the really awesome feature would be the ability to drag piles of cards and have it automatically determine whether there is enough space up top to do the swaps. (ie if you have 3 spaces open at the top-left, you can drag a 6543 onto a 7 in one step.) Similarly automatically putting cards up on the top right once they're exposed and there are no lower-value cards left. Obviously those would be rather more work though!
- acqq 11y agoSo which "phaser" have you used then and what have you used it for?
- haylem 11y agoThis is pretty awesome! Just one thought though... The starter screen is a bit complicated. (Talking only about the web version, haven't tried the phone apps) I was just thinking my parents would love this game as Klondike and FreeCell are pretty much bare requirements when they buy a new computer or when I set one up for them. And your game works great, looks good and has all these variants. Except... They wouldn't have a clue which one to pick! I don't know what would be the best way to show case the games for selecting them. A carousel showing an animation with each of them? Or a preview split screen that shows that animation when you hover on one? Or directly small animations for each button? No clue, but if you can find a way to make it easier (and to then pin your "favorite" games alongside the "popular" picks) you've got yourself a super winner.
- kyle_u 11y agoGreat advice, thanks for the feedback. I'll get on that tonight (right after the right-click bug that everyone hates).
- treebeard901 11y agoPlot twist: kyle_u is really Wes Cherry!
- __david__ 11y agoHey that's nice. I run http://greenfelt.net http://greenfelt.net in my spare time—it came about because my friend and I wanted to learn javascript after seeing how cool google maps was and so we implemented Sea Haven Towers, a solitaire game he had played on his Sun, back in the day. Solitaire is nice because it's easy but still challenging enough to not be completely straightforward. It's fun to work on occasionally and it's rewarding to see random people play your games. Our games don't work as well as your does on mobile, but I think they're still very nice on computers.
- phjesusthatguy3 11y agoThat's really nice! Plain ol' Russian Solitaire isn't linked from the front page, though (it's my wife's go-to solitaire game). I found it by looking in the help for Russian Cell and seeing it linked there.
- kyle_u 11y agoYeah, I've started work on 600 or so games, but haven't tested them all. Russian Solitaire is a glaring omission, and will be corrected right away.
- daurnimator 11y agoFound a bug: When double clicking on a stack a 3 of spades went "up", but the card graphic stayed (and can be moved around)
- kyle_u 11y agoFixed, thanks for the report!
- i336_ 11y agoI'm guessing this app looks cool; you might like to know that older systems remix it into glitch art like this: http://imgur.com/a/o3YVy http://imgur.com/a/o3YVy I thought I'd give it a whirl on the old ThinkPad T43 I'm using at the moment. I never really expect much from its tiny Mobility Radeon X300, but this was especially hilarious, and a most unexpected, refreshing change from the usual "oh, the disk LED is solid... again..." that I usually get. :P FWIW, the http://aframe.io/ http://aframe.io/ examples all work perfectly - I was actually slightly gobsmacked when I saw them, I can tell you with a fair amount of confidence that the simpler demos run on my system as fast as yours - so this GPU isn't a total lost cause with WebGL, and if it's moderately trivial to fix this, you'll net a small extra niche in your userbase (along with mobile users in 3rd-world countries using really entry-level smartphones and tablets). If the fault lies with Phaser.io, and you feel like poking their ticket thingy, I'm fine with you passing the screenshots along. I'm also fine with testing potential fixes, if there's any room to explore there. If your build environment can split out 32-bit Linux binaries without too much effort, I'd be happy to test that too.
- nacs 11y agoThat "glitch art" looks like a video-card driver problem to me. It's also possible that the solitaire site uses more texture space than your card/driver can handle causing issues. The Aframe examples you linked seem to be simple geometric shapes with no textures so you may just be getting lucky there. Also, Phaser, the library GP is using uses Pixi.js for the webGL drawing code if I remember correctly and Pixi is supposed to fall-back to plain canvas rendering if webGL isn't supported -- so disabling WebGL for the site may make the solitaire site work.
- i336_ 11y agoLooks like you're right, the author responded saying exactly the same thing :) I tried killing webGL, which technically worked - I see a card deck! - but it didn't practically work: said card deck interacted at about 0.75-0.9fps. XD
- kyle_u 11y agoLinux 32-bit Build: https://s3.amazonaws.com/solitaire.gg/linux/Solitaire.gg.x32.zip https://s3.amazonaws.com/solitaire.gg/linux/Solitaire.gg.x32... It looks like I exceeded your texture memory. I use pretty high resolutions (targeting 4K displays), and dynamically build the card textures at runtime based on your screen size. Let me know if the native app improves the situation.
- Narishma 11y agoThere's really no reason for it to hog a CPU core at all times, not to mention the battery drain. It's not a real-time game, you can refresh the screen or play the animations just when needed.
- eibrahim 11y agoBeautifully done. I can't believe a browser game is that smooth. Why are we even building native anymore!!!
- shultays 11y agoFor me, it is game of life. I enjoy implementing it in new languages/platforms.
- RyanMcGreal 11y agoStrange - I flat-out can't get the game to load on Firefox 43.0.1 or Chrome 47.0.2526.106, but it works just fine on IE11.
- kyle_u 11y agoHeh, I almost never test in IE, so I expect the reverse. Let me know what errors you're seeing via the game's feedback form.
- RyanMcGreal 11y agoI figured it out - the game wouldn't load because the computer I was testing the game on has very limited RAM.