Skip to content

feat: Planets affect recruit corruption and it's gaussian random#477

Merged
EttyKitty merged 3 commits intoAdeptus-Dominus:mainfrom
EttyKitty:feat/recruit-corruption
Feb 18, 2025
Merged

feat: Planets affect recruit corruption and it's gaussian random#477
EttyKitty merged 3 commits intoAdeptus-Dominus:mainfrom
EttyKitty:feat/recruit-corruption

Conversation

@EttyKitty
Copy link
Copy Markdown
Collaborator

@EttyKitty EttyKitty commented Feb 9, 2025

Description of changes

  • Add find_recruit_corruption(planet_type) function, similar to find_recruit_success_chance(). This thing returns the corruption value of a recruit, based on the selected trial and their source planet type, passed through a Gaussian distribution.
  • Remove planet types from corruption bonuses in trials, and move them to the above function (so that they are independent of trials).
  • Change trial corruption bonus to the [base, sd] format, for Gaussian distribution in find_recruit_corruption().
  • Add a small corruption bonus to "Survival of the Fittest" (I think it fits?) and "Combat Challenge"; and a small malus to "Knowledge of self" and "Shrine" planets. (for detailed changes, see the file itself)

Reasons for changes

  • I love Gaussian distribution and I don't love static numbers or flat distribution.
  • I don't think that corruption bonus from the planet should directly depend on the trial.
  • I do think that planets giving base corruption makes more sense than 10 base corruption (as it was originally).

Notes

  • The base/SD numbers of corruption on planet types/trials may need to be adjusted.
  • Some way of telling the player about planet type bonuses/maluses would be good, but that's a problem with the recruiting chance as well (I think).
  • How to show expected corruption values on the trial preview, if Gaussian distribution heavily influences them?

Related links

How have you tested your changes?

  • Compile
  • New game
  • Next turn
  • Space Travel
  • Ground Battle

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 9, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new recruitment corruption logic that leverages a Gaussian distribution for calculating the corruption value. The changes refactor how corruption bonuses are handled: they are now determined independently from trials by combining a planet-specific bonus and a trial-specific bonus, both defined in [base, sd] format. The new find_recruit_corruption() function computes the corruption value by sampling from a Gaussian function and then aggregates these results to produce a final, positive corruption amount.

File-Level Changes

Change Details Files
Implemented find_recruit_corruption() function using Gaussian distribution.
  • Created a new function that calculates recruit corruption based on planet type and associated corruption bonus parameters.
  • Defined a planet types data structure mapping each planet type to a corruption bonus described as [base, standard deviation].
  • Aggregated corruption values by applying a Gaussian function to the bonus and ensuring the final corruption value is non-negative.
scripts/scr_recruit_data/scr_recruit_data.gml
Updated recruitment process to use the new corruption function.
  • Replaced static corruption value with a dynamic value generated by find_recruit_corruption().
  • Added a debug message to log the newly computed corruption value.
scripts/scr_recruit_data/scr_recruit_data.gml
Refactored trial configurations for corruption bonus computations.
  • Changed trial corruption bonus properties from using a nested structure to using a simple corruption_bonus field in [base, sd] format.
  • Updated various trial definitions to incorporate these new corruption bonus values.
  • Modified the display logic for corruption effects to reflect the updated bonus values.
scripts/scr_recruit_data/scr_recruit_data.gml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the Type: Feature Adds something new label Feb 9, 2025
@EttyKitty EttyKitty requested a review from OH296 February 9, 2025 22:33
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @EttyKitty - I've reviewed your changes - here's some feedback:

Overall Comments:

  • In function find_recruit_corruption, in the trial bonus block, the check using _planet_type_data seems misplaced; change it to check _trial_type for a corruption_bonus to avoid unintended behavior.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@EttyKitty
Copy link
Copy Markdown
Collaborator Author

@sourcery-ai review

@EttyKitty EttyKitty changed the title feat: Planets affect new recruit corruption and gaussian random feat: Planets affect recruit corruption and it's gaussian random Feb 10, 2025
Copy link
Copy Markdown
Collaborator

@Blogaugis Blogaugis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit concerned that SD for gaussian distribution of 2 is a bit much, if my fiddling around with these values in the SM stats doc (especially if it comes to numbers low as that) is to go by. I think value of 1 might be better.
But otherwise, I guess it is alright.

Copy link
Copy Markdown
Collaborator

@OH296 OH296 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye this is cool

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Feb 13, 2025

@EttyKitty Let us know on suggestions and if you deem this ready to merge?

Co-authored-by: Nelsonh <81228864+OH296@users.noreply.github.com>
@EttyKitty
Copy link
Copy Markdown
Collaborator Author

Let us know on suggestions and if you deem this ready to merge?

It's okay to merge, if it looks okay from the side.
Possible issues may stem from stuff described in the PR notes section.

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Feb 16, 2025

Let us know on suggestions and if you deem this ready to merge?

It's okay to merge, if it looks okay from the side. Possible issues may stem from stuff described in the PR notes section.

@OH296 OH296 closed this Feb 16, 2025
@OH296 OH296 reopened this Feb 16, 2025
@OH296 OH296 mentioned this pull request Feb 16, 2025
5 tasks
@EttyKitty
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 17, 2025

📝 Walkthrough

Walkthrough

The changes introduce a new function that computes a recruitment trial corruption value based on the planet type. This function retrieves planet-specific corruption bonuses using a static data structure and applies a Gaussian distribution to calculate the corruption, ensuring the final value is non-negative. The existing recruitment logic now calls this function instead of using a fixed corruption value. Additionally, the trial data structure has been updated by replacing the previous corruption structure with a new array that holds the base corruption and its standard deviation. This modification affects multiple trial types, standardizing the way corruption values are represented and calculated across different recruitment scenarios.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
scripts/scr_recruit_data/scr_recruit_data.gml (3)

64-122: Add input validation and documentation.

The function implementation looks good but could benefit from:

  1. Input parameter validation
  2. Documentation explaining the purpose, parameters, and return value

Apply this diff to add validation and documentation:

+/// Calculates the corruption value for a recruit based on planet type and trial type.
+/// @param {string} planet_type - The type of planet (e.g., "Hive", "Temperate", etc.)
+/// @returns {number} The calculated corruption value, minimum 0
 function find_recruit_corruption(planet_type){
+    if (!is_string(planet_type)) {
+        show_error("planet_type must be a string", true);
+    }
     var _recruit_corruption = 0;

67-99: Consider differentiating planet type corruption values.

Several planet types (Forge, Desert, Ice, Agri, Death, Lava) share identical corruption bonus values [5, 2]. Consider differentiating these based on their unique characteristics to add more variety to the gameplay.


493-502: Clean up commented code or add TODO.

The commented code block suggests a potential feature for planet-specific corruption bonuses in trials. Either:

  1. Remove the commented code if the feature is not planned
  2. Add a TODO comment explaining the future feature plan
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7038ad4 and 94a8b9c.

📒 Files selected for processing (1)
  • scripts/scr_recruit_data/scr_recruit_data.gml (8 hunks)
🔇 Additional comments (3)
scripts/scr_recruit_data/scr_recruit_data.gml (3)

144-144: Gate debug message in production code.

The debug message should be gated to prevent it from appearing in production.


251-374: Review standard deviation values for balance.

The standard deviation values are consistently set to:

  • 2 for planet types
  • 1 for trials

Consider if these values provide enough variability for an engaging gameplay experience. You might want to adjust these based on testing results.


64-502: Implementation aligns well with PR objectives!

The changes successfully:

  1. Implement Gaussian distribution for corruption calculation
  2. Separate planet type corruption from trial corruption
  3. Update the data structures and UI to support the new system

@EttyKitty EttyKitty merged commit d419496 into Adeptus-Dominus:main Feb 18, 2025
@EttyKitty EttyKitty deleted the feat/recruit-corruption branch March 10, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature Adds something new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants