Topic: Solitaire Solver
Directions: Create a game which intelligently plays Solitaire.

There will not simply be an array of cards to choose from, because that would make cheating very easy. There will be arrays of cards, showing only the ones that are facing up. (The ones facing down are invisible to the programmer.)

card_array[0][0] might contain the card on the top of pile 1. card_array[1][1] might contain the second card down from the top of pile 2.

So it's: int card_array[pile][card in pile going from top downward]

Piles 0-6 will be the normal solitaire piles. Piles 7-10 will be the ones on the top where you put them last. Pile 11 will be the discard pile, which would show the card just served off the deck. All piles are read from left to right. Cards 0-12 are diamonds, the next 13 are hearts, the next 13 are clubs, and the last 13 are spades. (So, red cards are 0-25, the black cards are 26-51). This is a global variable. (I would've made it local, but that's too much work for something like this.) If a card turns up -1, that means that card does not exist, and you've probably gone to the end of that pile. (If the first card in a pile is -1, that means that pile is empty.)

Some functions:
int new_card(void);
This function takes a card from the serving pile (I forget the technical name) and places it in the discard pile. You can assume that each time it's only one card this is happening to. The value returned will be either the value of the card returned (cards are valued 0 to 51) or -1 if it has reached the end of the pile. It will automatically reset if it's at the end of the pile.

int move_card(pile number card is in, pile number card is moved to, number of cards moved);
This returns a 1 if successful, and a 0 for failure. Reasons for failure include breaking the rules or incorrect pile numbers.

Any possible functions i missed?

Your (the contestant's) function will be called:
int make_best_choice(void);
Inside it you will move cards, draw new cards, and basicly interact with the game so that you win. You are encouraged to use all the resources at your disposal to win, but it's impossible to peek. You can count cards that have already gone by, if you want to factor it into your decision.

After deciding the right move the program should call the move function. Then everything is automatically updated and you go through the process again until you win or lose.

It's up to your program to decide whether or not to lose. A winning scenario is easy to spot, but a losing scenario requires that you concede defeat yourself. Return a 0 for a defeat, and a 1 for a win.
Criteria:
efficiency -- use computer resources efficiently
elegance -- make your code neat and understandable. The structure and planning put into your program is key
portability -- how many computers can your code compile across? (especially important, cause i got to link with the code)
Special Criteria:
Interface -- make your interface user-friendly and idiot-proof
Success rate/Intelligence -- Does this game win more often than normal?
Stability/Garbage Collection -- does your game clean up after itself? (ie: memory leaks?) when will it crash? how stable is it?

Time Limit: For this one i'll be generous and say that all entries need to be in by September 24.

Signed up Contestants: 8 slots left
vasanth
troll king

Signed up Judges: all slots filled
ygfperson
civix
xds4xl
klinerr1

Send all entries to geoschnee2@thetruth.com or ygfperson@cprogramming.com
You can also submit your entry at the web site, contests.cprogramming.com

Remember, above all, make sure your program works.

2. I'd be more than happy to judge, if you didnt have a problem with that, ygf.

3. Id also like to judge .

4. only C or C++ programs allowed ?

5. Im not going to answer you because the answer is obvious.

6. Sign me up.. I am in....

7. only C or C++ programs allowed ?
yep.

8. Originally posted by ygfperson
only C or C++ programs allowed ?

yep.
What, I can't enter my REXX version then? Goddammit, ygf, I've been coding that for ages too.

9. games must restrict the player(s) to a
?

10. Congradulations. You found my momentary lapse of reason.

What I mean is that all players must be restricted in their movement and playing so they can't break the rules of the game.

Originally posted by ygfperson
Write a card game program. The card game can be any reasonable game (not 52-pickup).
what is 52-pickup??????

12. >what is 52-pickup??????
You never played 52 card pickup ? wow! It's an school trick, you get someone to agree to play it, then just throw the deck of cards in the air, and watch the poor sod pick up all the cards. If they refuse, they get the raps, or they did in my days at school. I suppose you've never heard of the raps either?!

13. the web page has been updated with the same info as is on here. soon i'll add file-uploading support.

14. File-Uploading support has been integrated. Just surf to the contest web page, click on the right link, and don't forget to include your name.

15. Yes that is waht i have been trying to say all these days.. Make the contest more specialized and not general so no onee can copy the cource...... I had recomended a function contest for specoialized problems.. So rethink the contest idea... TO submit a contest that has been happening all these time it just requires 10 minutes.. Go to a site download a source submit it... No idea how many have done it...

I am also off this contest if the idea remains same...