kemcbride / my_very_good_klondike Goto Github PK
View Code? Open in Web Editor NEWJust some c++ practice trying to make a card game. Klondike Solitaire!
Just some c++ practice trying to make a card game. Klondike Solitaire!
f1 f2 f3 f4 s( 2♥) ( 4♠) ( 4♦) ( 3♣) <9♣>
p1 [9♥,8♣,7♥,6♠,5♦,4♣]p2 [10♠,9♦]p3 [X][7♠,6♥,5♠]p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♣,6♦,5♣,4♥]p5 [K♠,Q♦,J♣,10♥]p6 [K♦]
p7 [X][X][X][7♦,6♣]cmd: m p1 1 f4 f1 f2 f3 f4 s( 2♥) ( 4♠) ( 4♦) ( 4♣) <9♣>
p1 [9♥,8♣,7♥,6♠,5♦]
p2 [10♠,9♦]
p3 [X][7♠,6♥,5♠]p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♣,6♦,5♣,4♥]p5 [K♠,Q♦,J♣,10♥]
p6 [K♦]
p7 [X][X][X][7♦,6♣]cmd: m p4 1 p3Invalid move: doesn't satisfy run constraints f1 f2 f3 f4 s
( 2♥) ( 4♠) ( 4♦) ( 4♣) <9♣>
p1 [9♥,8♣,7♥,6♠,5♦]p2 [10♠,9♦]
p3 [X][7♠,6♥,5♠]
p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♣,6♦,5♣,4♥]
p5 [K♠,Q♦,J♣,10♥]
p6 [K♦]
p7 [X][X][X][7♦,6♣]
cmd: m p4 1 p3
Invalid move: doesn't satisfy run constraints
f1 f2 f3 f4 s
( 2♥) ( 4♠) ( 4♦) ( 4♣) <9♣>
p1 [9♥,8♣,7♥,6♠,5♦]
p2 [10♠,9♦]
p3 [X][7♠,6♥,5♠]
p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♣,6♦,5♣,4♥]
p5 [K♠,Q♦,J♣,10♥]
p6 [K♦]
p7 [X][X][X][7♦,6♣]
cmd:
Why can't I move that 4 from the bottom of p4 to p3?
It definitely should be allowed.
Might really be time to implement some unit tests hahaha.
I want the Board object to be the one-stop interface into like managing & playing the game.
So let's put shuffle, new game, etc, onto the board.
🤷
whta's up with that
f1 f2 f3 f4 s |moves: 31|
( 4♠) ( 3♦) ( A♣) ( - ) <8♠>
p1 [K♣,Q♥,J♣,10♥,9♣,8♦,7♣,6♦,5♠]
p2
p3 [10♦]
p4 [K♦,Q♠,J♥]
p5 [X][7♦,6♣,5♥,4♣]
p6 [X][X][X][X][7♥,6♠]
p7 [X][X][X][X][X][X][6♥,5♣,4♦,3♣,2♥]
cmd: m p4 3 p1
mcmd count: 3
move count: 3
3
[K♦,Q♠,J♥]
Invalid move: doesn't satisfy run constraints
f1 f2 f3 f4 s |moves: 31|
( 4♠) ( 3♦) ( A♣) ( - ) <8♠>
p1 [K♣,Q♥,J♣,10♥,9♣,8♦,7♣,6♦,5♠]p2
p3 [10♦]
p4 [K♦,Q♠,J♥]
p5 [X][7♦,6♣,5♥,4♣]p6 [X][X][X][X][7♥,6♠]
p7 [X][X][X][X][X][X][6♥,5♣,4♦,3♣,2♥]
cmd:
Why would I add this? Who knows.
But I already added autoreveal as a flag and default to true, which is.. what I already implemented. How would manual reveal look? Why not do it?
ie. startup flags like
How should it look?
I'm imagining that the startup flags end up passed to the Board object, and then we have these enable/disable methods on the board, and instead of creating a new board, we give board a "new_game" or "reset" method - so that way basically it maintains the settings that a person has changed throughout their play session. (rather than, eg, current behavior would be to create an entirely new board, and we would reuse the state from the cli flags at startup)
Also I'm imagining in-game for it to kinda look like a settings menu, so like a sub-repl to the main game one. 😮
I think this is casue it reads just one character for count. Lol.
Maybe use something a bit more clever.
When you pull a card off the stock, instead of showing the "next" card in the stock, you should show the "previous" card.
related to the old issue of "why is it getting slower" #8
What if I had a mode that timed how long it takes between prompt availability?
Or even more detailedly, how long various functions take?
I suspect the time is lost in like hint calculation but I don't really know...
Sometimes during a game you can tell that something is messed up in the like, generation of possible moves. Because the prompt, board, etc. take much longer to pop up. Aka
From like idk 1ms to 500ms.
That's messed up!
I think it has something to do with either empty piles, piles with only Kings on them, or having all piles populated. Something like that.
examples of useless moves:
Catch has weird issues with clang :(
With seed... (default):
f1 f2 f3 f4 s
( 3♠) ( 2♥) ( 2♣) ( - ) <7♦>
p1 [K♥,Q♣,J♥]
p2 [K♦,Q♠]
p3
p4 [5♠]
p5 [X][X][X][X][9♦,8♠]
p6 [X][X][X][X][2♦]
p7 [X][X][K♣,Q♦,J♠,10♥,9♣,8♦,7♣,6♦,5♣,4♦]
cmd: m p7 9 p3
Invalid move; try something else.
f1 f2 f3 f4 s
( 3♠) ( 2♥) ( 2♣) ( - ) <7♦>
p1 [K♥,Q♣,J♥]
p2 [K♦,Q♠]
p3
p4 [5♠]
p5 [X][X][X][X][9♦,8♠]
p6 [X][X][X][X][2♦]
p7 [X][X][K♣,Q♦,J♠,10♥,9♣,8♦,7♣,6♦,5♣,4♦]
cmd: m p7 1 p4
f1 f2 f3 f4 s
( 3♠) ( 2♥) ( 2♣) ( - ) <7♦>
p1 [K♥,Q♣,J♥]
p2 [K♦,Q♠]
p3
p4 [5♠,4♦]
p5 [X][X][X][X][9♦,8♠]
p6 [X][X][X][X][2♦]
p7 [X][X][K♣,Q♦,J♠,10♥,9♣,8♦,7♣,6♦,5♣]
cmd: m p7 9 pp4
Invalid dest: pp4
f1 f2 f3 f4 s
( 3♠) ( 2♥) ( 2♣) ( - ) <7♦>
p1 [K♥,Q♣,J♥]
p2 [K♦,Q♠]
p3
p4 [5♠,4♦]
p5 [X][X][X][X][9♦,8♠]
p6 [X][X][X][X][2♦]
p7 [X][X][K♣,Q♦,J♠,10♥,9♣,8♦,7♣,6♦,5♣]
cmd: m p7 9 p4
doesnt satisfy run constraints
f1 f2 f3 f4 s
( 3♠) ( 2♥) ( 2♣) ( - ) <7♦>
p1 [K♥,Q♣,J♥]
p2 [K♦,Q♠]
p3
p4 [5♠,4♦]
p5 [X][X][X][X][9♦,8♠]
p6 [X][X][X][X][2♦]
p7 [X][8♣]
During that last step...
It successfully did the take() from p7 - but then failed to do the put for p4
Whoops, I meant to put it on p3.
But in any case - it should tell you it fails, and actually make the move not happen at all.
I guess that it did the take, and then failed to do the put, but didn't return the original take() back onto its run.
***** Also ----- double check that during a move, it doesn't auto-reveal the top run -
if it revealed the run, then it wouldn't be able to return the stack back to its position, since that would become invalid!!!
I obviously don't like this generally but technically the wikipedia says it was there for standard microsoft windows solitaire.
And that's my golden standard.
https://en.wikipedia.org/wiki/Klondike_(solitaire)#Scoring
I'd, naturally, hide this behind a flag, and default it to "false" 😝
here, i accidentally put a queen on an empty pile instad of on the king next to it:
f1 f2 f3 f4 s
( 5♦) ( 3♠) ( 6♥) ( 4♣) <4♠>
p1 [K♠]
p2 [K♦,Q♣,J♦,10♠,9♥,8♠,7♦,6♣]
p3 [6♦]
p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♠]
p5 [Q♠]
p6 [X][X][X][10♣,9♦,8♣,7♥]
p7 [K♥]
cmd: m p3 1 p4
f1 f2 f3 f4 s
( 5♦) ( 3♠) ( 6♥) ( 4♣) <4♠>
p1 [K♠]
p2 [K♦,Q♣,J♦,10♠,9♥,8♠,7♦,6♣]
p3
p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♠,6♦]
p5 [Q♠]
p6 [X][X][X][10♣,9♦,8♣,7♥]
p7 [K♥]
cmd: m s f2
f1 f2 f3 f4 s
( 5♦) ( 4♠) ( 6♥) ( 4♣) <J♣>
p1 [K♠]
p2 [K♦,Q♣,J♦,10♠,9♥,8♠,7♦,6♣]
p3
p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♠,6♦]
p5 [Q♠]
p6 [X][X][X][10♣,9♦,8♣,7♥]
p7 [K♥]
cmd: m p5 1 p6
doesn't satisfy run constraints
Only Kings can be placed on an empty pile
f1 f2 f3 f4 s
( 5♦) ( 4♠) ( 6♥) ( 4♣) <J♣>
p1 [K♠]
p2 [K♦,Q♣,J♦,10♠,9♥,8♠,7♦,6♣]
p3
p4 [K♣,Q♥,J♠,10♦,9♠,8♦,7♠,6♦]
p5
p6 [X][X][X][10♣,9♦,8♣,7♥]
p7 [K♥]
I think setting flags actually doesn't do anything right now... so that'd be nice... to do...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.