-
Notifications
You must be signed in to change notification settings - Fork 0
How to use
My_Torch is a neural network toolkit designed for chess state analysis. It consists of two main components:
- Network Generator (
my_torch_generator
) - Network Analyzer (
my_torch_analyzer
)
- Clone the repository:
git clone git@github.com:FppEpitech/MyTorch.git
cd my_torch
- Build the project:
make
This will generate two executables:
my_torch_generator
my_torch_analyzer
./my_torch_generator config_file_1 nb_1 [config_file_2 nb_2...]
-
config_file_X
: Configuration file path -
nb_X
: Number of networks to generate
./my_torch_generator basic_network.conf 3
This generates:
basic_network_1.nn
basic_network_2.nn
basic_network_3.nn
./my_torch_analyzer [--predict | --train [--save SAVEFILE]] LOADFILE FILE
-
--predict
: Use network to predict chess states -
--train
: Train network using input data -
--save SAVEFILE
: Save trained network (optional) -
LOADFILE
: Neural network file (.nn) -
FILE
: Input data file
- Predict chess states:
./my_torch_analyzer --predict network_1.nn chess_positions.txt
- Train network:
./my_torch_analyzer --train network_1.nn training_data.txt
- Train and save network:
./my_torch_analyzer --train --save new_network.nn network_1.nn training_data.txt
Each line contains:
FEN_string expected_output
Example:
rnbqkbnr/pppp2pp/8/4pp1Q/3P4/4P3/PPP2PPP/RNB1KBNR b KQkq - 1 3 Checkmate
Each line contains a FEN string:
rnbqkbnr/pppp2pp/8/4pp1Q/3P4/4P3/PPP2PPP/RNB1KBNR b KQkq - 1 3
Displays training progress and final accuracy:
Iteration X: Prediction - Target
...
result: XX.XX%
Outputs chess state classification for each input:
- Checkmate Black
- Checkmate White
- Stalemate
- Nothing
- Check White
- Check Black
The program exits with code 84 if:
- Invalid command line arguments
- File not found
- Invalid file format
- Neural network errors
FEN is a standard notation used to describe the state of a chess game. It encodes the position of pieces, the player to move, castling rights, en passant possibilities, half-move clock, and full-move number.
For example, the FEN:
rnbqkbnr/pppp2pp/8/4pp1Q/3P4/4P3/PPP2PPP/RNB1KBNR b KQkq - 1 3 Checkmate
Explanation (each rows are separated by a /):
- rnbqkbnr: Black's pieces (from left to right) on the 8th rank.
- pppp2pp: Black's pawns on the 7th rank.
- 8: Empty 6th rank.
- 4pp1Q: Black pawns and a White Queen on the 5th rank.
- 3P4: White pawn on the 4th rank.
- 4P3: White pawn on the 3rd rank.
- PPP2PPP: White pawns on the 2nd rank.
- RNB1KBNR: White's pieces (from left to right) on the 1st rank
You can eventually put in the end of the line the outcome, in this case Checkmate. You can put :
- Checkmate White
- Checkmate Black
- Check Black
- Check White
- Nothing
- Stalemate