trianglengin 2.0.2__cp310-cp310-win_amd64.whl → 2.0.4__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trianglengin/Release/trianglengin_cpp.cp39-win_amd64.pyd +0 -0
- trianglengin/cpp/game_state.cpp +10 -17
- trianglengin/game_interface.py +14 -0
- trianglengin/trianglengin_cpp.cp310-win_amd64.pyd +0 -0
- {trianglengin-2.0.2.dist-info → trianglengin-2.0.4.dist-info}/METADATA +4 -4
- {trianglengin-2.0.2.dist-info → trianglengin-2.0.4.dist-info}/RECORD +10 -10
- {trianglengin-2.0.2.dist-info → trianglengin-2.0.4.dist-info}/WHEEL +0 -0
- {trianglengin-2.0.2.dist-info → trianglengin-2.0.4.dist-info}/entry_points.txt +0 -0
- {trianglengin-2.0.2.dist-info → trianglengin-2.0.4.dist-info}/licenses/LICENSE +0 -0
- {trianglengin-2.0.2.dist-info → trianglengin-2.0.4.dist-info}/top_level.txt +0 -0
Binary file
|
trianglengin/cpp/game_state.cpp
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#include "shape_logic.h"
|
5
5
|
#include <stdexcept>
|
6
6
|
#include <numeric>
|
7
|
-
#include <iostream> //
|
7
|
+
#include <iostream> // Keep iostream if other debug logs might be added later, or remove if not needed
|
8
8
|
#include <algorithm> // For std::min
|
9
9
|
|
10
10
|
namespace trianglengin::cpp
|
@@ -41,8 +41,7 @@ namespace trianglengin::cpp
|
|
41
41
|
if (!game_over_ && valid_actions_cache_ && valid_actions_cache_->empty())
|
42
42
|
{
|
43
43
|
force_game_over("No valid actions available at start.");
|
44
|
-
// Log
|
45
|
-
std::cerr << "[GameStateCpp::check_initial_state_game_over] Forced game over: No valid actions at start." << std::endl;
|
44
|
+
// REMOVED C++ Log: std::cerr << "[GameStateCpp::check_initial_state_game_over] Forced game over: No valid actions at start." << std::endl;
|
46
45
|
}
|
47
46
|
}
|
48
47
|
|
@@ -218,8 +217,7 @@ namespace trianglengin::cpp
|
|
218
217
|
if (!game_over_ && valid_actions_cache_->empty())
|
219
218
|
{
|
220
219
|
force_game_over("No valid actions available.");
|
221
|
-
// Log
|
222
|
-
std::cerr << "[GameStateCpp::get_valid_actions] Forced game over: No valid actions found after calculation." << std::endl;
|
220
|
+
// REMOVED C++ Log: std::cerr << "[GameStateCpp::get_valid_actions] Forced game over: No valid actions found after calculation." << std::endl;
|
223
221
|
}
|
224
222
|
return *valid_actions_cache_;
|
225
223
|
}
|
@@ -235,8 +233,7 @@ namespace trianglengin::cpp
|
|
235
233
|
if (game_over_)
|
236
234
|
{
|
237
235
|
valid_actions_cache_ = std::set<Action>();
|
238
|
-
//
|
239
|
-
std::cerr << "[GameStateCpp::calculate_valid_actions_internal] Game already over. Returning empty set." << std::endl;
|
236
|
+
// REMOVED C++ Log: std::cerr << "[GameStateCpp::calculate_valid_actions_internal] Game already over. Returning empty set." << std::endl;
|
240
237
|
return;
|
241
238
|
}
|
242
239
|
std::set<Action> valid_actions;
|
@@ -260,19 +257,15 @@ namespace trianglengin::cpp
|
|
260
257
|
valid_actions.insert(encode_action(shape_idx, r, c));
|
261
258
|
can_place_true_count++; // Increment counter
|
262
259
|
}
|
263
|
-
// Optional: Log failed attempts if needed for deep debugging
|
264
|
-
// else {
|
265
|
-
// std::cerr << "[Debug] can_place failed for shape " << shape_idx << " at (" << r << "," << c << ")" << std::endl;
|
266
|
-
// }
|
267
260
|
}
|
268
261
|
}
|
269
262
|
}
|
270
|
-
//
|
271
|
-
std::cerr << "[GameStateCpp::calculate_valid_actions_internal] Step: " << current_step_
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
263
|
+
// REMOVED C++ Log:
|
264
|
+
// std::cerr << "[GameStateCpp::calculate_valid_actions_internal] Step: " << current_step_
|
265
|
+
// << ", Attempts: " << attempts_count
|
266
|
+
// << ", CanPlaceTrue: " << can_place_true_count
|
267
|
+
// << ", ValidActionsFound: " << valid_actions.size()
|
268
|
+
// << std::endl;
|
276
269
|
|
277
270
|
// Use mutable cache
|
278
271
|
valid_actions_cache_ = std::move(valid_actions);
|
trianglengin/game_interface.py
CHANGED
@@ -8,6 +8,7 @@ import numpy as np
|
|
8
8
|
from .config import EnvConfig
|
9
9
|
|
10
10
|
try:
|
11
|
+
# Keep the alias for clarity within this file
|
11
12
|
import trianglengin.trianglengin_cpp as cpp_module
|
12
13
|
except ImportError as e:
|
13
14
|
raise ImportError(
|
@@ -127,6 +128,19 @@ class GameState:
|
|
127
128
|
# C++ returns double, cast might be redundant but safe for mypy
|
128
129
|
return cast("float", self._cpp_state.get_score())
|
129
130
|
|
131
|
+
def get_outcome(self) -> float:
|
132
|
+
"""
|
133
|
+
Returns the final outcome of the game if it's over, otherwise 0.0.
|
134
|
+
Required by MCTS implementations like trimcts.
|
135
|
+
"""
|
136
|
+
if self.is_over():
|
137
|
+
# In this game, the final score is the outcome.
|
138
|
+
# Adjust if a different outcome definition is needed (e.g., +1 win, -1 loss).
|
139
|
+
return self.game_score()
|
140
|
+
else:
|
141
|
+
# MCTS typically expects 0 for non-terminal states during simulation.
|
142
|
+
return 0.0
|
143
|
+
|
130
144
|
def valid_actions(self, force_recalculate: bool = False) -> set[int]:
|
131
145
|
"""
|
132
146
|
Returns a set of valid encoded action indices for the current state.
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: trianglengin
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.4
|
4
4
|
Summary: High-performance C++/Python engine for a triangle puzzle game.
|
5
5
|
Author-email: "Luis Guilherme P. M." <lgpelin92@gmail.com>
|
6
6
|
License-Expression: MIT
|
@@ -40,7 +40,7 @@ Dynamic: license-file
|
|
40
40
|
[](https://opensource.org/licenses/MIT)
|
41
41
|
[](https://www.python.org/downloads/)
|
42
42
|
|
43
|
-
# Triangle Engine (`trianglengin`) v2
|
43
|
+
# Triangle Engine (`trianglengin`) v2.0.3
|
44
44
|
<img src="bitmap.png" alt="trianglengin logo" width="300"/>
|
45
45
|
|
46
46
|
**Version 2 introduces a high-performance C++ core for the game logic.**
|
@@ -78,7 +78,7 @@ The primary goal is to provide a self-contained, installable library with a high
|
|
78
78
|
|
79
79
|
```bash
|
80
80
|
# For standard use (once published or built):
|
81
|
-
pip install trianglengin
|
81
|
+
pip install trianglengin>=2.0.3
|
82
82
|
|
83
83
|
# Building from source (requires compiler and CMake):
|
84
84
|
git clone https://github.com/lguibr/trianglengin.git
|
@@ -233,7 +233,7 @@ trianglengin/
|
|
233
233
|
## Core Components (v2)
|
234
234
|
|
235
235
|
- **`trianglengin.cpp` (C++ Core)**: Implements the high-performance game logic (state, grid, shapes, rules). Not directly imported in Python.
|
236
|
-
- **`trianglengin.game_interface.GameState` (Python Wrapper)**: The primary Python class for interacting with the game engine. It holds a reference to the C++ game state object and provides methods like `step`, `reset`, `is_over`, `valid_actions`, `get_shapes`, `get_grid_data_np
|
236
|
+
- **`trianglengin.game_interface.GameState` (Python Wrapper)**: The primary Python class for interacting with the game engine. It holds a reference to the C++ game state object and provides methods like `step`, `reset`, `is_over`, `valid_actions`, `get_shapes`, `get_grid_data_np`, **`get_outcome`**.
|
237
237
|
- **`trianglengin.config.EnvConfig`**: Python Pydantic model for core environment configuration. Passed to C++ core during initialization.
|
238
238
|
- **`trianglengin.utils`**: General Python utility functions and types. ([`src/trianglengin/utils/README.md`](src/trianglengin/utils/README.md))
|
239
239
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
trianglengin/__init__.py,sha256=VBYKMivxX19prPkxmSCSJJrjFXDVWkQJ9b5kQ6RzvkI,954
|
2
|
-
trianglengin/game_interface.py,sha256=
|
2
|
+
trianglengin/game_interface.py,sha256=7zvt61QGmAuagRfNMpRORhX11sy9NqWM9xWstsEawKY,9540
|
3
3
|
trianglengin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
trianglengin/trianglengin_cpp.cp310-win_amd64.pyd,sha256=
|
5
|
-
trianglengin/Release/trianglengin_cpp.cp39-win_amd64.pyd,sha256=
|
4
|
+
trianglengin/trianglengin_cpp.cp310-win_amd64.pyd,sha256=7do6v1uhFhoyb2ORthRMvChg4z79yJFU8hFr8kuvOHE,242688
|
5
|
+
trianglengin/Release/trianglengin_cpp.cp39-win_amd64.pyd,sha256=7do6v1uhFhoyb2ORthRMvChg4z79yJFU8hFr8kuvOHE,242688
|
6
6
|
trianglengin/config/README.md,sha256=zPN8ezwsN5fmH4xCsVSgOZwfyng_TwrCj3MlwEq63Y4,1544
|
7
7
|
trianglengin/config/__init__.py,sha256=sdr4D-pSCYmfXY2jOLEjPra2VewDiaWNwx1bWKp0nf8,168
|
8
8
|
trianglengin/config/display_config.py,sha256=ivZEGTCuUfmiVU6GJpVpEASFh30AAHSH42PIIi6bPZg,1862
|
@@ -11,7 +11,7 @@ trianglengin/core/__init__.py,sha256=LWZkoJctRGUhd5DZUJlPCS7usdQLZyKYkoyWUWO3L4o
|
|
11
11
|
trianglengin/cpp/CMakeLists.txt,sha256=vmhTQLRD7LRPbfFlisVVJ9-cCkeM3UMrikIde7TRLWc,1370
|
12
12
|
trianglengin/cpp/bindings.cpp,sha256=okdR2NCdxgP_FTgMjwXNbzcaFdERRrvy7m1eB_5FY8g,8899
|
13
13
|
trianglengin/cpp/config.h,sha256=rZZ6os70igGgA_fp-81fMv9TQMFJb91m6T-KeTOpKAU,742
|
14
|
-
trianglengin/cpp/game_state.cpp,sha256
|
14
|
+
trianglengin/cpp/game_state.cpp,sha256=-aHu2S6zlaXvR8boX8uDxTa9s1ZTwYxrug3NldPB1BM,12442
|
15
15
|
trianglengin/cpp/game_state.h,sha256=jR2dmulSr1uE0F0SivyrLf_sSQlgpikeZ44ZX_df-gY,2619
|
16
16
|
trianglengin/cpp/grid_data.cpp,sha256=IVhNc9zJFCSNRUJARDo_E3pPBAdh7pNBzF03_rZ1_QA,7142
|
17
17
|
trianglengin/cpp/grid_data.h,sha256=IhFXZc4ijLrRqUM1nKZ0gQsg-to1VS66wzao4VnPtp4,2531
|
@@ -51,9 +51,9 @@ trianglengin/ui/visualization/drawing/utils.py,sha256=gtGtt8bgaIvctFA5TEmKqmXNov
|
|
51
51
|
trianglengin/utils/__init__.py,sha256=pnFOkerF1TAz9oCzkNYBw6N56uENsyOiMZzA0cQ2SrA,185
|
52
52
|
trianglengin/utils/geometry.py,sha256=nrhr5C3MGO-_xXz96w1B0OJNaATLbc_AeZwoB_O6gsI,2128
|
53
53
|
trianglengin/utils/types.py,sha256=N_CjVJISvBP5QG1QYvepgORD0oNpMJlJRCJ9IdgjmWc,241
|
54
|
-
trianglengin-2.0.
|
55
|
-
trianglengin-2.0.
|
56
|
-
trianglengin-2.0.
|
57
|
-
trianglengin-2.0.
|
58
|
-
trianglengin-2.0.
|
59
|
-
trianglengin-2.0.
|
54
|
+
trianglengin-2.0.4.dist-info/licenses/LICENSE,sha256=DNjSCXzwafRxA5zjyWccoRXZTDMpTNElFpNVKz4NEpY,1098
|
55
|
+
trianglengin-2.0.4.dist-info/METADATA,sha256=Mm9gc4krrDA42SvPu0tfWlAMw6OwCwJaM-8bY3rYtIU,12316
|
56
|
+
trianglengin-2.0.4.dist-info/WHEEL,sha256=2SI2v6oeF8cXA_fO3HjdyTywO2Wxj6SOtX9BZdWd5hs,101
|
57
|
+
trianglengin-2.0.4.dist-info/entry_points.txt,sha256=kQEqO_U-MEpMEC0xwOPSucBzQIq2Ny7XwCtFSruZhvY,57
|
58
|
+
trianglengin-2.0.4.dist-info/top_level.txt,sha256=YsSWmp_2zM23wRc5TRERHpVCgQuVYieYHDTpnwVQC7Y,13
|
59
|
+
trianglengin-2.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|