> You put it very clear. The question now is if the PIC would at least
> be able to represent a board and make some moves without committing
> suicide. Maybe it could be used for some purpose: for example, to
> control positions of the pieces on the board, and things like that,
> then, a more powerful processor would be used for computations. But to
> start, I would prefer a PIC, since it's easier to program than other,
> more complex, solutions.
You could try to reduce the amount of data you store:
You have:
int piece[64]; // values 0..6
int color[64]; // values 0, 1, 6
typedef struct tag_MOVE {
int from, // values 0..63?
dest, // values 0..63?
type; // values 0..7
} MOVE;
/* For storing all moves of game */
typedef struct tag_HIST {
MOVE m;
int cap; // 0..6
} HIST;
That is 64x2 byte for piece and color and 8 byte per tag_HIST.
Using
/*
* Encode color as bit 3 of each entry, bits 0..2 denote the piece,
* 0 (or 15) is empty.
* A) 0: empty; 1..6: white; 9..14: black
* B) 0..5: white, 8..13: black, 15: empty
* I'd prefer A...
*
* #define PIECE(p) ((p) & 7)
* #define COLOR(p) (0 != ((p) & 8))
*
* p = piece[position];
* if (0 == piece) {
* empty;
* } else {
* // act on PIECE(p) of COLOR(p)
* }
*/
unsigned char piece[64];
// no color array
typedef struct tag_MOVE {
unsigned char from;
unsigned char dest;
unsigned char type:4;
unsigned char cap:4; // moved up from tag_HIST
} MOVE;
/* For storing all moves of game */
typedef struct tag_HIST {
MOVE m;
} HIST;
would be only 64x1 byte for piece and 3 byte per tag_HIST, allowing you
to keep a HIST hist[85] in a single data bank. It's not 6000, but for a
start... And by using accessor functions you could instantiate 1 <= N <=
8 (or so) of these arrays and access one of them at (INDEX div N),
basing the selection on (INDEX mod N) either via a pointer array or a
switch statement.
Happy coding,
Raphael
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user