C and C++ are generally the same. I guess I couldn't use that code since I'm using Borland C++. Borland's fun.
Anyway, are there any solvers that determine the most efficient method of solving a deal, as in fewest number of manual moves (not including the final cascade or any sub-moves of super/meta-moves)? I could do that and come up with a rating system for all MS games. That would be really really fun.
Can you help me with some code in my program? I think I got everything I need written out, but I'm having some trouble with classes. Forunately (sarcasm) for me, my second year C++ class was taught by a handful of Word documents. I didn't understand a thing from them. Not to mention it's been about two years since then and I have never used a class in a program.
class column
{
public: //everything is public
apvector <int> c; //array of integers
column();
};
column::column() //constructor thing
{
c.resize(0); //resizes c to zero elements initially
}
I want to be able to make arrays of type "column". Column is just a generic array of ints, where the integers are the cards. In the program, I tell the program to create an array
apvector <column> tbl(8);
(I don't know if you guys are familiar with apvector, but if you don't, it's a type of 1D array.) Ideally, this makes eight empty columns for me. Now I could be able to say
tbl[column_number].c[card_number]
and be able to call up some integer. For example, if all this worked out and MS game #1 was loaded into the program, saying tbl[0].c[0] would return the value 111, or JD. tbl[0].c[1] would be KD, tbl[7].c[5], 10C...
I keep getting the error "Undefined symbol c". What did I screw up this time? Probably something elementary, given what I know about classes. (I know, well, "Jack")
-----Original Message-----
From: Danny A Jones <dajones_at_inreach.com>
To: fc-solve-discuss_at_yahoogroups.com
Date: Fri, 14 Nov 2003 00:08:53 -0800
Subject: Re: Strategies for coding a solver
/*
make_microsoft_freecell_board.c - Program to generate the initial
board of Microsoft Freecell or Freecell Pro for input to
Freecell Solver.
Usage: make-microsoft-freecell-board [board-number] | fc-solve
Note: this program will generate the boards for Microsoft Freecell and
FC-Pro only if it is compiled with a Microsoft C compiler such as
Visual C++.
If you want to generate the code without those compilers use the
pi-make-microsoft-freecell-board program.
Based on the code by Jim Horne (who wrote the original Microsoft Freecell)
Modified By Shlomi Fish, 2000
Modified slightly by Danny A Jones, 2003
This code is under the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
static long seed;
typedef int CARD;
#define ACE 0 /* VALUE(card) */
#define DEUCE 1
#define VALUE(card) ((card) >> 2)
#define CLUB 0 /* SUIT(card) */
#define DIAMOND 1
#define HEART 2
#define SPADE 3
#define SUIT(card) ((card) & 3)
#define BLACK 0 /* COLOR(card) */
#define RED 1
#define COLOR(card) (SUIT(card) == DIAMOND || SUIT(card) == HEART)
#define MAXPOS 21
#define MAXCOL 9 /* includes top row as column 0 */
char * card_to_string(char * s, CARD card, int print_ts)
{
int suit = SUIT(card);
int v = VALUE(card)+1;
switch (v)
{
case 1: strcpy(s, "A" ); break;
case 10:
if (print_ts) strcpy(s, "T" );
else strcpy(s, "10"); break;
case 11: strcpy(s, "J" ); break;
case 12: strcpy(s, "Q" ); break;
case 13: strcpy(s, "K" ); break;
default:
sprintf(s, "%i", v);
}
switch (suit)
{
case CLUB: strcat(s, "C" ); break;
case DIAMOND: strcat(s, "D" ); break;
case HEART: strcat(s, "H" ); break;
case SPADE: strcat(s, "S" ); break;
}
return s;
}
int ms_rand( void )
{
seed = seed * 214013L + 2531011L;
return (seed >> 16) & 0x7fff;
}
int main(int argc, char * argv[])
{
CARD card[MAXCOL][MAXPOS]; /* current layout of cards, CARDs are ints */
int i, j; /* generic counters */
int wLeft = 52; /* cards left to be chosen in shuffle */
CARD deck[52]; /* deck of 52 unique cards */
int gamenumber;
int print_ts = 0;
int arg;
if (argc == 1) gamenumber = time(NULL);
else
{
arg = 1;
if (!strcmp(argv[arg], "-t"))
{
print_ts = 1;
arg++;
}
gamenumber = atoi(argv[arg]);
}
/* shuffle cards */
for (i = 0; i < 52; i++) /* put unique card in each deck loc. */
deck[i] = i;
seed = gamenumber;
for (i = 0; i < 52; i++)
{
j = ms_rand() % wLeft;
card[(i%8)+1][i/8] = deck[j];
deck[j] = deck[--wLeft];
}
{
int stack;
int c;
char card_string[10];
for (stack=1; stack<9; stack++ )
{
for (c=0; c < (6+(stack<5)); c++)
{
printf("%s",
card_to_string(card_string,card[stack][c],print_ts ) );
}
printf("%s", "\n");
}
}
return 0;
}
Received on Fri Nov 14 2003 - 13:41:17 IST