Skip to content

Commit

Permalink
Merge pull request google-deepmind#1255 from WFKala:run_windows
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 658379086
Change-Id: If4c73f3a71c3d7b8aef2a1b0df645ebe645b5236
  • Loading branch information
lanctot committed Aug 2, 2024
2 parents b9b6cc0 + 92d5c77 commit 023847b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
8 changes: 7 additions & 1 deletion docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion open_spiel/games/bridge/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <algorithm>
Expand Down
34 changes: 17 additions & 17 deletions open_spiel/games/twixt/twixtboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -399,48 +399,48 @@ 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
AppendPegChar(s, position);

// +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(" ");
}

Expand Down Expand Up @@ -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<Link>& 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)) {
Expand Down
5 changes: 5 additions & 0 deletions open_spiel/utils/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}

Expand Down

0 comments on commit 023847b

Please sign in to comment.