Author Topic: Solitaire: Klondike and FreeCell  (Read 9178 times)

0 Members and 1 Guest are viewing this topic.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Solitaire: Klondike and FreeCell
« on: March 13, 2014, 04:38:08 am »
As some of you are aware, for the past month, I've been working on a combination Solitaire game, containing both the popular Klondike kind found on most versions of Windows, as well as FreeCell. Today, I present a working beta.

Title & options screen:


Playing game:


I've managed to win a game twice, including on hardware. However, there is still much work to do. There is no scoring code (though you can indeed switch between draw-1 and draw-3 modes), the FreeCell mode isn't implemented at all, there are no graphics for the high-ranking cards, the save feature isn't implemented, the undo feature isn't implemented, and there is no code to detect the win condition.

If you find any bugs, you may report, but only if you can reproduce them. Which is difficult, considering that the RNG is not only implemented, but well-designed to prevent the same game from being generated twice.

EDIT: You can find the latest version and good screen shots at ticalc.org .
« Last Edit: November 17, 2014, 01:54:36 pm by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Solitaire: Klondike and FreeCell
« Reply #1 on: March 13, 2014, 09:43:29 am »
Looking nice, good to see awesome CSE games out there :)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #2 on: March 13, 2014, 06:00:54 pm »
Looks very nice so far! :D

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #3 on: March 15, 2014, 12:09:57 pm »
Wow, i love FreeCell! It looks great and it's amazing all the detail that can fit on the screen. Great work DrDnar! I always wished there were a FreeCell game for the 83/+, i spent a lot of time playing solitaire on my 83 in school.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #4 on: March 19, 2014, 06:55:27 am »
This week's update finishes the Klondike Solitaire feature, by adding the following features:
 - ALPHA now implements move-to-home-cell
 - If you empty the waste, it shows the card beneath if one is there
 - Deck graphic changes to empty box if no more cards are in deck
 - Down key moves to bottom-most card in stack
 - Changed how the arrow keys move between stacks
 - All illegal moves should now also unselect the currently selected card (So ALPHA will unselect the currently selected card.)
 - HOPEFULLY fixed rare random freeze issue
 - Implemented timer
 - Implemented scoring
 - APD now three minutes
 - Every invocation of the build.bat file will now increment the build number, so every version has a unique ID.
You may find the app download here, and source code here.

I've added a routine call Panic that gets called in various places if the game fails a sanity check. If you see the panic screen, it doesn't necessarily mean the game has crashed. It just means that it's reporting a bug. Pressing ON will trigger a panic. If you see a panic unexpectedly, or need to use ON to terminate the app, please record the numbers it spews out and report them and what you were doing, including all options; the information will help me identify what happened.

This release was delayed a lot by a rare issue I encountered with the game very rarely freezing. I may have fixed the issue by ensuring the game never enters a key processing loop with interrupts disabled. However, I'm not certain interrupts were the issue in the first place. Nevertheless, I also restructured interrupts so the IVT can't be corrupted (by moving it into the app) and I added sanity checks for the PC and SP into the ISR.
« Last Edit: March 19, 2014, 06:57:12 am by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Online DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Solitaire: Klondike and FreeCell
« Reply #5 on: March 21, 2014, 09:48:44 pm »
DrDnar made games?? O.O

Anyway that looks pretty good so far and pretty old school too (for some reasons I am reminded a bit of Windows 3.1 :P)

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #6 on: March 27, 2014, 10:13:47 pm »
The game is nearing completion! I've added FreeCell, and I've added game saving. Now you can stop the game you're playing, and resume it at a later time. There are now two pending features: undo/redo, and adding some better graphics. I think I can do both in the remaining 2.3 K of space, and I can increase that to 2.8 K if needed by moving the IVT and ISR into RAM.

You may find the app download here, and source code here.

Here are some new screen shots:

Main menu 1:

Main menu 2:

Klondike Solitaire:

FreeCell:

Game saving in action:


Full readme:
Code: [Select]


                                   Solitaire
                                 March 27 2014



====== Introduction ============================================================

    Since Windows 3.0, Windows has included two electronic versions of two
Solitaire (or Patience in UK English) type card games.  Windows called them
Solitaire and FreeCell.  This app currently implements a clone of both programs.

    For the precise rules of Klondike and FreeCell, please consult the Internet.


====== Usage ===================================================================

MAIN MENU

    Solitaire has a main menu which lets you select which game to play, and the
options applicable for the chosen game.  The currently selected menu item is
displayed in inverted color; that is, white text on black background.  The arrow
keys will select different items.  Press ENTER or 2ND to select an item.

    To quit, you must press the quit button at the bottom of the screen.

    Unlike in the OS, Solitaire will not dim the screen after a period of no
activity.  However, after three minutes, Solitaire will terminate itself and
turn the calculator off.  If this happens while a game is in progress, Solitaire
will save your game if there is sufficient free RAM (about 400 bytes).   

SAVING

    Solitaire uses an appvar named Solitair to save your settings and
statistics.  This appvar is about 100 bytes in size at a minimum, and is always
in RAM.  If you archive the appvar, Solitaire will unarchive it, and will not
rearchive it.

    Additionally, while you are playing a game, Solitaire can save your game and
restore it when you rerun the app.  This function can be invoked explicitly by
pressing MODE.  This will expand the save appvar to about 400 bytes.  If you are
playing a game, and press no buttons for more than three minutes, Solitaire will
attempt to save your game, and then turn the calculator off.

    There are some conditions that can prevent Solitaire's save feature from
working:
  - An appvar named Solitair was created by another application.  Solitaire
    cannot use any other appvar name.
  - There is not enough free RAM.  If there is enough free RAM for the appvar to
    save statistics, then they will be updated when you quit; however attempting
    to use the save feature (either by pressing MODE or waiting three minutes)
    will cause the app to update its statistics, but not save your game.
  - There is not enough RAM to unarchive the appvar when it is archived.  This
    is exactly like above, but statistics won't be saved, either, and any saved
    game cannot be resumed.
  - The appvar was created by an older version of Solitaire, and the new version
    cannot understand it.
In any of these circumstances, attempting to invoke the game saving feature---
either through pressing MODE or waiting three minutes---WILL NOT SAVE YOUR IN-
PROGRESS GAME.

    If you repeatedly get error messages when starting Solitaire and you are
sure there are not, in fact, any problems, try deleting the appvar Solitair.

GENERAL GAME PLAY

    Once you have started a game, use the arrow keys to move the cursor around.
Use ENTER or 2ND to select a card, move the cursor to another card, and then use
ENTER or 2ND again to place the card.  Cards that are hidden may be revealed
with ENTER or 2ND.

    If you do not a press any keys for three minutes, Solitaire will attempt to
save the in-progress game and then turn off the calculator, returning you to the
home screen; see above for more information.

BUG CHEKCS

    Solitaire contains sanity checks in certain areas, in which the game
verifies that its internal data is in a valid state.  If a sanity check fails,
it means that the app has a bug.  Therefore, the game will display an error
message saying BUG CHECK, followed by some numbers.  A BUG CHECK can also be
triggered by press ON at any time, which may be useful if the game appears to
have locked up.  If you see a BUG CHECK and you did not cause it purposefully,
please record the numbers, and send them to me, with a thorough description of
what you were doing when the BUG CHECK was triggered.  If at all possible, also
send an exact list of steps that cause the issue; you may also need to include
the appvar Solitair.


------ Klondike ----------------------------------------------------------------

    Klondike is the name for the specific version of Solitaire Windows is known
for.

    Unlike in Windows Solitaire, the four foundations that you must move cards
into is not on the top right.  Instead, they are on the left side of the screen;
this is purely due to the low resolution of the TI-84 Plus C SE screen.

    Y= will draw more cards from the deck.  Alternatively, you may simply click
on the deck.  Click on a hidden card to flip it.

    There are two main scoring modes: normal and Vegas.  In normal mode, the
score is always positive. 500 points is average for an un-timed game, 700-plus
is excellent.

    Vegas scoring has two sub-modes: non-cumulative and cumulative.  In Vegas
scoring, you only get one pass through the deck.  When you start the game, you
start 52 currency units (e.g. US dollars) in debt, and earn back 5 units for
every card moved to a home cell (or foundation).  With only pass through the
deck, your chances of winning are very small.  In fact, even earning back more
than 52 units is very hard.  In cumulative mode, you get to retain any debt (or
credit, however unlikely that may be) from previous hands.  Switching back to
normal scoring will erase your debt.  (Caution: May not work in real casions.)

    Basically, in Vegas mode, you're almost certain to lose.  That's why it's
called Vegas mode.

    If you enable the timer, in normal scoring mode, you lose two points every
ten seconds.  In Vegas mode, the timer serves no purpose.


------ FreeCell ----------------------------------------------------------------

    FreeCell is a game similar to Klondike Solitaire.  However, an important
difference is that all cards are visible when you start the game.  Also, you get
four free cells that can be used as a temporary holding area for exactly one
card.  Therefore, unlike Klondike, FreeCell is purely a logic/strategy game.

    Unlike in Windows FreeCell, the four home cells and free cells are not on
the top of the screen.  Instead, they are on the left side of the screen; this
is purely due to the low resolution of the TI-84 Plus C SE screen.

    This implementation of FreeCell provides the same 32000 unique games that
the original Windows FreeCell contained, the so-call Microsoft 32000.  Every
game except one is solvable with normal four free cells; the unsolvable game is
#11982, which can be solved with a fifth free cell.  Dozens of people have
claimed to have solved all 32000; if you attempt to solve all of them before
graduating, you are unlikely to graduate.  Numbers 1941 and 10692 are also
considered very hard, and 617 often trips up beginners, or so I'm told.

    You can find solutions to all 31999 games online in various places; be
forewarned, however, that this implementation does not currently support the
supermove.


====== About ===================================================================

------ Credits -----------------------------------------------------------------

    FloppusMaximus and BrandonW are responsible for nearly all of the OS
documentation that made this possible.  KermM provided the vital insight of the
identity of the specific LCD driver the TI-84 Plus C SE uses, without which this
game could not operate at a reasonable speed.

    Xeda helpfully provided some optimizations for some routines.

------ Change Log --------------------------------------------------------------

Build 461 (27 March 2014)
 - Added Random! button to GUI
 - Fixed glitch in Klondike where disabling the timer would also make the Draw
   text disappear
 - Added some basic statistics
 - Optimized some code
 - Added win detection logic
 - Added dialogs
 - Added FreeCell game mode
 - Fixed a bug in Klondike where moving a card onto a foundation would leave the
   card below the new top card still selected, so you could move the card onto
   another pile
 - Fixed points being deducted at the wrong time when turning over the waste
 - Fixed points being deducted after waste is empty
 - Added settings, stats, and game saving.  Now APDs correctly save your gave (if
   possible)!
 - Made FreeCell number entry and free cell count entry a little better
 - Changed a bunch of code relating to the card cursor positioning that I had been
   putting off until I implemented FreeCell

Build 259 (19 March 2014)
 - ALPHA now implements move-to-home-cell
 - If you empty the waste, it shows the card beneath if one is there
 - Deck graphic changes to empty box if no more cards are in deck
 - Down key moves to bottom-most card in stack
 - Changed how the arrow keys move between stacks
 - All illegal moves should now also unselect the currently selected card
    - So ALPHA will unselect the currently selected card
 - HOPEFULLY fixed rare random freeze issue
 - Implemented timer
 - Implemented scoring
 - APD now three minutes
 - Every invocation of the build.bat file will now increment the build number,
   so every version has a unique ID.

Initial release (12 March 2014)
 - Basic functionality

DrDnar made games?? O.O

Anyway that looks pretty good so far and pretty old school too (for some reasons I am reminded a bit of Windows 3.1 :P)
What did you call Robot Finds Kitten? The old-school look is intentional.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #7 on: April 01, 2014, 07:37:08 pm »
I've uploaded a non-April-Fool's update. Yes, despite the date, this release contains no jokes (aside from the Vegas line that's been in the readme this whole time). This release adds the useful supermove feature to FreeCell, fixes some bugs, and adds minor enhancements. This also breaks compatibility with the old save appvar format, so you'll have to delete your save appvar.

You may find the app download here, and source code here.

 - Fixed bug where selecting AGAIN after winning a game would prevent game saving from working in the new game.
 - Minor changes to the modal dialog routine
 - Fixed a bug where, after resuming game, the timer would not restart correctly.
 - Added some comments in various places in the code
 - Changed variables, so save compatibility is lost
 - GUI cursor now blinks
 - Fixed the YOU WIN dialog having a different score than the score under the KLONDIKE text.  (The YOU WIN score was always the correct one.)
 - Fixed a bug in FreeCell that would allow selection of an empty stack!  This would generally cause a panic on any attempt to move the un-card.
 - Made the free RAM required for game saving substantially smaller.
 - Fixed a bug in clean-up termination code that could cause a crash in CLASSIC
 - Implemented FreeCell supermove
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #8 on: April 02, 2014, 01:01:47 pm »
Bug!


No BUG CHECK is triggered by this, but it's game-breaking. I didn't get the update yet, but since it doesn't look like it's in the changelog, I'm reporting it anyways.


Instructions: Start a FreeCell game and make a ladder extending past the bottom of the screen. The calc freezes at a green (or green with yellow lines) screen.


Please fix. :/
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #9 on: April 02, 2014, 06:04:35 pm »
Bug!


No BUG CHECK is triggered by this, but it's game-breaking. I didn't get the update yet, but since it doesn't look like it's in the changelog, I'm reporting it anyways.


Instructions: Start a FreeCell game and make a ladder extending past the bottom of the screen. The calc freezes at a green (or green with yellow lines) screen.
That has been fixed. I posted a release in which the code for dealing with that situation hadn't been implemented, so a bunch of routines just produce garbage. When the LCD gets garbage, it likes to freeze, as though it's Windows ME. I believe it's not a true freeze. You need to press ON, press CLEAR a couple times, then press 2nd+ON to turn the calculator off. It should turn off, and the screen should reinitialize when you turn it on.

Incidentally, if you really enjoy FreeCell that much, don't use the supermove feature in the most recent release. If you move to a pile with more than ten or so cards, it will cause corruption. (You can often, but not always, fix the corruption by pressing MODE to save and quit, and then restarting.)
« Last Edit: April 02, 2014, 11:00:36 pm by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Online DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Solitaire: Klondike and FreeCell
« Reply #10 on: April 02, 2014, 07:18:33 pm »
I'm downloading this now so hopefully I can give it a try later. :)

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #11 on: April 04, 2014, 08:37:50 pm »
Today's update adds undo support, and also fixes several bugs related to FreeCell's supermove feature:
  • Fixed an issue with Panic not reporting correct register values, making it less useful
  • Fixed a bug in FreeCell's supermove where it would LDIR the wrong number of cards.  Normally, it would copy too many, but the stack size counter would be updated correctly, so the extra cards were invisible.
  • Fixed a bug in FreeCell's supermove when you moved a stack to an empty cell
  • Fixed a bug where FreeCell's supermove counted foundations as free cells, instead of counting the free cells as free cells.  (What? The names were similar.)
  • Implemented undo feature for both Klondike and FreeCell.
Since I can't make my server work, I'm attaching this week's update.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Online DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Solitaire: Klondike and FreeCell
« Reply #12 on: April 05, 2014, 02:59:36 am »
Ok, I'm gonna grab this version then load it on my calc :)

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Solitaire: Klondike and FreeCell
« Reply #13 on: April 11, 2014, 12:25:48 am »
This minor update fixes some small bugs, and adds a helpful feature for the ALPHA key: it will scan the tableau and move any cards that can be moved to a home cell (foundation). (Windows also does this.)
 
 I want to add a little more graphics to the game. Namely, the face cards lack special graphics. There's enough room remaining in the app for eight 4-color 24w by 25h graphics, or sixteen 2-color graphics. I'm not having much success coming up with graphics of my own; is anybody able to lend some pixel art skills?
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Online DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Solitaire: Klondike and FreeCell
« Reply #14 on: April 11, 2014, 12:48:38 am »
Face card graphics would definitively be nice, providing you can manage to fit some decent ones into the small cards. You might have to ask in the pixel art sub-forum, though, so your art request gets more attention. Good luck!