Klondike Solitaire

Show off your games, demos and other (playable) creations.
Ortzinator
Prole
Posts: 5
Joined: Wed Mar 16, 2011 5:27 am

Klondike Solitaire

Post by Ortzinator »

A little proud of this because although I've been programming for years, this is the first thing I've "finished".

Image

http://dl.dropbox.com/u/313489/solitaire.love

Known issues:
  • Nothing happens when you win
  • You have to restart to start a new game
  • Card graphics are ugly
  • Possible insufficient shuffling???
Last edited by Ortzinator on Fri Jul 22, 2011 3:58 pm, edited 1 time in total.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Klondike Solitaire

Post by ivan »

Pretty good. I played it a few times but couldn't beat it either.
Just a minor suggestion: gameplay would 'feel' better if you could actually drag the cards with the mouse.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Klondike Solitaire

Post by bartbes »

It seems as if I regain my previous card when I put one down, so say I draw a 7 of hearts, then an 8 of spades, if I put the 8 down, I see the 7 again, that's not how it's supposed to work, there should be 3 cards drawn!
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Klondike Solitaire

Post by ivan »

bartbes wrote:that's not how it's supposed to work, there should be 3 cards drawn!
This is 'Vegas' style solitaire where only 1 card is drawn at a time and they do not rotate once you've drawn all of them.
Maybe it's just me, but I find this style of solitaire much more exciting then when 3 cards are drawn.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Klondike Solitaire

Post by Robin »

I can see why no-one won yet. The diamonds 5 is missing.

And I think you know why. In your code, I can see you counting from 0 in your numeric indices for tables. However, Lua counts from 1. I think something went wrong there.

EDIT: just to be clear, in this case diamonds 5 was missing, but I think it is a different card each time, either because it is at location 0, when Lua starts with 1, or at location #table, and you only count to #table - 1.

EDIT 2: also, I see a few instances of "pairs" where you should use "ipairs".
Attachments
Look for it. It isn't there.
Look for it. It isn't there.
no-diamonds-5.png (99.01 KiB) Viewed 7804 times
Help us help you: attach a .love.
Ortzinator
Prole
Posts: 5
Joined: Wed Mar 16, 2011 5:27 am

Re: Klondike Solitaire

Post by Ortzinator »

Nice catch :awesome:

And thanks for taking the time to look at the code. I didn't know about ipairs. You were right about the problem, the shuffle function was nuking one of the cards.

New version is up, same link.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Klondike Solitaire

Post by tentus »

Yep, nothing happens when you win. A couple of things:
Could you track/show the number of moves?
And could you remove the ".lua" from line 2 of main.lua? It won't run in the next version of Love if its there.

Also, moving cards from the "finished" stack back into the play area can be a bit tricky. Occasionally you need to resort, so it's something you should probably code an exception for.
Kurosuke needs beta testers
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Klondike Solitaire

Post by Robin »

Happy to help. :)

It works much better, and now the game is winnable.

One small tip:

Code: Select all

quads = {}
quads["C"] = {}
quads["D"] = {}
quads["H"] = {}
quads["S"] = {}
is the same as:

Code: Select all

quads = {C = {}, D = {}, H = {}, S = {}}
Help us help you: attach a .love.
Ortzinator
Prole
Posts: 5
Joined: Wed Mar 16, 2011 5:27 am

Re: Klondike Solitaire

Post by Ortzinator »

tentus wrote:Could you track/show the number of moves?
What should I consider a move? I'm thinking of omitting moving to the foundations.
And could you remove the ".lua" from line 2 of main.lua? It won't run in the next version of Love if its there.
Done, thanks.
Also, moving cards from the "finished" stack back into the play area can be a bit tricky. Occasionally you need to resort, so it's something you should probably code an exception for.
Can you elaborate? It seems to work fine for me.
Robin wrote:Happy to help. :)

It works much better, and now the game is winnable.

One small tip:

Code: Select all

quads = {}
quads["C"] = {}
quads["D"] = {}
quads["H"] = {}
quads["S"] = {}
is the same as:

Code: Select all

quads = {C = {}, D = {}, H = {}, S = {}}
That's much cleaner, thanks.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Klondike Solitaire

Post by BlackBulletIV »

Robin wrote:One small tip:

Code: Select all

quads = {}
quads["C"] = {}
quads["D"] = {}
quads["H"] = {}
quads["S"] = {}
is the same as:

Code: Select all

quads = {C = {}, D = {}, H = {}, S = {}}
But if you really want to do it line by line, for string keys you can do this:

Code: Select all

quads = {}
quads.C = {}
quads.D = {}
quads.H = {}
quads.S = {}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest