Skip to content

WebAssembly Z80 Cellular Automata .cursorrules prompt file

Author: PhantasticUniverse

What you can build

Interactive Cellular Automata Simulator: An application allowing users to customize and visualize cellular automata simulations with an environmental region grid. Users can adjust region parameters in real-time to see how different environmental influences affect cell behavior.Educational Tool for Cellular Automata: A web-based platform designed for educational purposes, focusing on teaching the principles of cellular automata and emergent behavior through interactive simulations. Students can experiment with various region parameters and observe the outcomes.Cellular Automata Game Maker: A tool for game developers to create custom games or puzzles based on cellular automata principles. It allows developers to define regions and adjust parameters to create unique gameplay mechanics influenced by environmental factors.Scientific Research Utility for Cellular Automata: A software solution for researchers to explore complex phenomena and emergent behaviors in cellular systems. It includes advanced features for configuring region parameters and conducting systematic experiments.Artistic Cellular Automata Visualizer: An app designed for artists to create dynamic, visually appealing patterns and animations using cellular automata. Artists can manipulate environmental regions to achieve distinct aesthetic effects.Simulation-Based Environment Modeling Tool: A virtual environment modeling tool that uses cellular automata to simulate ecological and biological systems. Users can define regions with specific properties to study ecosystem interactions and changes over time.AI and Machine Learning Experimentation Platform: A platform for experimenting with AI models and machine learning algorithms by testing their adaptability and learning capabilities in dynamic, region-based cellular automata environments.Collaborative Cellular Automata Platform: An online service where users can collaboratively build and modify simulations, share their configurations, and explore each other's creations, fostering a community-focused approach to learning and development.Cellular Automata-Based Music Generator: An innovative tool for generating music based on the state and activity of cells within the simulation. Users can customize regions and parameters to influence the musical output.Optimization and Problem-Solving Tool: A software application that leverages cellular automata to tackle complex optimization and problem-solving tasks. Users configure regions to apply different strategies and influences, aiding in finding solutions to real-world challenges.

Benefits

Dynamic Region Customization: Each region allows for custom parameters like directional influence, temperature, and energy levels, enabling nuanced simulation configurations and unique soup cell behavior inside each region.Efficient Mapping and Interaction: Implements a sophisticated mapping system between soup cells and regions for optimized performance, ensuring real-time updates and interactions within the environmental region grid.Robust Visualization and UI: Integrates a detailed user interface with a visualization system to manipulate and display regional properties, offering intuitive controls and immediate feedback on parametric changes.

Synopsis

Developers building cellular automata simulations would benefit by implementing multi-level environmental controls for complex, dynamic interactions and user-driven environmental modifications in z80 cellular automata projects.

Overview of .cursorrules prompt

The .cursorrules file outlines a system for enhancing a z80 cellular automata simulation by introducing a higher-level control structure called the "environmental region grid." This structure allows users to define and manipulate larger areas within the simulation, referred to as regions, which can influence the behavior of underlying "soup cells." The regional grid can be configured in varying sizes (4x4, 8x8, 16x16) for different levels of granularity. Regions have adjustable parameters such as obstacles, directional influence, randomness, temperature, and energy levels that dynamically modify cell behavior. Users can interact with the simulation by adjusting these parameters in real-time, and changes are visually represented. The file provides a step-by-step plan to implement this system, including creating data structures, mapping cells to regions, modifying the simulation loop, enhancing the WebAssembly interface, developing user interfaces, and synchronizing data between frontend and backend components. This approach allows for complex user-defined behaviors and enhances the depth and interactivity of the simulation.

.cursorrules Content

json
We're implementing a higher-level control structure for our z80 cellular automata simulation, which we call the "environmental region grid."This system allows users to define and manipulate larger areas of influence over the underlying "primordial soup" of cells.Key Concepts:1. Soup Cells: The individual units of our cellular automata, which follow basic rules and interact with their neighbors.2. Regions: Larger areas that encompass multiple soup cells. Each region can have unique properties that influence the behavior of the soup cells within it.3. Environmental Region Grid: A grid overlaid on top of the soup cell grid, dividing the simulation space into discrete regions. This grid can be 4x4, 8x8, or 16x16, allowing for different levels of granularity.4. Region Parameters: Each region has a set of adjustable parameters that affect the soup cells within it. These could include: - Obstacle (A region that blocks the movement of soup cells) - Directional influence (biasing cell interactions in specific directions) - Randomness factor (introducing more or less chaos in cell behavior) - Temperature (affecting overall activity levels) - Energy levels (influencing the likelihood of certain cell states or interactions) - Other custom parameters as needed5. Dynamic Influence: The region parameters dynamically modify the behavior of soup cells, creating areas of distinct characteristics within the larger simulation.6. User Interaction: Users can interact with the simulation by adjusting region parameters in real-time, allowing for on-the-fly modification of the simulation's behavior.7. Visualization: The region grid and its effects are visually represented, allowing users to see the influence of their changes on the simulation.Purpose:This system adds a new layer of complexity and control to the cellular automata simulation. It allows for the creation of diverse environments within a single simulation, enabling users to explore how different regional properties affect the emergent behavior of the cellular automata.By implementing this region grid system, we're providing a powerful tool for users to experiment with large-scale influences on cellular automata behavior, potentially leading to new insights and interesting emergent phenomena.Plan:1. Define the Region Structure:Create a comprehensive data structure to represent each region. This structure should be flexible enough to accommodate various parameters that can influence the behavior of soup cells within that region. Consider including: - Obstacle - Directional influence (for each cardinal direction) - Randomness factor - Temperature - Energy level - Any other relevant parametersEnsure that each parameter is represented by an appropriate data type, typically using floating-point numbers for continuous values or integers for discrete states. This structure will be the foundation of your region system, so design it with extensibility in mind.2. Create the Region Grid:Implement a two-dimensional array to represent the region grid. This grid should be flexible in size, allowing for configurations such as 4x4, 8x8, or 16x16. Each element of this array will be an instance of the region structure defined in step 1. Initialize this grid with default values for all parameters, ensuring a consistent starting state. Consider implementing methods to easily resize the grid and maintain the aspect ratio with the underlying soup cells.3. Implement Soup Cell to Region Mapping:Develop a system to efficiently map each soup cell to its corresponding region. This mapping is crucial for quick lookups during simulation. Create a separate array where each element represents a soup cell and contains the index or reference to its associated region. Implement functions to update this mapping whenever the region grid size changes. Ensure that this mapping system is optimized for performance, as it will be frequently accessed during the simulation.4. Modify the Main Simulation Loop:Update the core simulation logic to incorporate region parameters. For each soup cell update: a. Determine the cell's corresponding region using the mapping created in step 3. b. Retrieve the region's parameters. c. Apply the effects of each parameter to the soup cell's behavior.This might involve adjusting probabilities, modifying state transition rules, or influencing the cell's interaction with neighbors. Ensure that this integration is done efficiently to maintain simulation performance.5. Implement Parameter-Specific Logic:For each parameter in the region structure, create dedicated functions or methods to apply its effects. For example: - Obstacle: Turns the cell into an obstacle, preventing it from being randomly selected, and preventing neighbor soup cells from interacting with it. - Directional influence: Adjust the probability of a cell interacting with neighbors in specific directions. - Randomness: Introduce variability in state transitions or cell behavior. - Temperature: Affect the overall activity level or energy of cells within the region. - Energy level: Influence the likelihood of certain operations or state changes.Design these functions to be modular and easily expandable, allowing for the addition of new parameters in the future without major code restructuring.6. Enhance the WASM Interface:Extend the WebAssembly interface to handle the new region grid system. This involves: a. Creating functions to set and get the entire region grid state, allowing for efficient data transfer between JavaScript and WASM. b. Implementing additional functions for manipulating individual regions or specific parameters. c. Ensuring these functions are properly exported and accessible from the JavaScript side. d. Optimizing data transfer to minimize performance overhead, especially for larger grid sizes.7. Develop the User Interface:Design and implement a comprehensive user interface for manipulating the region grid. This should include: a. A visual representation of the region grid, possibly overlaid on the main simulation view. b. Interactive elements for each region, allowing users to adjust parameters individually. c. Global controls for setting grid size and applying presets. d. A system for selecting different "brushes" or tools for painting parameter values across multiple regions. e. Real-time feedback showing the effects of parameter changes on the simulation.Ensure that the UI is intuitive and responsive, providing users with immediate visual feedback on their actions.8. Create a Region Visualization System:Develop a robust visualization system for the regions. This should: a. Visually represent the various parameters of each region, possibly using color coding, patterns, or overlays. b. Update in real-time as parameters are changed, providing immediate feedback to the user. c. Implement different visualization modes to focus on specific parameters or overall region states. d. Ensure that the visualization is clear and distinguishable from the underlying soup cell simulation.9. Implement Data Synchronization:Create an efficient system for keeping the region grid data synchronized between the JavaScript UI and the WASM simulation. This might involve: a. Implementing periodic updates at set intervals. b. Creating an event-driven synchronization system that updates when changes occur. c. Optimizing large data transfers to maintain smooth performance, possibly using typed arrays or other efficient data structures. d. Implementing a queuing system for updates to prevent overwhelming the simulation with rapid changes.10. Update the Shader Code:Modify the fragment shader used for rendering the simulation to incorporate region effects. This involves: a. Passing region data to the shader, either as a texture or uniform array. b. Updating the shader logic to consider region parameters when rendering cells. c. Implementing visual effects that reflect the influence of region parameters, such as color shifts, intensity variations, or particle effects. d. Optimizing the shader code to maintain performance, especially for larger simulations or complex region effects.This system will allow for complex, user-defined behaviors across the simulation space, significantly enhancing the depth and interactivity of the cellular automata simulation.

Released under the MIT License.