Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noise: add simplex noise #207

Merged
merged 11 commits into from
Aug 5, 2024
Merged

Conversation

PottierLoic
Copy link
Contributor

@PottierLoic PottierLoic commented Jul 3, 2024

This PR add an implementation of Simplex Noise #206

For now there is only the 2d implementation, I will add the remaining ones/tests/comments in the coming days.
It will work the same as perlin noise: a generator struct holds the permutation table, which can be randomized.

I would like to rename the "Perlin" generator struct to a more general name so we can use it for both Perlin and Simplex noise (they both use the same permutation table) if there is no issue doing it ?

Summary by CodeRabbit

  • New Features

    • Introduced simplex noise generation capabilities in 2D, 3D, and 4D spaces.
    • Added tests for simplex noise generation in multiple dimensions.
    • Added example module to visualize 2D Simplex noise using a heatmap.
    • Introduced example project showcasing 2D fractal noise generation and visualization.
  • Improvements

    • Enhanced Perlin noise generation by refactoring to use a Generator for permutation tables.
    • Improved naming consistency and code readability in noise generation functions and tests.

Copy link

coderabbitai bot commented Jul 3, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes enhance noise generation capabilities by introducing a module for simplex noise across 1D, 2D, 3D, and 4D spaces. Additionally, the Perlin noise functions have been refined to utilize a new Generator struct, improving the noise generation logic and updating the corresponding test files for accuracy and consistency.

Changes

File Summary
noise/simplex.v New module for simplex noise generation in 1D, 2D, 3D, and 4D space with functions for each respective dimension.
noise/noise.v Introduces Generator struct for handling permutation tables used in noise generation.
noise/perlin2d.v, noise/perlin3d.v Updates Perlin noise functions to use Generator instead of Perlin, modifying logic accordingly.
noise/perlin2d_test.v, noise/perlin3d_test.v Adjusts tests to reflect the usage of Generator in Perlin noise generation.
noise/simplex_test.v New tests for simplex noise generation in multiple dimensions.
examples/noise_simplex_2d/README.md New README introducing an example for generating simplex noise with usage instructions.
examples/noise_simplex_2d/main.v New module that visualizes 2D simplex noise using a noise generator, including plotting functionality.
examples/noise_fractal_2d/README.md New README for an example project showcasing pink noise generation.
examples/noise_fractal_2d/main.v New module for generating and visualizing 2D fractal noise using the Simplex noise algorithm.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NoiseModule
    participant Generator

    User ->> NoiseModule: Call simplex_2d(x, y)
    NoiseModule ->> Generator: Create or use existing Generator
    Generator -->> NoiseModule: Permutation table
    NoiseModule -->> User: Return simplex noise value
Loading
sequenceDiagram
    participant User
    participant NoiseModule
    participant Generator

    User ->> NoiseModule: Call perlin2d(x, y)
    NoiseModule ->> Generator: Use Generator for permutation
    Generator -->> NoiseModule: Permutation table
    NoiseModule -->> User: Return Perlin noise value
Loading

Poem

In the realm of code, where numbers dance,
Simplex noise now takes its stance.
With new dimensions, it will create,
Patterns that will fascinate.
Generators now lead the way,
For Perlin's charm to still hold sway.
🎵✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7fd1d43 and dc7e687.

Files selected for processing (1)
  • noise/simplex.v (1 hunks)
Additional comments not posted (2)
noise/simplex.v (2)

5-5: Constants are correct.

The constants f2 and g2 are defined correctly for skewing and unskewing the input space in the Simplex Noise algorithm.


8-8: Gradient calculation function is correct.

The grad_2d function correctly calculates the dot product of a pseudorandom gradient vector and the distance vector based on the hash value.

noise/simplex.v Outdated
})
}

pub fn simplex_2d(x f64, y f64) f64 {
Copy link

Choose a reason for hiding this comment

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

Main Simplex Noise function is correct but can be improved.

The simplex_2d function correctly implements the 2D Simplex Noise algorithm. However, some improvements can be suggested for readability and performance.

Refactor suggestion: Use descriptive variable names.

Using more descriptive variable names can improve readability. For example, i1 and j1 could be renamed to offset_x and offset_y.

Refactor suggestion: Inline small calculations.

Inlining small calculations, such as f2 and g2, can improve performance by reducing the number of operations.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dc7e687 and cb9f649.

Files selected for processing (1)
  • noise/simplex.v (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • noise/simplex.v

@PottierLoic
Copy link
Contributor Author

PottierLoic commented Jul 4, 2024

I would like to visualize the 4d simplex in plot by gradually increasing the 4th parameter so te whole 3d noise will be "moving").
Is it possible ?
This would be a great example to add too

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cb9f649 and 88a9e48.

Files selected for processing (1)
  • noise/simplex.v (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • noise/simplex.v

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 88a9e48 and b0d2484.

Files selected for processing (1)
  • noise/simplex.v (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • noise/simplex.v

@PottierLoic
Copy link
Contributor Author

PottierLoic commented Jul 7, 2024

All of the dimensions are implemented.

Here is the 3d version using plot module :
image

And a 4d visualization:
ezgif-6-cda400ad2c

Maybe I can add the 3d plot as an example in example/noise ?
If anything can be enhanced tell me, I'll add tests soon

@medvednikov
Copy link
Member

@ulises-jeremias can you have a look please?

Copy link

@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

Outside diff range and nitpick comments (2)
noise/perlin2d.v (1)

Line range hint 4-20:
Ensure the permutation index is within bounds.

The access to the generator.perm array doesn't handle out-of-bound indices, which could lead to runtime errors.

-	pxi := generator.perm[xi]
-	pxi1 := generator.perm[xi + 1]
-	aa := generator.perm[pxi + yi]
-	ab := generator.perm[pxi + yi + 1]
-	ba := generator.perm[pxi1 + yi]
-	bb := generator.perm[pxi1 + yi + 1]
+	pxi := generator.perm[xi % generator.perm.len]
+	pxi1 := generator.perm[(xi + 1) % generator.perm.len]
+	aa := generator.perm[(pxi + yi) % generator.perm.len]
+	ab := generator.perm[(pxi + yi + 1) % generator.perm.len]
+	ba := generator.perm[(pxi1 + yi) % generator.perm.len]
+	bb := generator.perm[(pxi1 + yi + 1) % generator.perm.len]
noise/perlin3d.v (1)

Line range hint 4-29:
Ensure the permutation index is within bounds.

The access to the generator.perm array doesn't handle out-of-bound indices, which could lead to runtime errors.

-	pxi := generator.perm[xi]
-	pxi_yi := generator.perm[pxi + yi]
-	pxi_yi1 := generator.perm[pxi + yi + 1]
-	pxi1 := generator.perm[xi + 1]
-	pxi1_yi := generator.perm[pxi1 + yi]
-	pxi1_yi1 := generator.perm[pxi1 + yi + 1]
-	aaa := generator.perm[pxi_yi + zi]
-	aba := generator.perm[pxi_yi1 + zi]
-	aab := generator.perm[pxi_yi + zi + 1]
-	abb := generator.perm[pxi_yi1 + zi + 1]
-	baa := generator.perm[pxi1_yi + zi]
-	bba := generator.perm[pxi1_yi1 + zi]
-	bab := generator.perm[pxi1_yi + zi + 1]
-	bbb := generator.perm[pxi1_yi1 + zi + 1]
+	pxi := generator.perm[xi % generator.perm.len]
+	pxi_yi := generator.perm[(pxi + yi) % generator.perm.len]
+	pxi_yi1 := generator.perm[(pxi + yi + 1) % generator.perm.len]
+	pxi1 := generator.perm[(xi + 1) % generator.perm.len]
+	pxi1_yi := generator.perm[(pxi1 + yi) % generator.perm.len]
+	pxi1_yi1 := generator.perm[(pxi1 + yi + 1) % generator.perm.len]
+	aaa := generator.perm[(pxi_yi + zi) % generator.perm.len]
+	aba := generator.perm[(pxi_yi1 + zi) % generator.perm.len]
+	aab := generator.perm[(pxi_yi + zi + 1) % generator.perm.len]
+	abb := generator.perm[(pxi_yi1 + zi + 1) % generator.perm.len]
+	baa := generator.perm[(pxi1_yi + zi) % generator.perm.len]
+	bba := generator.perm[(pxi1_yi1 + zi) % generator.perm.len]
+	bab := generator.perm[(pxi1_yi + zi + 1) % generator.perm.len]
+	bbb := generator.perm[(pxi1_yi1 + zi + 1) % generator.perm.len]
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b0d2484 and 3f64daa.

Files selected for processing (7)
  • noise/noise.v (1 hunks)
  • noise/perlin2d.v (2 hunks)
  • noise/perlin2d_test.v (1 hunks)
  • noise/perlin3d.v (2 hunks)
  • noise/perlin3d_test.v (1 hunks)
  • noise/simplex.v (1 hunks)
  • noise/simplex_test.v (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • noise/simplex.v
Additional comments not posted (13)
noise/perlin2d_test.v (1)

9-12: LGTM! Verify the consistency of the perlin2d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the perlin2d function with a tolerance check.

Ensure that the perlin2d function in noise/perlin2d.v is consistent with the expected output.

Verification successful

The perlin2d function implementation appears consistent and well-defined.

The function correctly calculates Perlin noise values based on the given coordinates. The test in noise/perlin2d_test.v should effectively validate this implementation.

  • noise/perlin2d.v:
    • The perlin2d function is implemented correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `perlin2d` function in `noise/perlin2d.v` is consistent with the expected output.

# Test: Search for the `perlin2d` function.
ast-grep --lang v --pattern $'fn (generator Generator) perlin2d($_, $_) $_' noise/perlin2d.v

Length of output: 196


Script:

#!/bin/bash
# Description: Verify the `perlin2d` function in `noise/perlin2d.v` is consistent with the expected output.

# Test: Search for the `perlin2d` function definition.
rg 'fn (generator Generator) perlin2d' noise/perlin2d.v

Length of output: 57


Script:

#!/bin/bash
# Description: Verify the `perlin2d` function is consistent with the expected output.

# Test: Search for the `perlin2d` function definition across the entire repository.
rg 'fn (generator Generator) perlin2d'

Length of output: 40


Script:

#!/bin/bash
# Description: Verify any function related to Perlin noise is consistent with the expected output.

# Test: Search for any function definitions containing "perlin" in their names across the entire repository.
rg 'fn .*perlin.*'

Length of output: 263


Script:

#!/bin/bash
# Description: Extract the implementation of the `perlin2d` function from `noise/perlin2d.v`.

# Extract the function implementation.
sed -n '/fn (generator Generator) perlin2d/,/}/p' noise/perlin2d.v

Length of output: 599

noise/perlin3d_test.v (1)

9-12: LGTM! Verify the consistency of the perlin3d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the perlin3d function with a tolerance check.

Ensure that the perlin3d function in noise/perlin3d.v is consistent with the expected output.

Verification successful

The perlin3d function implementation in noise/perlin3d.v is consistent with the expected output.

  • The function calculates the Perlin noise value for the given 3D coordinates using linear interpolation and gradient functions.
  • The implementation appears to be correct and follows the standard Perlin noise algorithm.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `perlin3d` function in `noise/perlin3d.v` is consistent with the expected output.

# Test: Search for the `perlin3d` function.
ast-grep --lang v --pattern $'fn (generator Generator) perlin3d($_, $_, $_) $_' noise/perlin3d.v

Length of output: 200


Script:

#!/bin/bash
# Description: Verify the `perlin3d` function in `noise/perlin3d.v` is consistent with the expected output.

# Test: Search for the `perlin3d` function definition.
rg 'fn (generator Generator) perlin3d' noise/perlin3d.v

Length of output: 57


Script:

#!/bin/bash
# Description: Verify the `perlin3d` function in the `noise` directory is consistent with the expected output.

# Test: Search for all function definitions in the `noise` directory.
rg 'fn ' noise/

Length of output: 1317


Script:

#!/bin/bash
# Description: Extract the implementation of the `perlin3d` function from `noise/perlin3d.v`.

# Extract the `perlin3d` function implementation.
rg -A 20 'pub fn (generator Generator) perlin3d' noise/perlin3d.v

Length of output: 67


Script:

#!/bin/bash
# Description: Extract the implementation of the `perlin3d` function from `noise/perlin3d.v`.

# Extract the `perlin3d` function implementation using `sed`.
sed -n '/pub fn (generator Generator) perlin3d/,/}/p' noise/perlin3d.v

Length of output: 1228

noise/noise.v (3)

5-9: LGTM!

The Generator struct is correctly defined and the permutation table is properly initialized.


11-14: LGTM!

The new method correctly returns a new Generator struct.


16-20: LGTM!

The randomize method correctly shuffles the permutation set inside the Generator struct.

noise/simplex_test.v (4)

33-39: LGTM! Verify the consistency of the simplex_4d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the simplex_4d function with a tolerance check.

Ensure that the simplex_4d function in noise/simplex.v is consistent with the expected output.


24-30: LGTM! Verify the consistency of the simplex_3d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the simplex_3d function with a tolerance check.

Ensure that the simplex_3d function in noise/simplex.v is consistent with the expected output.


6-12: LGTM! Verify the consistency of the simplex_1d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the simplex_1d function with a tolerance check.

Ensure that the simplex_1d function in noise/simplex.v is consistent with the expected output.

Verification successful

LGTM! Verify the consistency of the simplex_1d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the simplex_1d function with a tolerance check. The simplex_1d function is defined in noise/simplex.v.

  • noise/simplex.v: pub fn (generator Generator) simplex_1d(x f64) f64
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `simplex_1d` function in `noise/simplex.v` is consistent with the expected output.

# Test: Search for the `simplex_1d` function.
ast-grep --lang v --pattern $'fn (generator Generator) simplex_1d($_) $_' noise/simplex.v

Length of output: 193


Script:

#!/bin/bash
# Description: Verify the `simplex_1d` function in `noise/simplex.v` is consistent with the expected output.

# Test: Search for the `simplex_1d` function using ripgrep.
rg 'fn (generator Generator) simplex_1d' noise/simplex.v

Length of output: 58


Script:

#!/bin/bash
# Description: Verify the `simplex_1d` function is present and consistent with the expected output.

# Test: Search for the `simplex_1d` function across the entire codebase.
rg 'fn (generator Generator) simplex_1d'

Length of output: 42


Script:

#!/bin/bash
# Description: Verify the presence of any `simplex` related functions.

# Test: Search for any functions related to `simplex` across the entire codebase.
rg 'fn .*simplex.*'

Length of output: 515


15-21: LGTM! Verify the consistency of the simplex_2d function.

The test correctly seeds the random number generator, creates a new Generator, randomizes it, and tests the simplex_2d function with a tolerance check.

Ensure that the simplex_2d function in noise/simplex.v is consistent with the expected output.

Verification successful

The simplex_2d function is consistent with the expected output.

The function implementation correctly follows the 2D simplex noise algorithm, and the test in simplex_test.v verifies its behavior with appropriate seeding, randomization, and tolerance checks.

  • noise/simplex.v, lines 107-167: Implementation of simplex_2d function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `simplex_2d` function in `noise/simplex.v` is consistent with the expected output.

# Test: Search for the `simplex_2d` function.
ast-grep --lang v --pattern $'fn (generator Generator) simplex_2d($_, $_) $_' noise/simplex.v

Length of output: 197


Script:

#!/bin/bash
# Description: Verify the `simplex_2d` function in `noise/simplex.v` is consistent with the expected output.

# Test: Search for the `simplex_2d` function definition in the codebase.
rg 'fn \(generator Generator\) simplex_2d' --vimgrep

Length of output: 136


Script:

#!/bin/bash
# Description: Extract the `simplex_2d` function implementation from `noise/simplex.v`.

# Extract the `simplex_2d` function implementation.
sed -n '107,127p' noise/simplex.v

Length of output: 490


Script:

#!/bin/bash
# Description: Extract the complete `simplex_2d` function implementation from `noise/simplex.v`.

# Extract the `simplex_2d` function implementation.
sed -n '107,147p' noise/simplex.v

Length of output: 886


Script:

#!/bin/bash
# Description: Extract the complete `simplex_2d` function implementation from `noise/simplex.v`.

# Extract the `simplex_2d` function implementation.
sed -n '107,167p' noise/simplex.v

Length of output: 1273

noise/perlin2d.v (3)

Line range hint 24-26:
LGTM!

The fade function is correctly implemented and optimized.


Line range hint 28-44:
LGTM!

The grad2d function is correctly implemented and covers all possible hash values.


Line range hint 48-50:
LGTM!

The lerp function is correctly implemented and optimized.

noise/perlin3d.v (1)

Line range hint 31-49:
LGTM!

The grad3d function is correctly implemented and covers all possible hash values.

@PottierLoic
Copy link
Contributor Author

I renamed the Perlin struct that was holding the permutation table to Generator as it is now used for simplex noise too.
Tests are done too and simplex noise can now be randomized the same way it is done with Perlin noise

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3f64daa and d6d226f.

Files selected for processing (1)
  • noise/simplex.v (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • noise/simplex.v

Copy link

@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

Outside diff range, codebase verification and nitpick comments (1)
examples/noise_simplex_2d/main.v (1)

37-37: Potential error handling improvement.

The plt.show() call uses the ! operator, which will panic if an error occurs. Consider handling the error more gracefully.

- plt.show()!
+ if err := plt.show() {
+   println('Error displaying plot: $err')
+   return
+ }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d6d226f and c8f94bf.

Files selected for processing (2)
  • examples/noise_simplex_2d/README.md (1 hunks)
  • examples/noise_simplex_2d/main.v (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/noise_simplex_2d/README.md
Additional comments not posted (7)
examples/noise_simplex_2d/main.v (7)

1-2: Module declaration and imports look good.

The module declaration and imports are correctly defined.


3-5: Imports are appropriate.

The necessary modules for random number generation, noise generation, and plotting are imported.


7-9: Commenting style is clear and informative.

The comments provide clear context about the creation of the noise generator and the availability of other noise functions and dimensions.


10-12: Random seed initialization and generator creation are correct.

The random seed is initialized, and the noise generator is created and randomized correctly.


14-16: Pre-allocating arrays is a good practice.

The arrays x, y, and z are pre-allocated with a capacity of 1600, which is efficient.


18-26: Nested loops for generating noise values are appropriate.

The nested loops iterate over a 40x40 grid to generate simplex noise values. The coordinates are scaled to control the frequency of the noise.


28-37: Plot creation and configuration are correct.

The heatmap plot is created and configured correctly, with the title set appropriately.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c8f94bf and 4861581.

Files selected for processing (3)
  • examples/noise_fractal_2d/README.md (1 hunks)
  • examples/noise_fractal_2d/main.v (1 hunks)
  • examples/noise_simplex_2d/main.v (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/noise_fractal_2d/README.md
Files skipped from review as they are similar to previous changes (1)
  • examples/noise_simplex_2d/main.v
Additional comments not posted (6)
examples/noise_fractal_2d/main.v (6)

1-6: Imports and module declaration look good.

The module declaration and imports are correct and necessary for the functionality.


7-13: Initialization and generator creation look good.

The random seed initialization and noise generator creation are correct. The randomize method usage is appropriate.


14-17: Array initialization looks good.

The arrays for x, y, and z coordinates are correctly initialized.


18-21: Variable initialization looks good.

The variables for noise generation layers and persistence are correctly initialized.


22-42: Noise generation logic looks good.

The nested loops and noise generation logic are correct. The normalization step and accumulation of noise values are appropriately handled.


44-54: Plot initialization and visualization look good.

The plot initialization and heatmap visualization are correctly implemented.

Copy link
Member

@ulises-jeremias ulises-jeremias left a comment

Choose a reason for hiding this comment

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

🔥

@@ -0,0 +1,16 @@
# Example - plot_bar 📘
Copy link
Member

Choose a reason for hiding this comment

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

the title here is wrong 😅

@ulises-jeremias ulises-jeremias merged commit ebaaf2d into vlang:main Aug 5, 2024
6 of 8 checks passed
ulises-jeremias added a commit that referenced this pull request Aug 5, 2024
* 'main' of github.com:vlang/vsl:
  feat: Improve machine learning models and data struct in vsl.ml
  feat: Add machine learning models and data struct to vsl.ml
  noise: add simplex noise (#207)
  poly: edit multiply and add divide functions (#215)
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.

4 participants