2 main things: score counter and game simulator with names and scores #3
Open
Fabbernat wants to merge 57 commits into
Open
2 main things: score counter and game simulator with names and scores #3Fabbernat wants to merge 57 commits into
Fabbernat wants to merge 57 commits into
Conversation
Add Pillow dependency and update map_renderer.py imports
Add Pillow dependency and update map_renderer.py imports --- Index: polytopia_score_counter/rewards.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/polytopia_score_counter/rewards.py b/polytopia_score_counter/rewards.py --- a/polytopia_score_counter/rewards.py (revision 76cc9a7) +++ b/polytopia_score_counter/rewards.py (date 1736350762769) @@ -52,4 +52,7 @@ if action == "discover_fog": return 5 + if action == "park": + return 250 + return 0 # Default reward for neutral actions Index: polytopia_score_counter/actions.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/polytopia_score_counter/actions.py b/polytopia_score_counter/actions.py --- a/polytopia_score_counter/actions.py (revision 76cc9a7) +++ b/polytopia_score_counter/actions.py (date 1736351187218) @@ -11,5 +11,22 @@ "gain_territory", "lose_territory", "research_tech", - "discover_fog" + "discover_fog", + "park", +] + +_2D_ACTIONS = [ + {"action": "train_unit", "unit_type": "archer"}, + {"action": "lose_unit", "unit_type": "warrior"}, + {"action": "upgrade_city", "city_population_gain": 3}, + {"action": "place_structure", "structure": "monument"}, + {"action": "capture_city", "city_population_gain": 1}, + {"action": "lose_city", "city_population_loss": 2}, + {"action": "gain_territory"}, + {"action": "lose_territory"}, + {"action": "research_tech", "tech_tier": 1}, + {"action": "research_tech", "tech_tier": 2}, + {"action": "research_tech", "tech_tier": 3}, + {"action": "discover_fog"}, + {"action": "park"}, ] Index: main.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/main.py b/main.py --- a/main.py (revision 76cc9a7) +++ b/main.py (date 1736351187218) @@ -1,18 +1,20 @@ -# main.py - from polytopia_score_counter.rewards import calculate_reward -from polytopia_score_counter.actions import ACTIONS +from polytopia_score_counter.actions import _2D_ACTIONS + def main(): - # Test reward calculations - print("Reward for training an archer:", calculate_reward("train_unit", unit_type="archer")) - print("Reward for losing a warrior:", calculate_reward("lose_unit", unit_type="warrior")) - print("Reward for upgrading a city with 3 population gain:", calculate_reward("upgrade_city", city_population_gain=3)) - print("Reward for placing a monument:", calculate_reward("place_structure", structure="monument")) - print("Reward for researching a tier 2 technology:", calculate_reward("research_tech", tech_tier=2)) - print("Reward for discovering a fog tile:", calculate_reward("discover_fog")) - print("Reward for gaining a territory tile:", calculate_reward("gain_territory")) - print("Reward for losing a city with 2 population:", calculate_reward("lose_city", city_population_loss=2)) + score = 0 + + # Loop through each action and calculate the reward + for action_info in _2D_ACTIONS: + action = action_info["action"] + # Call calculate_reward dynamically with the appropriate arguments + reward = calculate_reward(action, **{key: value for key, value in action_info.items() if key != "action"}) + score += reward + print(f"Reward for {action}: {reward}") + + print(f'Total score: {score}') + if __name__ == "__main__": main()
…um support - Converted GameMode to an Enum for consistency with MapSizes and MapTypes, allowing the use of .name attributes. - Updated Settings to ensure GAME_MODE and MAP_SIZE are compatible with .name-based access. - Enhanced the un_game.py script to handle map_settings dynamically using .name for Enum members and raw values where appropriate. - Fixed the ModuleNotFoundError by addressing Python package structure and import paths in the polytopia_game module. This refactor improves readability, robustness, and consistency across game settings.
- Ensured that the `self.players` list is properly initialized with player names. - Corrected the issue where `player_scores` was not populated due to an empty `self.players` list. - Added a check to verify that `self.players` contains valid player names before assigning scores. - Ensured that player names are shuffled and linked to the players correctly for dynamic gameplay. - Improved the readability and robustness of the `run()` method by ensuring proper initialization and shuffling logic. This resolves the issue where `player_scores` was not populated, leading to empty results in the game run.
Owner
|
Hello! It's really cool to see that you saw some value in this project and wanted to contribute 😄 |
…Where to put the Views, models, controllers? WHeret to put static files like css and img? Is there a wwwroot or static or templates folder?
- Set up a Flask app to serve web pages. - Added routes for: - Home (`/`) - Privacy (`/privacy`) - Dashboard (`/dashboard`) - About (`/about`) - Settings (`/settings`) - Hall of Fame (`/hall_of_fame`) - Throne Room (`/throne_room`) - Created navigation between pages to enable smooth browsing. - Implemented basic HTML responses to test routing functionality. This commit lays the foundation for serving dynamic content and creating a user-friendly web interface.
- Add `vegallapot(n)`: Checks if the game has reached a terminal state. - Add `hasznossag(n)`: Evaluates game states based on city and unit count. - Add `n_szomszedai(n)`: Generates possible next states for the current player. - Basic mechanics include unit training and attacking. - Lays groundwork for reinforcement learning integration.
… newly created games
…xt, no errors or exeptions thrown in this version
Updated README to reflect changes in contributions and added information about the Java console app.
…sole app as well, so pretty good so far
… still needs to be fixed
…spawn. It does not always work, but it gives decent results when succeeds
…ail to generate with this algorithm
…e loop, fix that. Then, add shallow water, ruins and valid village spawns
…WW runs into infinite loop, fix that. Then, add shallow water, ruins and valid village spawns
…n any more on ocean. Mountains do. This patch increased forest spawn rate.
…flow now seamlessly integrates with the console app. Both apps can be controlled from console now. Also extracted a lot of repetitive code into methods. So overall the code quality is much better too.
Big improvements on the desktop app. The desktop app's control flow now seamlessly integrates with the console app. Both apps can be controlled from console now. Also extracted a lot of repetitive code into methods. So overall the code quality is much better too.
Updated links to point to the correct frontend repository.
…s, Lakes, Continents, and Archipelagos. Added images and descriptions for various map types including Drylands, Lakes, Continents, and Archipelagos. Updated contributions section with details on terrain generation and score counter modules.
Updated README.md with additional map types and contributions.
Updated descriptions for various map types and added insights.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor Settings and GameMode handling for better consistency and Enum support
un_game.py script to handle map_settings dynamically using .name for Enum members and raw values where appropriate.
This refactor improves readability, robustness, and consistency across game settings.
Fix: Properly initialize and populate players in the game
self.playerslist is properly initialized with player names.player_scoreswas not populated due to an emptyself.playerslist.self.playerscontains valid player names before assigning scores.run()method by ensuring proper initialization and shuffling logic.This resolves the issue where
player_scoreswas not populated, leading to empty results in the game run.