diff --git a/docs/windows.md b/docs/windows.md index ad695f2fab..fe206d13e6 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -56,7 +56,13 @@ CMake, and choose `C:\Users\MyUser\open_spiel\open_spiel\CMakeLists.txt`. CMake will then run; once you see `CMake generation finished`, choose Build -> Build All. The files will be available in `C:\Users\MyUser\open_spiel\open_spiel\out\build\x64-Debug`, when the build -completes with "Build All succeeded." +completes with "Build All succeeded." Extra compilation options may be necessary +if errors occur. \ +MSVC options to deal with required C++ standard, file encoding (for chess +characters) and large object files include `/std:c++17`, `/utf-8`, `/bigobj`. To +use them together with default MSVC arguments, you can use the follwing CMake +command line arguments: `-DCMAKE_CXX_FLAGS="/std:c++17 /utf-8 /bigobj /DWIN32 +/D_WINDOWS /GR /EHsc"` To be able to import the Python code (both the C++ binding `pyspiel` and the rest) from any location, you will need to add to your PYTHONPATH the root diff --git a/open_spiel/games/bridge/bridge.cc b/open_spiel/games/bridge/bridge.cc index 86be844580..6207c95924 100644 --- a/open_spiel/games/bridge/bridge.cc +++ b/open_spiel/games/bridge/bridge.cc @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +#define NOMINMAX #include "open_spiel/games/bridge/bridge.h" #include diff --git a/open_spiel/games/twixt/twixtboard.cc b/open_spiel/games/twixt/twixtboard.cc index 8c08574403..036e64036d 100644 --- a/open_spiel/games/twixt/twixtboard.cc +++ b/open_spiel/games/twixt/twixtboard.cc @@ -386,9 +386,9 @@ void Board::AppendPegChar(std::string& s, Position position) const { void Board::AppendBeforeRow(std::string& s, Position position) const { // -1, +1 int len = s.length(); - AppendLinkChar(s, position + (Position){-1, 0}, kENE, "/"); - AppendLinkChar(s, position + (Position){-1, -1}, kNNE, "/"); - AppendLinkChar(s, position + (Position){0, 0}, kWNW, "_"); + AppendLinkChar(s, position + Position{-1, 0}, kENE, "/"); + AppendLinkChar(s, position + Position{-1, -1}, kNNE, "/"); + AppendLinkChar(s, position + Position{0, 0}, kWNW, "_"); if (len == s.length()) s.append(" "); // 0, +1 @@ -399,17 +399,17 @@ void Board::AppendBeforeRow(std::string& s, Position position) const { // +1, +1 len = s.length(); - AppendLinkChar(s, position + (Position){+1, 0}, kWNW, "\\"); - AppendLinkChar(s, position + (Position){+1, -1}, kNNW, "\\"); - AppendLinkChar(s, position + (Position){0, 0}, kENE, "_"); + AppendLinkChar(s, position + Position{+1, 0}, kWNW, "\\"); + AppendLinkChar(s, position + Position{+1, -1}, kNNW, "\\"); + AppendLinkChar(s, position + Position{0, 0}, kENE, "_"); if (len == s.length()) s.append(" "); } void Board::AppendPegRow(std::string& s, Position position) const { // -1, 0 int len = s.length(); - AppendLinkChar(s, position + (Position){-1, -1}, kNNE, "|"); - AppendLinkChar(s, position + (Position){0, 0}, kWSW, "_"); + AppendLinkChar(s, position + Position{-1, -1}, kNNE, "|"); + AppendLinkChar(s, position + Position{0, 0}, kWSW, "_"); if (len == s.length()) s.append(" "); // 0, 0 @@ -417,30 +417,30 @@ void Board::AppendPegRow(std::string& s, Position position) const { // +1, 0 len = s.length(); - AppendLinkChar(s, position + (Position){+1, -1}, kNNW, "|"); - AppendLinkChar(s, position + (Position){0, 0}, kESE, "_"); + AppendLinkChar(s, position + Position{+1, -1}, kNNW, "|"); + AppendLinkChar(s, position + Position{0, 0}, kESE, "_"); if (len == s.length()) s.append(" "); } void Board::AppendAfterRow(std::string& s, Position position) const { // -1, -1 int len = s.length(); - AppendLinkChar(s, position + (Position){+1, -1}, kWNW, "\\"); - AppendLinkChar(s, position + (Position){0, -1}, kNNW, "\\"); + AppendLinkChar(s, position + Position{+1, -1}, kWNW, "\\"); + AppendLinkChar(s, position + Position{0, -1}, kNNW, "\\"); if (len == s.length()) s.append(" "); // 0, -1 len = s.length(); - AppendLinkChar(s, position + (Position){-1, -1}, kENE, "_"); - AppendLinkChar(s, position + (Position){+1, -1}, kWNW, "_"); + AppendLinkChar(s, position + Position{-1, -1}, kENE, "_"); + AppendLinkChar(s, position + Position{+1, -1}, kWNW, "_"); AppendLinkChar(s, position, kSSW, "|"); if (len == s.length()) AppendLinkChar(s, position, kSSE, "|"); if (len == s.length()) s.append(" "); // -1, -1 len = s.length(); - AppendLinkChar(s, position + (Position){-1, -1}, kENE, "/"); - AppendLinkChar(s, position + (Position){0, -1}, kNNE, "/"); + AppendLinkChar(s, position + Position{-1, -1}, kENE, "/"); + AppendLinkChar(s, position + Position{0, -1}, kNNE, "/"); if (len == s.length()) s.append(" "); } @@ -514,7 +514,7 @@ void Board::SetPegAndLinks(Player player, Position position) { if (target_cell.color() == cell.color()) { // check if there are blocking links before setting link const std::set& blockers = - BlockerMap::GetBlockers((Link){position, dir}); + BlockerMap::GetBlockers(Link{position, dir}); bool blocked = false; for (auto& bl : blockers) { if (GetCell(bl.position).HasLink(bl.direction)) { diff --git a/open_spiel/utils/file.cc b/open_spiel/utils/file.cc index 569ff89a1c..9016e6dd12 100644 --- a/open_spiel/utils/file.cc +++ b/open_spiel/utils/file.cc @@ -106,9 +106,14 @@ bool Exists(const std::string& path) { } std::string RealPath(const std::string& path) { +#ifdef _WIN32 + char real_path[MAX_PATH]; + if (_fullpath(real_path, path.c_str(), MAX_PATH) == nullptr) { +#else char real_path[PATH_MAX]; if (realpath(path.c_str(), real_path) == nullptr) { // If there was an error return an empty path +#endif return ""; }