Compare commits
No commits in common. "1ff9b33bda98f1bfacca98f6792534fb34cc77a8" and "0aa8b7a16f2a91b91317119c60d78b2acbd8f552" have entirely different histories.
1ff9b33bda
...
0aa8b7a16f
4
Makefile
4
Makefile
@ -28,8 +28,8 @@ obj/%.o:
|
|||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CXX) $(CXXFLAGS) -o $@ -c $<
|
$(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
stickfosh: $(OBJFILES)
|
main: $(OBJFILES)
|
||||||
$(CXX) $(CXXFLAGS) $(OBJFILES) $(LOADLIBES) $(LDLIBS) -o stickfosh -lsfml-graphics -lsfml-window -lsfml-system
|
$(CXX) $(CXXFLAGS) $(OBJFILES) $(LOADLIBES) $(LDLIBS) -o main -lsfml-graphics -lsfml-window -lsfml-system
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf obj/* $(DEPFILES) test_bin/
|
rm -rf obj/* $(DEPFILES) test_bin/
|
||||||
|
14
README.md
14
README.md
@ -60,17 +60,13 @@ This project has undergone multiple AI improvements, including:
|
|||||||
./main
|
./main
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running the Application
|
## Running AI vs AI Matches
|
||||||
|
|
||||||
Stickfosh provides multiple execution modes, selectable via command-line arguments:
|
To watch two AI versions play against each other, modify `main.cpp` to instantiate the desired AI versions and run:
|
||||||
|
|
||||||
| Mode | Description | Example Command |
|
```sh
|
||||||
|------|------------|----------------|
|
./main
|
||||||
| **Human vs AI** | Play against the AI | `./stickfosh --mode human_vs_ai` |
|
```
|
||||||
| **AI vs AI** | Watch two AI versions compete | `./stickfosh --mode ai_vs_ai --ai1 v3_AB_ordering --ai2 v6_iterative_deepening` |
|
|
||||||
| **Human vs Human** | Manually input moves for both sides | `./stickfosh --mode human_vs_human` |
|
|
||||||
| **Perft Testing** | Performance test move generation | `./stickfosh --mode perft` |
|
|
||||||
| **Custom FEN** | Start from a custom position | `./stickfosh --mode ai_vs_ai --fen "rnbqkb1r/pppppppp/8/8/8/8/PPPPPPPP/RNBQKB1R w KQkq - 0 1"` |
|
|
||||||
|
|
||||||
## Video Demo
|
## Video Demo
|
||||||
|
|
||||||
|
85
src/main.cpp
85
src/main.cpp
@ -9,73 +9,36 @@
|
|||||||
#include "view/view.hpp"
|
#include "view/view.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
void print_usage() {
|
|
||||||
std::cout << "Usage: chess_ai [OPTIONS]\n";
|
|
||||||
std::cout << "Options:\n";
|
|
||||||
std::cout
|
|
||||||
<< " --mode <human_vs_ai|ai_vs_ai|human_vs_human|perft> Choose the "
|
|
||||||
"game mode.\n";
|
|
||||||
std::cout << " --ai1 <version> Choose the first AI version (for ai_vs_ai "
|
|
||||||
"mode).\n";
|
|
||||||
std::cout << " --ai2 <version> Choose the second AI version (for "
|
|
||||||
"ai_vs_ai mode).\n";
|
|
||||||
std::cout << " --fen <FEN_STRING> Set a custom FEN position.\n";
|
|
||||||
std::cout << " --help Show this help message.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string mode = "human_vs_ai";
|
// std::string pos =
|
||||||
std::string ai1_version = "v0_random";
|
// "r2qkb1r/2p1pppp/p1n1b3/1p6/B2P4/2P1P3/P4PPP/R1BQK1NR w KQkq - 0 9 ";
|
||||||
std::string ai2_version = "v6_iterative_deepening";
|
std::string pos = "3r4/3r4/3k4/8/3K4/8/8/8 w - - 0 1";
|
||||||
std::string fen =
|
|
||||||
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
// pos for ai timing<
|
||||||
std::string arg = argv[i];
|
// std::string pos =
|
||||||
if (arg == "--mode" && i + 1 < argc) {
|
// "r3k2r/p1ppqpb1/Bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPB1PPP/R3K2R b KQkq - 0
|
||||||
mode = argv[++i];
|
// 3";
|
||||||
} else if (arg == "--ai1" && i + 1 < argc) {
|
|
||||||
ai1_version = argv[++i];
|
Board b = Board::setup_fen_position(pos);
|
||||||
} else if (arg == "--ai2" && i + 1 < argc) {
|
|
||||||
ai2_version = argv[++i];
|
ai::v0_random p1(true, std::chrono::milliseconds(1000));
|
||||||
} else if (arg == "--fen" && i + 1 < argc) {
|
// ai::v1_pure_minimax p2(false, std::chrono::milliseconds(20000));
|
||||||
fen = argv[++i];
|
// ai::v2_alpha_beta p2(false, std::chrono::milliseconds(20000));
|
||||||
} else if (arg == "--help") {
|
// ai::v3_AB_ordering p2(false, std::chrono::milliseconds(20000));
|
||||||
print_usage();
|
// ai::v4_search_captures p2(false, std::chrono::milliseconds(20000));
|
||||||
return 0;
|
// ai::v5_better_endgame p2(false, std::chrono::milliseconds(20000));
|
||||||
} else {
|
ai::v6_iterative_deepening p2(false, std::chrono::milliseconds(2000));
|
||||||
std::cerr << "Unknown option: " << arg << "\n";
|
|
||||||
print_usage();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Board board = Board::setup_fen_position(fen);
|
|
||||||
GUI gui;
|
GUI gui;
|
||||||
Controller* controller = nullptr;
|
// NoOpView gui;
|
||||||
|
// AIvsAIController manual(b, gui, p1, p2);
|
||||||
|
HumanVsAIController manual(b, gui, p2);
|
||||||
|
|
||||||
if (mode == "human_vs_ai") {
|
Controller& controller = manual;
|
||||||
ai::v6_iterative_deepening ai(false, std::chrono::milliseconds(2000));
|
|
||||||
controller = new HumanVsAIController(board, gui, ai);
|
|
||||||
} else if (mode == "ai_vs_ai") {
|
|
||||||
ai::v0_random p1(true, std::chrono::milliseconds(1000));
|
|
||||||
ai::v6_iterative_deepening p2(false, std::chrono::milliseconds(2000));
|
|
||||||
controller = new AIvsAIController(board, gui, p1, p2);
|
|
||||||
} else if (mode == "human_vs_human") {
|
|
||||||
controller = new ManualController(board, gui);
|
|
||||||
} else if (mode == "perft") {
|
|
||||||
perft();
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
std::cerr << "Invalid mode selected!\n";
|
|
||||||
print_usage();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
controller->start();
|
controller.start();
|
||||||
delete controller;
|
|
||||||
|
// perft();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user