From 4a9871721add27bda57427a819ea0c0b6a103abb Mon Sep 17 00:00:00 2001 From: Aaron Snoswell Date: Fri, 25 Feb 2022 12:47:06 +1000 Subject: [PATCH] Fix #794 morpion_solitaire.cc was using a linux-only C++ extension (ellipses in case statements). I've changed this to a if-else block to fix windows compatibility. --- docs/windows.md | 3 +- open_spiel/games/morpion_solitaire.cc | 51 +++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/windows.md b/docs/windows.md index 4c4d3fa877..368df19721 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -59,7 +59,8 @@ rest) from any location, you will need to add to your PYTHONPATH the root directory and the `open_spiel` directory. Open [Windows environment variables and add to the PYTHONPATH](https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-so-it-finds-my-modules-packages). Add the directories `C:\Users\MyUser\open_spiel\open_spiel\out\build\x64-Debug` -and `C:\Users\MyUser\open_spiel\open_spiel\out\build\x64-Debug` to PYTHONPATH. +and `C:\Users\MyUser\open_spiel\open_spiel\out\build\x64-Debug\python` to PYTHONPATH. +If your PYTHONPATH does not exist, then create a new environment variable for it. To check that python is working, you can run the example in `open_spiel\python\examples`. diff --git a/open_spiel/games/morpion_solitaire.cc b/open_spiel/games/morpion_solitaire.cc index 37ab101223..1f0e822660 100644 --- a/open_spiel/games/morpion_solitaire.cc +++ b/open_spiel/games/morpion_solitaire.cc @@ -62,36 +62,35 @@ Line::Line(Action action) { int base; Point point1; Point point2; - switch (action) { + if (action >= 0 && action <= 129) { // [0, 1] - case 0 ... 129: - row = action / 10; - point1 = Point(row, action - row * 10); - point2 = Point(row, (action - row * 10) + 3); - break; + row = action / 10; + point1 = Point(row, action - row * 10); + point2 = Point(row, (action - row * 10) + 3); + } + else if (action >= 130 && action <= 259) { // [1, 0] - case 130 ... 259: - base = action - 130; - row = (base) / 13; - point1 = Point(row, base - row * 13); - point2 = Point(row + 3, (base - row * 13)); - break; + base = action - 130; + row = (base) / 13; + point1 = Point(row, base - row * 13); + point2 = Point(row + 3, (base - row * 13)); + } + else if (action >= 260 && action <= 359) { // [1, -1] - case 260 ... 359: - base = action - 260; - row = (base) / 10; - point1 = Point(row, base - row * 10); - point2 = Point(row + 3, (base - row * 10) + 3); - break; + base = action - 260; + row = (base) / 10; + point1 = Point(row, base - row * 10); + point2 = Point(row + 3, (base - row * 10) + 3); + } + else if (action >= 360 && action <= 459) { // [1, 1] - case 360 ... 459: - base = action - 360; - row = (base) / 10; - point1 = Point(row + 3, base - row * 10); - point2 = Point(row, (base - row * 10) + 3); - break; - default: - SpielFatalError("action provided does not correspond with a move"); + base = action - 360; + row = (base) / 10; + point1 = Point(row + 3, base - row * 10); + point2 = Point(row, (base - row * 10) + 3); + } + else { + SpielFatalError("action provided does not correspond with a move"); } Init(point1, point2); }