Skip to content

Commit

Permalink
Merge pull request #252 from jhtschultz:external_hearts
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 317867934
Change-Id: I65ec20534cc5557b006e996b90af35c55f900d5f
  • Loading branch information
open_spiel@google.com authored and open_spiel@google.com committed Jun 23, 2020
2 parents 7fabb57 + 53a37af commit 4300bc4
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions open_spiel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ endif()
set (BUILD_WITH_EIGEN $ENV{BUILD_WITH_EIGEN})
message("${BoldYellow}BUILD_WITH_EIGEN: ${BUILD_WITH_EIGEN} ${ColourReset}")

set (BUILD_WITH_XINXIN OFF CACHE BOOL "Build against xinxin Hearts program.")
if(NOT DEFINED ENV{BUILD_WITH_XINXIN})
message("${BoldRed}BUILD_WITH_XINXIN not set. Defaults to OFF${ColourReset}")
set (ENV{BUILD_WITH_XINXIN} OFF)
endif()
set (BUILD_WITH_XINXIN $ENV{BUILD_WITH_XINXIN})
message("${BoldYellow}BUILD_WITH_XINXIN: ${BUILD_WITH_XINXIN} ${ColourReset}")

##


Expand Down Expand Up @@ -165,6 +173,9 @@ if (BUILD_WITH_EIGEN)
include_directories(eigen/libeigen)
set(OPEN_SPIEL_OBJECTS ${OPEN_SPIEL_OBJECTS} $<TARGET_OBJECTS:eigen>)
endif()
if (BUILD_WITH_XINXIN)
set(OPEN_SPIEL_OBJECTS ${OPEN_SPIEL_OBJECTS} $<TARGET_OBJECTS:xinxin>)
endif()

# We have the parent of this directory in the include path, so that we can
# include for example "open_spiel/spiel.h" (assuming this directory is named
Expand Down
3 changes: 3 additions & 0 deletions open_spiel/games/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ endif()
if (${BUILD_WITH_ACPC})
add_subdirectory(universal_poker)
endif()
if (${BUILD_WITH_XINXIN})
add_subdirectory(hearts)
endif()

# Uncomment to build the Ludii demo
# add_subdirectory (ludii)
Expand Down
42 changes: 42 additions & 0 deletions open_spiel/games/hearts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
add_library(xinxin OBJECT
hearts/Algorithm.cpp
hearts/Algorithm.h
hearts/CardGameState.cpp
hearts/CardGameState.h
hearts/CardProbabilityData.cpp
hearts/CardProbabilityData.h
hearts/Game.cpp
hearts/Game.h
hearts/GameState.cpp
hearts/GameState.h
hearts/Hearts.cpp
hearts/Hearts.h
hearts/HeartsGameData.cpp
hearts/HeartsGameData.h
hearts/HeartsGameHistories.cpp
hearts/HeartsGameHistories.h
hearts/Player.cpp
hearts/Player.h
hearts/ProblemState.cpp
hearts/ProblemState.h
hearts/States.cpp
hearts/States.h
hearts/Timer.cpp
hearts/Timer.h
hearts/UCT.cpp
hearts/UCT.h
hearts/algorithmStates.cpp
hearts/algorithmStates.h
hearts/fpUtil.cpp
hearts/fpUtil.h
hearts/hash.cpp
hearts/hash.h
hearts/iiGameState.cpp
hearts/iiGameState.h
hearts/iiMonteCarlo.cpp
hearts/iiMonteCarlo.h
hearts/mt_random.cpp
hearts/mt_random.h
)

target_include_directories (xinxin PUBLIC hearts)
9 changes: 9 additions & 0 deletions open_spiel/games/hearts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Hearts

OpenSpiel can support playing against Nathan Sturtevant's state of the art
Hearts program xinxin. To enable this option, see
`open_spiel/scripts/global_variables.sh`.

For more information about xinxin, see its
[github page](https://github.com/nathansttt/hearts) and/or
[Nathan's Hearts research page](https://webdocs.cs.ualberta.ca/~nathanst/hearts.html).
1 change: 1 addition & 0 deletions open_spiel/scripts/global_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ export BUILD_WITH_HANABI=${BUILD_WITH_HANABI:-$DEFAULT_OPTIONAL_DEPENDENCY}
export BUILD_WITH_ACPC=${BUILD_WITH_ACPC:-$DEFAULT_OPTIONAL_DEPENDENCY}
export BUILD_WITH_JULIA=${BUILD_WITH_JULIA:-$DEFAULT_OPTIONAL_DEPENDENCY}
export BUILD_WITH_EIGEN=${BUILD_WITH_EIGEN:-$DEFAULT_OPTIONAL_DEPENDENCY}
export BUILD_WITH_XINXIN=${BUILD_WITH_XINXIN:-$DEFAULT_OPTIONAL_DEPENDENCY}
7 changes: 7 additions & 0 deletions open_spiel/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ if [[ ${BUILD_WITH_EIGEN:-"ON"} == "ON" ]] && [[ ! -d ${DIR} ]]; then
git clone -b '3.3.7' --single-branch --depth 1 https://gitlab.com/libeigen/eigen.git ${DIR}
fi

# This GitHub repository contains Nathan Sturtevant's state of the art
# Hearts program xinxin.
DIR="open_spiel/games/hearts/hearts"
if [[ ${BUILD_WITH_XINXIN:-"ON"} == "ON" ]] && [[ ! -d ${DIR} ]]; then
git clone -b 'master' --single-branch --depth 1 https://github.com/nathansttt/hearts.git ${DIR}
fi

# 2. Install other required system-wide dependencies

# Install Julia if required and not present already.
Expand Down

0 comments on commit 4300bc4

Please sign in to comment.