A program to solve N-y thing problem using these algorithms:
- Hill Climbing Algorithm
- Simulated Annealing Algorithm
- Genetic Algorithm
We need these models:
- Bishop
- Queen
- Knight
- Rook
All these models will inherit the ChessPiece abstract base class, which has these attributes:
-
position
save it as a pair of values (x,y)
-
countAttackedPawns count the other pawns that can be attacked by this
-
color
black or white
In the solver.py file, we need to implement these methods:
-
generate_move : This function will receive the current state of the problem and make a move one pawn based on the best cost.
-
generate_random_move : This function will receive the current state and make a random move (move one pawn to random location).
-
generate_random_solution : This function will receive the current state of the problem and will make a random solution out of it.
I think we need to implement another function for the genetic algorithm, please let us know :D
In the cost.py file, we need to implement this method:
- fitness_function.py : This function will receive the state of a solution and calculate the fitness function.
Those function above will be used in the algorithms.
This will parse the external file and returns the array of Pawns object
This will print the state of the chess board to the screen
The flow of the main program is as follows:
-
File parser.py contains the parser function that will parse the external file and returns an array of Pawns object that is going to be used as the parameter to the algorithm functions.
-
The user will have to choose one of the three algorithms.
-
The array of Pawns object will be thrown into the parameter of those three algorithms (meaning that those algorithms have the same parameters)
-
The algorithms will return an array that depicts the position of the chess pawns.
-
The array then will be printed by the function in the printer.py file.