Skip to content

Dev#5

Merged
remi-bezot merged 9 commits intomainfrom
dev
Nov 25, 2025
Merged

Dev#5
remi-bezot merged 9 commits intomainfrom
dev

Conversation

@remi-bezot
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings November 25, 2025 14:43
@remi-bezot remi-bezot merged commit c79e4ce into main Nov 25, 2025
3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR merges development work that adds a nutrient system to the 3D voxel world simulation, enhances the biology module with population merging and nutrient-based growth limits, and introduces CI/CD workflows for automated releases. The changes bump the version from 0.1.0 to 0.2.0.

Key Changes:

  • Added a nutrients field to the Voxel struct with default values for different materials (soil: 10.0, water: 5.0)
  • Implemented nutrient consumption and carrying capacity mechanics in the biology simulation
  • Added population merging logic to consolidate populations at the same location
  • Introduced GitHub Actions workflows for automated stable and beta releases

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/world3d.rs Added nutrients field to Voxel struct and updated all constructor methods to initialize nutrients with material-specific defaults
src/biology.rs Implemented population merging, nutrient-based carrying capacity, nutrient consumption mechanics, and increased minimum migration threshold from 0 to 10
Cargo.toml Version bump from 0.1.0 to 0.2.0
Cargo.lock Updated version to match Cargo.toml
CHANGELOG.md Added changelog entries documenting the new features and improvements in version 0.2.0
.github/workflows/release-stable.yml New workflow for automatic stable releases on pushes to main branch
.github/workflows/release-beta.yml New workflow for automatic beta releases on pushes to dev branch

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

pub material: VoxelMaterial,
pub temperature: f32,
pub density: f32,
pub nutrients: f32, // Ajout des nutriments
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

These comments are in French, but the codebase uses English for all other documentation and comments (e.g., in main.rs and existing world3d.rs comments). For consistency and broader accessibility, please translate these to English. For example: "Ajout des nutriments" → "Addition of nutrients".

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +45
Self::new(VoxelMaterial::Soil, 18.0, 1.2, 10.0) // Ajout de nutriments par défaut pour le sol
}

pub fn water() -> Self {
Self::new(VoxelMaterial::Water, 10.0, 1.0)
Self::new(VoxelMaterial::Water, 10.0, 1.0, 5.0) // Ajout de nutriments par défaut pour l'eau
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

These comments are in French, but the codebase uses English for all other documentation and comments. For consistency and broader accessibility, please translate these to English. For example: "Ajout de nutriments par défaut pour le sol" → "Default nutrients for soil".

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +80
// Fusionner les populations proches sur le même voxel
let mut population_map = std::collections::HashMap::new();

// Ajouter les populations existantes au map
for pop in populations.iter() {
let key = (pop.x, pop.y, pop.z, pop.species_id);
population_map
.entry(key)
.and_modify(|existing_size| *existing_size += pop.size)
.or_insert(pop.size);
}

// Ajouter les nouvelles populations au map
for pop in new_populations.iter() {
let key = (pop.x, pop.y, pop.z, pop.species_id);
population_map
.entry(key)
.and_modify(|existing_size| *existing_size += pop.size)
.or_insert(pop.size);
}

// Reconstruire la liste des populations
populations.clear();
for ((x, y, z, species_id), size) in population_map {
populations.push(Population::new(species_id, x, y, z, size));
}
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The population merging logic at the beginning of the function clears the original populations vector (line 77) and rebuilds it from the HashMap. However, this happens before the retain_mut closure processes populations. This means all populations are being reset before any simulation logic runs, which likely breaks the intended flow. The merging logic should either:

  1. Run after the retain_mut closure to merge newly created populations with existing ones, or
  2. Be restructured to preserve the simulation state correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +79
- name: Create GitHub Beta Release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.beta.outputs.new_beta_tag }}
release_name: Beta ${{ steps.beta.outputs.new_beta_tag }}
body: |
Beta build from dev.
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} No newline at end of file
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The actions/create-release@v1 action is deprecated and no longer maintained. GitHub recommends migrating to the newer softprops/action-gh-release or using the GitHub CLI (gh release create). The deprecated action may stop working in the future.

Copilot uses AI. Check for mistakes.
&& new_z < world.depth as i32
{
// Diviser la population : une partie reste, l'autre se déplace
let moving_size = pop.size / 2;
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

Changing the population movement threshold from > 0 to > 10 prevents small populations from migrating. This is a significant behavioral change that should be documented in the changelog or explained with a comment, as it affects the simulation dynamics and may prevent small populations from colonizing new areas.

Suggested change
let moving_size = pop.size / 2;
let moving_size = pop.size / 2;
// Only allow migration if the moving population is greater than 10.
// This threshold prevents small populations from migrating, which may
// affect the ability of small populations to colonize new areas and
// changes the simulation dynamics. Adjust with care.

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +74
// Ajouter les nouvelles populations au map
for pop in new_populations.iter() {
let key = (pop.x, pop.y, pop.z, pop.species_id);
population_map
.entry(key)
.and_modify(|existing_size| *existing_size += pop.size)
.or_insert(pop.size);
}
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The new_populations vector is empty at this point (initialized on line 53), so this loop iterating over it will never execute. This code should be moved to after the retain_mut closure (before line 188) where new_populations is actually populated with new entries. The current placement makes the population merging logic ineffective for newly created populations.

Copilot uses AI. Check for mistakes.
Comment on lines +157 to +163
if new_x >= 0
&& new_y >= 0
&& new_z >= 0
&& new_x < world.width as i32
&& new_y < world.height as i32
&& new_z < world.depth as i32
{
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

This validation logic duplicates the existing is_valid method available on World3D. Consider using world.is_valid(new_x, new_y, new_z) instead of this manual check for consistency and maintainability.

Suggested change
if new_x >= 0
&& new_y >= 0
&& new_z >= 0
&& new_x < world.width as i32
&& new_y < world.height as i32
&& new_z < world.depth as i32
{
if world.is_valid(new_x, new_y, new_z) {

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +76
uses: actions/create-release@v1
with:
tag_name: ${{ steps.version.outputs.new_tag }}
release_name: Release ${{ steps.version.outputs.new_tag }}
body: |
Stable release ${{ steps.version.outputs.new_tag }}.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} No newline at end of file
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The actions/create-release@v1 action is deprecated and no longer maintained. GitHub recommends migrating to the newer softprops/action-gh-release or using the GitHub CLI (gh release create). The deprecated action may stop working in the future.

Suggested change
uses: actions/create-release@v1
with:
tag_name: ${{ steps.version.outputs.new_tag }}
release_name: Release ${{ steps.version.outputs.new_tag }}
body: |
Stable release ${{ steps.version.outputs.new_tag }}.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.new_tag }}
name: Release ${{ steps.version.outputs.new_tag }}
body: |
Stable release ${{ steps.version.outputs.new_tag }}.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Copilot uses AI. Check for mistakes.
) {
let mut rng = rand::thread_rng();
let mut new_populations = Vec::new();
let mut new_populations: Vec<Population> = Vec::new();
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The explicit type annotation : Vec<Population> is redundant here since the type can be inferred from Vec::new(). Rust's type inference makes this unnecessary unless there's ambiguity.

Suggested change
let mut new_populations: Vec<Population> = Vec::new();
let mut new_populations = Vec::new();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants