News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Solitaire in assembly

Started by Magicle, February 05, 2010, 03:35:46 PM

Previous topic - Next topic

Magicle

So just a few questions here....

what will be the easiest language to build this solitaire game?
I know pascal, could i combine pascal and ASM?
if so, any tips how to do it? or any tutorials or well explained pages?
What approaches should i take before starting this application

if you have any insight or additional material on this, please post
because i cant seem to find anything on google  :(

Thanks in advance !!! <:

BlackVortex

Is it gonna be a 32-bit windows application ?


oex

Solitaire is not massively graphically wanting, you could probably write it in javascript/html, flash, java or vb quite easily, vb if it's a 32 bit application....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Magicle

So assembly is mainly for graphical requiring programs?

I don't know visual basic nor java...
Will pascal do? Maybe without the graphicas aspect, just text output...

And on another note, code-wise if someone could point out strategies to confront the coding of solitaire..
It probably is really easy to most of you but i'm having trouble thinking how to build my functions\procedures..
the shuffling, that it will be 4 stacks of 1 (ace) to 13 (king) and pick randoms ,
the stacks of cards, maybe arrays containing the randoms assigned in the shuffles?

Well as you can see im pretty damn lost , if anyone maybe has a solitaire code i'd love to take a look at that, figure out how you did it.

btw, im sorry if this isnt the right forum to ask this..

thanks

oex

It is best to start with a text version in Pascal/PHP/Perl etc, a higher level language and use ASM for things that need lots of processing time like graphics. C would probably also be easier to do solitaire in.... ASM might be a bit fiddly for an early card game app.... Having said that you could do a basic console mode version reasonably easily....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Magicle

that was so vague from my point of view lol <:

any ideas on how to 'shuffle' 52 cards, with just values between 1 to 13? (and only 4 of each of course)
and card stack, is it best to address them with arrays?

redskull

Most of the graphics can be done by the functions in cards.dll, which comes with Windows.  It contains all the card pictures, and ways to draw them and animate them.  As far as data structures go, a straightforward way would be to create a 52 'card' data structures, containing suit/value information, and 9 linked lists (one for each pile, 1 for the face-down deck, and 1 for the 'turnover' pile).  Then, repositioning cards is as simple as changing the list the card is attached to; e.g. "dealing three" involves changing the fourth card on the deck list to be the head node, and switching the first card to be the end node of the pile list.

Obviously there are many different ways to do it.  A good place to start is getting it working in text mode, just printing out the information, and then "windowize" it

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

dedndave

my brother once wrote some code that emulated a real shuffle - lol
you know, sometimes 1, 2, 3, or 4 cards fall from the left, then from the right, etc...

Magicle

I hate pascal lol, i'm starting to feel its really limited (after looking at C)

BlackVortex

Isn't Pascal a dead language ?

Magicle

Ahh, let me clarify.
I honestly don't know if it is being used nowadays for actual programming, but I am a freshmen in Computer Engineering
in the university, just started this year and we are programming in pascal.
I started learning assembly just on my own a week ago or so (lol), and well, honestly, I will probably begin to learn C pretty soon as well.

TmX

Quote from: BlackVortex on February 05, 2010, 06:06:05 PM
Isn't Pascal a dead language ?

Nope. Not yet.
FPC (Free Pascal Compiler) is still being actively developed.
And AFAIK it's user base is pretty big.

raymond

Here's my procedure for shuffling a deck of cards.

a) At the start of the program, pick a "random" seed and OR it with 1 to make sure it's odd. One good source for that seed may be the lower dword returned by QueryPerformanceCounter. (This may not be necessary if the random number generator you intend to use does not need a seed.)

For shuffling later on,
- get a random number N between 1 and 52 (or 0-51 if you prefer 0-based), remove the Nth card from those remaining and transfer it to the end of the deck.
- get a random number N between 1 and 51, remove that Nth card from those remaining and transfer it to the end of the deck.
- get a random number N between 1 and 50, remove that Nth card from those remaining and transfer it to the end of the deck.
- etc continue until only one card remains.

Repeat the above half a dozen times or so, and you get a well shuffled deck of cards (even from a "new" deck where all the card are in order). Keep a copy of that shuffled deck and use it the next time you need to shuffle.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

hutch--

I wonder why you guys do these things the hard way, to shuffle a deck of 52 cards, stuff them into an array and start from the beginning swapping each card with a randomly selected other card in the 52 card array. There is an example in the masm32 example code "exampl10" called "shuflarr" that does it with string arrays, what you are after is really simple to do.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php