-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature: render pieces using `FEN` notation
- Loading branch information
Showing
7 changed files
with
198 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
[ | ||
{ | ||
"directory": "/Users/aome/dev/c_projects/Chess/cmake/src", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -o CMakeFiles/Chess.dir/Main.cpp.o -c /Users/aome/dev/c_projects/Chess/src/Main.cpp", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -isystem /Library/Frameworks/SDL2_image.framework/Headers -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -F /Library/Frameworks/ -o CMakeFiles/Chess.dir/Main.cpp.o -c /Users/aome/dev/c_projects/Chess/src/Main.cpp", | ||
"file": "/Users/aome/dev/c_projects/Chess/src/Main.cpp", | ||
"output": "src/CMakeFiles/Chess.dir/Main.cpp.o" | ||
}, | ||
{ | ||
"directory": "/Users/aome/dev/c_projects/Chess/cmake/src", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -o CMakeFiles/Chess.dir/ChessLoop.cpp.o -c /Users/aome/dev/c_projects/Chess/src/ChessLoop.cpp", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -isystem /Library/Frameworks/SDL2_image.framework/Headers -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -F /Library/Frameworks/ -o CMakeFiles/Chess.dir/ChessLoop.cpp.o -c /Users/aome/dev/c_projects/Chess/src/ChessLoop.cpp", | ||
"file": "/Users/aome/dev/c_projects/Chess/src/ChessLoop.cpp", | ||
"output": "src/CMakeFiles/Chess.dir/ChessLoop.cpp.o" | ||
}, | ||
{ | ||
"directory": "/Users/aome/dev/c_projects/Chess/cmake/src", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -o CMakeFiles/Chess.dir/SDL_Handler.cpp.o -c /Users/aome/dev/c_projects/Chess/src/SDL_Handler.cpp", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -isystem /Library/Frameworks/SDL2_image.framework/Headers -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -F /Library/Frameworks/ -o CMakeFiles/Chess.dir/SDL_Handler.cpp.o -c /Users/aome/dev/c_projects/Chess/src/SDL_Handler.cpp", | ||
"file": "/Users/aome/dev/c_projects/Chess/src/SDL_Handler.cpp", | ||
"output": "src/CMakeFiles/Chess.dir/SDL_Handler.cpp.o" | ||
}, | ||
{ | ||
"directory": "/Users/aome/dev/c_projects/Chess/cmake/src", | ||
"command": "/usr/bin/g++ -DSOME_DEFINITION -isystem /Library/Frameworks/SDL2.framework/Headers -iframework /Library/Frameworks -isystem /Library/Frameworks/SDL2_image.framework/Headers -Wall -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -F /Library/Frameworks/ -o CMakeFiles/Chess.dir/FEN.cpp.o -c /Users/aome/dev/c_projects/Chess/src/FEN.cpp", | ||
"file": "/Users/aome/dev/c_projects/Chess/src/FEN.cpp", | ||
"output": "src/CMakeFiles/Chess.dir/FEN.cpp.o" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
set(CHESS_SOURCES | ||
ChessLoop.cpp | ||
SDL_Handler.cpp | ||
FEN.cpp | ||
) | ||
|
||
if (WIN32) | ||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/SDL2.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
endif (WIN32) | ||
|
||
# add_executable(Chess Main.cpp ${CHESS_SOURCES}) | ||
add_executable(${PROJECT_NAME} Main.cpp ${CHESS_SOURCES}) | ||
|
||
target_link_libraries(${PROJECT_NAME} SDL2::SDL2 SDL2::SDL2main) | ||
target_link_libraries(${PROJECT_NAME} SDL2::SDL2 SDL2::SDL2main SDL2_image::SDL2_image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "FEN.h" | ||
|
||
std::vector<std::string> FEN::parse(const std::string &fen) | ||
{ | ||
std::vector<std::string> pieces; | ||
int pos = 0; | ||
for (int i = 0; i <= fen.size(); i++) | ||
{ | ||
if (fen[i] == ' ') | ||
{ | ||
pieces.push_back(fen.substr(pos, i - pos)); | ||
pos = i + 1; | ||
} | ||
} | ||
pieces.push_back(fen.substr(pos, fen.size() - pos)); | ||
return pieces; | ||
} | ||
|
||
std::vector<std::string> FEN::get_initial_positions() | ||
{ | ||
std::vector<std::string> initial_positions; | ||
std::string initial_position = | ||
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; | ||
initial_positions = parse(initial_position); | ||
return initial_positions; | ||
} | ||
|
||
std::string FEN::get_positions(const std::vector<std::string> &positions) | ||
{ | ||
return positions[0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace FEN | ||
{ | ||
std::vector<std::string> parse(const std::string &fen); | ||
std::vector<std::string> get_initial_positions(); | ||
std::string get_positions(const std::vector<std::string> &positions); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters