Skip to content

Commit 370d7cf

Browse files
authored
Merge pull request #945 from utilForever/refactor
Refactor code
2 parents c7b0c0d + a0cb919 commit 370d7cf

73 files changed

Lines changed: 1364 additions & 840 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/macos.yml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ name: macOS
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
811

912
env:
10-
PYTHON_VERSION: '3.12'
13+
PYTHON_VERSION: "3.12"
1114

1215
jobs:
1316
build-macos:
@@ -39,38 +42,39 @@ jobs:
3942
os: macos-26
4043
compiler: gcc
4144
version: "13"
42-
4345
runs-on: ${{ matrix.os }}
4446
name: 🍎 Build - ${{ matrix.name }}
4547

4648
steps:
47-
- uses: actions/checkout@v4
48-
- name: Setup Python
49-
uses: actions/setup-python@v5
50-
with:
51-
python-version: ${{ env.PYTHON_VERSION }}
52-
- name: Install packages
53-
run: brew install autoconf autoconf-archive automake libtool
54-
- name: Configure Compiler
55-
run: |
56-
if [ "${{ matrix.compiler }}" = "gcc" ]; then
57-
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
58-
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
59-
else
60-
ls -ls /Applications/
61-
sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
62-
echo "CC=clang" >> $GITHUB_ENV
63-
echo "CXX=clang++" >> $GITHUB_ENV
64-
fi
65-
- name: Configure Build
66-
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ..
67-
- name: Build
68-
run: cd build && make
69-
- name: Run Unit Test
70-
run: /Users/runner/work/RosettaStone/RosettaStone/build/bin/UnitTests
71-
- name: Run Python Test
72-
run: |
73-
python -m pip install --upgrade pip
74-
python -m pip install -r requirements.txt
75-
python -m pip install .
76-
python -m pytest Tests/PythonTests/
49+
- uses: actions/checkout@v4
50+
with:
51+
persist-credentials: false
52+
- name: Setup Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: ${{ env.PYTHON_VERSION }}
56+
- name: Install packages
57+
run: brew install autoconf autoconf-archive automake libtool
58+
- name: Configure Compiler
59+
run: |
60+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
61+
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
62+
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
63+
else
64+
ls -ls /Applications/
65+
sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
66+
echo "CC=clang" >> $GITHUB_ENV
67+
echo "CXX=clang++" >> $GITHUB_ENV
68+
fi
69+
- name: Configure Build
70+
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ..
71+
- name: Build
72+
run: cd build && make
73+
- name: Run Unit Test
74+
run: /Users/runner/work/RosettaStone/RosettaStone/build/bin/UnitTests
75+
- name: Run Python Test
76+
run: |
77+
python -m pip install --upgrade pip==26.1.2
78+
python -m pip install -r requirements.txt
79+
python -m pip install --no-build-isolation --no-deps .
80+
python -m pytest Tests/PythonTests/

.github/workflows/ubuntu-codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
lcov --gcov-tool "${GCOV_TOOL}" --directory build --capture --output-file build/coverage.info
5353
lcov --ignore-errors unused --gcov-tool "${GCOV_TOOL}" --remove build/coverage.info '/usr/*' '*/Tests/*' --output-file build/coverage.info.cleaned
5454
- name: Upload Coverage Reports to Codecov
55-
uses: codecov/codecov-action@v5
55+
uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac # v5
5656
with:
5757
fail_ci_if_error: true
5858
files: ./build/coverage.info.cleaned

.github/workflows/ubuntu-sonarcloud.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
runs-on: ubuntu-latest
1717
env:
1818
BUILD_WRAPPER_OUT_DIR: bw-output
19+
CC: gcc-14
20+
CXX: g++-14
1921
steps:
2022
- uses: actions/checkout@v4
2123
with:

.github/workflows/ubuntu.yml

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ name: Ubuntu
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
811

912
env:
10-
PYTHON_VERSION: '3.12'
13+
PYTHON_VERSION: "3.12"
1114

1215
jobs:
1316
build-ubuntu:
@@ -19,63 +22,44 @@ jobs:
1922
os: ubuntu-24.04
2023
compiler: gcc
2124
version: "14"
22-
# Ubuntu 24.04 + gcc-13
23-
- name: "Ubuntu 24.04 + gcc-13"
24-
os: ubuntu-24.04
25-
compiler: gcc
26-
version: "13"
27-
# Ubuntu 24.04 + gcc-12
28-
- name: "Ubuntu 24.04 + gcc-12"
29-
os: ubuntu-24.04
30-
compiler: gcc
31-
version: "12"
3225
# Ubuntu 24.04 + clang-18
3326
- name: "Ubuntu 24.04 + clang-18"
3427
os: ubuntu-24.04
3528
compiler: clang
3629
version: "18"
37-
# Ubuntu 24.04 + clang-17
38-
- name: "Ubuntu 24.04 + clang-17"
39-
os: ubuntu-24.04
40-
compiler: clang
41-
version: "17"
42-
# Ubuntu 24.04 + clang-16
43-
- name: "Ubuntu 24.04 + clang-16"
44-
os: ubuntu-24.04
45-
compiler: clang
46-
version: "16"
47-
4830
runs-on: ${{ matrix.os }}
4931
name: 🐧 Build - ${{ matrix.name }}
5032

5133
steps:
52-
- uses: actions/checkout@v4
53-
- name: Setup Python
54-
uses: actions/setup-python@v5
55-
with:
56-
python-version: ${{ env.PYTHON_VERSION }}
57-
- name: Check generated docs
58-
run: python Scripts/card_stats.py --check
59-
- name: Install packages
60-
run: sudo apt-get update && sudo apt-get install -yq autoconf autoconf-archive automake libtool python3-setuptools
61-
- name: Configure Compiler
62-
run: |
63-
if [ "${{ matrix.compiler }}" = "gcc" ]; then
64-
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
65-
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
66-
else
67-
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
68-
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
69-
fi
70-
- name: Configure Build
71-
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ..
72-
- name: Build
73-
run: cd build && make
74-
- name: Run Unit Test
75-
run: /home/runner/work/RosettaStone/RosettaStone/build/bin/UnitTests
76-
- name: Run Python Test
77-
run: |
78-
python -m pip install --upgrade pip
79-
python -m pip install -r requirements.txt
80-
python -m pip install .
81-
python -m pytest Tests/PythonTests/
34+
- uses: actions/checkout@v4
35+
with:
36+
persist-credentials: false
37+
- name: Setup Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ env.PYTHON_VERSION }}
41+
- name: Check generated docs
42+
run: python Scripts/card_stats.py --check
43+
- name: Install packages
44+
run: sudo apt-get update && sudo apt-get install -yq autoconf autoconf-archive automake libtool python3-setuptools
45+
- name: Configure Compiler
46+
run: |
47+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
48+
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
49+
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
50+
else
51+
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
52+
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
53+
fi
54+
- name: Configure Build
55+
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ..
56+
- name: Build
57+
run: cd build && make
58+
- name: Run Unit Test
59+
run: /home/runner/work/RosettaStone/RosettaStone/build/bin/UnitTests
60+
- name: Run Python Test
61+
run: |
62+
python -m pip install --upgrade pip==26.1.2
63+
python -m pip install -r requirements.txt
64+
python -m pip install --no-build-isolation --no-deps .
65+
python -m pytest Tests/PythonTests/

.github/workflows/windows.yml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ name: Windows
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
811

912
env:
10-
PYTHON_VERSION: '3.12'
13+
PYTHON_VERSION: "3.12"
1114

1215
jobs:
1316
build-windows:
@@ -27,22 +30,24 @@ jobs:
2730
name: 🪟 Build - ${{ matrix.name }}
2831

2932
steps:
30-
- uses: actions/checkout@v4
31-
- name: Setup Python
32-
uses: actions/setup-python@v5
33-
with:
34-
python-version: ${{ env.PYTHON_VERSION }}
35-
- name: Configure Build
36-
run: mkdir build && cd build && cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" ..
37-
- name: Add MSBuild to PATH
38-
uses: microsoft/setup-msbuild@v2
39-
- name: Build
40-
run: cd build && MSBuild.exe ${{ matrix.solution }} /p:Configuration=Release
41-
- name: Run Unit Test
42-
run: /a/RosettaStone/RosettaStone/build/bin/Release/UnitTests.exe
43-
- name: Run Python Test
44-
run: |
45-
python -m pip install --upgrade pip
46-
python -m pip install -r requirements.txt
47-
python -m pip install .
48-
python -m pytest Tests/PythonTests/
33+
- uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
36+
- name: Setup Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ env.PYTHON_VERSION }}
40+
- name: Configure Build
41+
run: mkdir build && cd build && cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" ..
42+
- name: Add MSBuild to PATH
43+
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
44+
- name: Build
45+
run: cd build && MSBuild.exe ${{ matrix.solution }} /p:Configuration=Release
46+
- name: Run Unit Test
47+
run: /a/RosettaStone/RosettaStone/build/bin/Release/UnitTests.exe
48+
- name: Run Python Test
49+
run: |
50+
python -m pip install --upgrade pip==26.1.2
51+
python -m pip install -r requirements.txt
52+
python -m pip install --no-build-isolation --no-deps .
53+
python -m pytest Tests/PythonTests/

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Guidance for AI coding agents (Codex, Claude Code, etc.) working in this reposit
44

55
## What this repository is
66

7-
This is **RosettaStone**, a C++17 Hearthstone simulator with console tooling, generated card/task implementations, and a Python API exposed through pybind11.
7+
This is **RosettaStone**, a C++23 Hearthstone simulator with console tooling, generated card/task implementations, and a Python API exposed through pybind11.
88

99
It is not just a single C++ library:
1010

@@ -22,7 +22,7 @@ Upstream lives at <https://github.com/utilForever/RosettaStone.git>.
2222
1. **Keep C++ and Python-visible behavior in sync.** If you change public types, enums, cards, tasks, zones, game flow, or other core behavior, check whether `Extensions/RosettaPython/` and `Tests/PythonTests/` need matching updates.
2323
2. **Treat generated files as generated.** `Includes/Rosetta/RosettaStone.hpp` is produced by `Scripts/header_gen.py` during the CMake build. Change headers under `Includes/Rosetta/` or the generator, not the aggregate header by hand.
2424
3. **Use CMake targets as the source of truth.** Before adding or moving C++ files, read the relevant `CMakeLists.txt`. Most source lists use `GLOB_RECURSE`, but target ownership and compile definitions still live there.
25-
4. **Preserve C++17 portability.** CI builds on Ubuntu, macOS, and Windows with several compilers. Avoid compiler-specific assumptions unless they are isolated or guarded by CMake.
25+
4. **Preserve C++23 portability.** CI builds on Ubuntu, macOS, and Windows with several compilers. Avoid compiler-specific assumptions unless they are isolated or guarded by CMake.
2626
5. **Do not add dependencies casually.** Prefer the standard library and existing vendored libraries. If Python dependencies change, update `requirements.txt` and verify the Python tests.
2727
6. **Run the smallest relevant check.** Documentation-only changes usually do not need a build. Code or API changes should run the focused C++ and/or Python tests below.
2828

ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RosettaStone is distributed and consumed in the following ways:
44

5-
- A C++17 Hearthstone simulator library for use from C++.
5+
- A C++23 Hearthstone simulator library for use from C++.
66
- A `pyRosetta` Python extension exposed through pybind11.
77
- Console and utility executables built on top of the same simulator library.
88

Builds/CMake/CompileOptions.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ endif()
2626
#
2727

2828
set(DEFAULT_PROJECT_OPTIONS
29-
CXX_STANDARD 17 # Not available before CMake 3.8.2; see below for manual command line argument addition
29+
CXX_STANDARD 23
30+
CXX_STANDARD_REQUIRED ON
31+
CXX_EXTENSIONS OFF
3032
LINKER_LANGUAGE "CXX"
3133
POSITION_INDEPENDENT_CODE ON
3234
)
@@ -127,7 +129,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
127129
-Wno-unused-variable # -> disable warning: error: unused variable 'curr_delta' [-Werror=unused-variable] (caused by tiny-dnn)
128130

129131
${WARN_AS_ERROR_FLAGS}
130-
-std=c++1z
131132
)
132133
endif ()
133134

Documents/Install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Or, you can simply clone the clode by adding --recursive option.
1616
git clone https://github.com/utilForever/RosettaStone.git --recursive
1717
```
1818

19-
To build the code, a compiler that supports C++17 is required. Platform-specific build instructions are described below.
19+
To build the code, a compiler that supports C++23 is required. Platform-specific build instructions are described below.
2020

2121
### Building from macOS
2222

@@ -203,4 +203,4 @@ The build quality is tracked by [Travis CI](https://travis-ci.org/utilForever/Ro
203203

204204
### Code Quality
205205

206-
The code quality is tracked by [Codacy](https://app.codacy.com/project/utilForever/RosettaStone/dashboard) and [CodeFactor](https://www.codefactor.io/repository/github/utilforever/RosettaStone). Any pull requests must pass all the code quality tools.
206+
The code quality is tracked by [Codacy](https://app.codacy.com/project/utilForever/RosettaStone/dashboard) and [CodeFactor](https://www.codefactor.io/repository/github/utilforever/RosettaStone). Any pull requests must pass all the code quality tools.

Documents/doxygen/main.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Hearthstone++ is hearthstone simulator using C++ with some reinforcement learning. The code is built on C++17 and can be compiled with commonly available compilers such as g++, clang++, or Microsoft Visual Studio. Hearthstone++ currently supports macOS (10.12.6 or later), Ubuntu (17.04 or later), Windows (Visual Studio 2017 or later), and Windows Subsystem for Linux (WSL). Other untested platforms that support C++17 also should be able to build Hearthstone++.
1+
RosettaStone is a Hearthstone simulator using C++ with some reinforcement learning. The code is built on C++23 and can be compiled with supported versions of g++, clang++, or Microsoft Visual Studio. RosettaStone currently supports macOS, Ubuntu, Windows, and Windows Subsystem for Linux (WSL). Other C++23 platforms have not been verified.
22

33
### Key Features
44

55
- JSON-based hearthstone card data
66
- Console, GUI, web-based simulator
77
- Reinforcement learning to "The Innkeeper" smart
8-
- C++ and Python API
8+
- C++ and Python API

0 commit comments

Comments
 (0)