How to improve gataxx

Here is do some suggestions for improving gataxx, in no particular order:

Possible moves

Currently, all computer-player functions find out on their own what moves can be done. A function should be made which finds all possible moves, with duplicates removed and no jumps if a normal move to the same spot is possible.

This should probably work as follows:

function getPossibleMoves(board, player) {
	foreach(empty box) {
		move=find_one_normal_move(board, player);
		if (move) {
			moveList.add(move);
		} else {
			moves=find_all_jump_moves(board, player);
			moveList.add(moves);
		}
	}
	return moveList;
}
This function searches for each empty box one normal move, and searches only for jump moves to the same spot if no normal move is found. This would result in a minimum number of moves possible.

To effectively process moves, it would be easy to make a move struct. There are two possibilities for such a struct. The first is making a position struct and combining two position structs to get a move struct:

struct pos {
	int x;
	int y;
}

struct move {
	struct pos from;
	struct pos to;
}
The second one is to put 4 integers in the move struct, for each coordinate one. Depending on the algorithm, the score for each move may also need to be stored. Structs are easy to clone with the function memcpy.

Provide for more and better levels

Currently, the levels are named level one, level two and level three. Maybe it is logical for the developer which one is the hardest, but this may not be clear to everyone. The levels should get names like:

  1. learning
  2. novice
  3. intermediate
  4. advanced
  5. professional
or, even more clear, names ranging from very easy to very hard.

Very easy should be for people learning the rules of the game. The computer makes a random move, more normal moves than jumps. Easy should pick the move with the highest score, with a heuristic based on the number of pieces. Hard and very hard should do alpha-beta pruning or minimax search. Medium can do either one of these or use a better heuristic than easy.

Code cleanup

The code of ataxx is messy, has no comment and is badly organized. It is difficult for others to read and understand. If you expect someone else to contribute to the source code, you should keep it nice and clean.

Split the AI from the rest of the program

Each AI algorithm needs some common functions, like one to get all possible moves and methods to alter the board and to get information about the current state. These functions should be in one file. Furthermore, the algorithms themselves should be in another separate file. This makes it easy to try out new algorithms and heuristics, because one has only one file to replace.