{"id":26045129,"url":"https://github.com/definetlynotai/colortomata","last_synced_at":"2025-10-07T15:41:26.984Z","repository":{"id":279849304,"uuid":"940198649","full_name":"DefinetlyNotAI/Colortomata","owner":"DefinetlyNotAI","description":"Simple application that implements a complex cellular automaton system with dynamic rules for color propagation and grid evolution. The system is based on an array of cells, each containing a color, and evolves according to a series of rules, applying various constraints and probabilistic factors to simulate interactions between cells.","archived":false,"fork":false,"pushed_at":"2025-02-27T19:55:35.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T03:58:00.338Z","etag":null,"topics":["automata","cells","cellular","cellular-automata","color","flask","grids","python","simple"],"latest_commit_sha":null,"homepage":"https://colortomata.vercel.app","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DefinetlyNotAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-27T19:17:43.000Z","updated_at":"2025-02-27T19:55:38.000Z","dependencies_parsed_at":"2025-02-28T03:58:03.209Z","dependency_job_id":"02be375e-6eb6-4aa3-819f-5690c1a831b6","html_url":"https://github.com/DefinetlyNotAI/Colortomata","commit_stats":null,"previous_names":["definetlynotai/colortomata"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FColortomata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FColortomata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FColortomata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FColortomata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DefinetlyNotAI","download_url":"https://codeload.github.com/DefinetlyNotAI/Colortomata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242451423,"owners_count":20130394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automata","cells","cellular","cellular-automata","color","flask","grids","python","simple"],"created_at":"2025-03-07T19:31:48.392Z","updated_at":"2025-10-07T15:41:26.978Z","avatar_url":"https://github.com/DefinetlyNotAI.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Colortomata\r\n\r\nColortomata is a mix between **Color** and Au**tomata** and is exactly the mixture of these 2 words,\r\nI was inspired by a random YouTube short showcasing an idea of an automata for colors that generate intricate designs\r\n\r\nThis application generates a dynamic grid of colored cells based on customizable rules. \r\nIt uses a Flask web server to allow users to interact with the grid's generation, evolution, \r\nand manipulation. Here's how to use it:\r\n\r\n### 1. **Run the Application**\r\n\r\nIf you want to use locally:\r\n\r\nTo start the application, run the following command in your terminal:\r\n\r\n```bash\r\npython Colortomata.py\r\n```\r\n\r\nThis will start the Flask server on `http://127.0.0.1:5000/`. \r\nYou can access the app through any web browser.\r\n\r\n### 2. **Access the Application**\r\n\r\nOnce the application is running, open a browser and navigate to:\r\n\r\n```\r\nhttp://127.0.0.1:5000/\r\n```\r\n\r\n### 3. **Configure the Grid**\r\n\r\nYou can configure the following parameters before generating the grid:\r\n\r\n- **Grid Size:** Determines the dimensions of the grid (default is 500).\r\n- **Theta:** Controls the threshold variation when applying rules (default is 0.8).\r\n- **Delta:** Adds noise to the rule application (default is 0.1).\r\n- **Lambda (Cluster Bias):** Controls the bias for color clustering (default is 0.7).\r\n- **Seed:** The seed used for random number generation (default is 42).\r\n- **Custom Rule Order:** You can specify the order in which the colors' rules are applied (e.g., `[\"Red\", \"Blue\", \"Green\"]`).\r\n\r\n### 4. **Generate the Grid**\r\n\r\nAfter setting the parameters, press the **Generate Grid** button to initialize the grid. \r\nThe app will return a base64-encoded PNG image of the grid, \r\nwhich you can view directly in your browser.\r\n\r\n### 5. **Evolve the Grid**\r\n\r\nClick on the **Evolve Grid** button to start the grid evolution process. \r\nThe grid will evolve dynamically over time based on the defined rules. \r\nThe evolution process will run in the background and automatically stop after 60 seconds \r\n(or the specified time limit).\r\n\r\n---\r\n\r\n# Logic Explanation\r\n\r\nThis application implements a complex cellular automaton system with dynamic rules\r\nfor color propagation and grid evolution. The system is based on an array of cells, \r\neach containing a color, and evolves according to a series of rules, \r\napplying various constraints and probabilistic factors to simulate interactions between cells.\r\n\r\n## 1. **Grid Initialization**\r\n\r\nUpon starting, the grid is initialized randomly, \r\nwhere each cell is assigned one of the colors from a predefined palette (excluding black and white).\r\nThe initialization is performed using the following steps:\r\n\r\n- **Random Color Assignment:** Each cell is assigned a color from the available colors (excluding `White`).\r\n- **Cluster Bias (λ):** To introduce bias towards certain colors, a `lambda_` parameter influences the probability of certain colors being chosen. This ensures that some colors are more likely to appear than others.\r\n\r\nThe probability distribution for color selection is weighted by `lambda_`, \r\nensuring that certain colors (especially those near the start of the custom rule order) \r\nhave a higher chance of appearing.\r\n\r\n```python\r\nfrom Colortomata import np, COLOR_KEYS, lambda_\r\n\r\n\r\ndef generate_cluster_bias():\r\n    base_prob = np.ones(len(COLOR_KEYS) - 1) / (len(COLOR_KEYS) - 1)\r\n    base_prob *= lambda_\r\n    base_prob /= base_prob.sum()\r\n    return base_prob\r\n```\r\n\r\n## 2. **Color Rule Logic**\r\n\r\nThe most intricate part of this system is how colors evolve. \r\nThe grid undergoes periodic updates (every time step) based on its neighboring cells' \r\ncolors and a set of rules that govern the propagation of color.\r\n\r\nEach cell has **eight neighbors** (in a 3x3 square centered on the cell), and the next state of a cell \r\nis determined by its neighbors' colors and how well they align with certain predefined rules.\r\n\r\nThe **rules** for each color are complex and depend on the combination of neighboring colors. \r\nBelow is a breakdown of how each color's rule is applied.\r\n\r\n### **Red Rule**\r\nRed cells can evolve if:\r\n\r\n1. **Threshold Variation:** If the red cells are surrounded by at least 5 other red cells (adjusted by a random threshold determined by `theta`), they maintain their color.\r\n2. **Red and Yellow/Orange Combo:** If there are at least 3 red cells and at least 2 orange or yellow cells in the neighborhood, the cell becomes red.\r\n\r\n### **Orange Rule**\r\nOrange cells are applied if:\r\n\r\n- There are at least 2 red cells and at least 2 yellow cells in the neighborhood.\r\n\r\n### **Yellow Rule**\r\nYellow cells are more likely to propagate if:\r\n\r\n1. There are at least 4 orange cells in the neighborhood.\r\n2. Alternatively, if there are at least 3 yellow cells and at least 2 green cells, the yellow cell rule applies.\r\n\r\n### **Green Rule**\r\nGreen cells are influenced by:\r\n\r\n1. At least 3 blue cells in the neighborhood.\r\n2. Alternatively, at least 3 yellow cells in the neighborhood.\r\n\r\n### **Blue Rule**\r\nBlue cells evolve if:\r\n\r\n1. There are at least 5 blue cells in the neighborhood.\r\n2. Alternatively, if there are at least 3 blue cells and at least 2 purple cells, a blue cell will emerge.\r\n\r\n### **Purple Rule**\r\nPurple cells are quite rare and are applied if:\r\n\r\n1. There are at least 3 blue cells and at least 3 pink cells in the neighborhood, excluding black cells.\r\n2. Alternatively, purple can form if there are enough connections between blue and pink cells, combined with the absence of too many black cells.\r\n\r\n### **Pink Rule**\r\nPink cells propagate under two conditions:\r\n\r\n1. There are at least 4 pink cells around.\r\n2. Alternatively, if red and magenta cells are present, and there are no more than 3 black cells in the neighborhood, the pink rule can be triggered.\r\n\r\n### **Magenta Rule**\r\nMagenta is a rare, often hard-to-form color. It requires:\r\n\r\n1. At least 3 purple cells.\r\n2. At least 2 pink cells.\r\n\r\n### **Black Rule (Always Last)**\r\nIf none of the above rules apply, the cell turns black.\r\nIndicating death.\r\n\r\n## 3. **Noise and Randomness (Delta and Theta)**\r\n\r\nThe grid evolution is not purely deterministic. \r\nWe introduce randomness through **delta** and **theta** parameters:\r\n\r\n- **Theta (θ):** Determines the threshold for when a rule should apply. \r\n  - It's a variation factor that makes the system more unpredictable by introducing a random deviation when deciding whether the rule should be applied.\r\n- **Delta (δ):** Introduces noise, affecting how likely a cell is to remain in a certain state or change based on neighboring conditions.\r\n\r\n## 4. **Grid Evolution and Time Limit**\r\n\r\nThe grid evolves by continuously applying the rules iteratively until the maximum allowed time \r\n(`MAX_TIME`) is reached. The evolution is time-sensitive to prevent excessive computational load \r\nand ensure that the app runs efficiently.\r\n\r\n## 5. **Neighboring and Boundary Conditions**\r\n\r\nEach cell is surrounded by its **eight neighbors** in a square arrangement. \r\nThe boundary conditions are handled by:\r\n\r\n**Edge Handling:** Cells on the edge of the grid wrap around to the opposite side, \r\ncreating a toroidal grid. This means that the grid's edges connect to each other, \r\nallowing for continuous evolution without boundary issues.\r\n\r\n## 6. **Image Generation**\r\n\r\nAfter the grid is evolved, the final image is generated \r\nby translating the grid’s color values into an image using **PIL (Python Imaging Library)**. \r\nThe image is then converted to a **base64-encoded string** for easy display in a browser.\r\n\r\n---\r\n\r\n## Conclusion\r\n\r\nThis application combines cellular automata with dynamic, \r\ncustomizable rules to create an engaging, visually appealing grid of evolving colors. \r\nThe interplay of color rules, randomness, and grid size creates a unique and constantly evolving pattern, \r\nwhich can be adjusted and customized by the user for endless possibilities.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefinetlynotai%2Fcolortomata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefinetlynotai%2Fcolortomata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefinetlynotai%2Fcolortomata/lists"}