Mail Archives: djgpp/1997/11/04/14:46:22
Knut Pape wrote:
> I have just started programming with djgpp in C.
> After reading some Tutorials and Book's I'm trying myself on my first
> programm (4Gewinnt).
> Now I have a big problem. I have a board of 42 fields, variables from f1
>
> to f42.
>
All good C/C++ programmers use f0 to f41
> Now the KI has to look up for deadly combinations
Make your squares a struct:
typedef struct square {
bool filled; /* 1 if the square is filled */
int directions; /* Set a bit for each direction you want to search */
};
squares board[41];
(etc)Every square has a finite number of directions to be checked. Use a
bit field to determine which directions to look. Given the size of your
field, a breadth first search may be helpful. (look it up in your algroithm
book) (Go out and buy and algorithm book)
You might want to consider looking at the source code for grep as an aid in
pattern matching. Yes, this can be a pattern matching problem.
>
--
Charles Krug, Jr.
- Raw text -