Summary
This tool simulates dynamic, T6SS-mediated interactions between up to three bacterial populations: Attackers (red), Prey (blue), and Defenders (yellow-orange). Cells exist on a hexagonal grid where they can move, replicate, and compete for space based on a wide range of user-configurable parameters. While Attackers and Defenders utilize a contact-dependent Type VI Secretion System (T6SS) to deliver toxins, Prey cells can defend themselves by producing and releasing diffusible bacteriocin toxins into the environment. The simulation proceeds in discrete one-minute time steps.
Getting Started 🚀
-
Set Up the Arena: Interactively design your starting battlefield.
- Use the 'Att', 'Prey', 'Def', 'Barr', or 'Rem' buttons to select a tool, then click and drag on the canvas to place or remove cells. Barriers are static obstacles.
- Alternatively, use 'Place Cells Randomly' to populate the grid based on 'Initial Count' settings, or import a specific layout with 'Import Arena (TSV)'.
- Configure Parameters: Adjust settings in the left-hand Control Panel. For the cleanest workflow, load your settings *before* populating the arena. If you do this out of order, a sync button (🔄) will appear to help you fix the state.
- Run the Simulation: Use the main control buttons: Start [S], Pause [P], One Step [O], and Stop & Report [R]. When paused, you can scrub the timeline using the time-travel slider, use the step navigation buttons (◀/▶), the autoplay buttons (Play/Stop), or use the Left/Right Arrow Keys as keyboard shortcuts to navigate history. For better performance on long runs, increase the Render Rate in the 'Simulation Control' panel to draw the arena less frequently.
- Analyze Results: After stopping, a report appears. From here, you can view a graph of the population dynamics and download various data files, including the full session for later analysis.
Visualizations 🎨
- Cell States: Live cells are solid colors. Dead cells are dark gray, and lysing cells are light gray, both with a faint inner dot of their original color.
- Prey Capsule: A thick, purple inner border on a Prey cell indicates it has synthesized protective capsule layers.
- Prey Toxin Lysis Indicator: In lysis-dependent release mode, Prey cells with accumulated internal toxins display a green inner circle that darkens as they get closer to the lysis threshold.
- T6SS Firing: A bright green sector indicates a 'precise hit' capable of delivering toxins. A darker, transparent green sector (Attackers only) indicates a 'miss' that causes no damage but still triggers a cooldown.
- CPRG Reporter: The arena's background color shifts from white towards magenta as lysed Prey cells release LacZ enzyme, which converts the CPRG substrate.
- Prey AI Field: A blue overlay on empty hexes visualizes the concentration of the Prey autoinducer signal. The overlay becomes more opaque as the concentration crosses key thresholds (the Attacker's attraction limit and a fraction of the theoretical maximum AI level).
- Prey Toxin Field: A transparent green overlay on empty hexes visualizes the concentration of the Prey-derived toxins (bacteriocins NL and L) in the environment. The overlay becomes more opaque as the local toxin concentration increases, helping visualize the chemical defensive barrier created by Prey cells.
Preset Scenarios 📚
The 'Load Preset Scenario' button provides a fast way to configure the simulation for specific experimental questions.
To select a preset, simply click anywhere on its title or in the background of its box. The box will become highlighted. Once a preset is selected, you can adjust its custom sliders and options (such as fill percentage, ratios, strategies, or trigger modes) directly within that preset's panel.
Applying the Preset: Clicking the "Apply Selected Preset & Close" button will apply the customized parameters, reset the arena and RNG, and randomly populate the grid. This will only override the specific settings relevant to that scenario, leaving all other parameters (like Arena Radius or any settings you have manually changed) untouched. You can use the 'Reset Settings to Defaults' button in the main panel if you wish to return to a baseline state before applying a preset.
The available presets include:
- 1. Role of Initial Density: Vary total cell density and Attacker:Prey ratios.
- 2. Prey Sensitivity / Effector Type: Explore outcomes when Prey are sensitive to only Lytic, only Non-Lytic, or Both toxin types.
- 3. Contact Sensing & Kin Exclusion: Adjust Attacker firing strategies like Contact Sensing Bias and Kin Exclusion.
- 4. Tit-for-Tat Dynamics: A 3-type scenario (Att, Prey, Def) to model Defender retaliation strategies.
- 5. Role of Capsule in Protection: Tests Prey capsule protection by making it always-on. Control protection % and synthesis time.
- 6. Predation by T6SS Activity: Forces Attackers to "eat to replicate" by disabling normal replication and enabling the Lysis-for-Replication reward.
- 7. Role of Movement in Killing: Focuses on mobility and chemotaxis. Control Prey AI production and Attacker movement/attraction.
- 8. Quorum Sensing Dynamics: A two-column setup to control *both* Attacker T6SS activation and Prey capsule synthesis via their respective QS systems.
- 9. Prey Toxin Production: Explore the effects of diffusible Prey-derived toxins (NL and L), release mode (lysis-dependent or continuous), start probabilities, and trigger modes.
- 10. Battle Royale: A full sandbox to quickly configure all three cell types with high-level strategy switches (e.g., 'Movement: AI', 'Predation: Yes', 'Selectivity: High').
Settings Explained ⚙️
The control panel allows fine-tuning of the simulation. Here are the key concepts for each cell type:
Reproducibility & The Seed
The simulation's outcome is determined by the Seed. The controls below give you full power over the simulation's state.
• Seed Input Field: The current seed for the random number generator (RNG).
• New Seed (🔄) Button: Generates a new, random seed for a completely new experiment.
• RNG Reset (🡄) Button: Appears (in green) when the RNG has been used. Click to reset the sequence to the beginning for the current seed. This is crucial for creating identical starting conditions.
• Cell Sync (🔄) Button: Appears (in red) if the placed cells are out of sync with the RNG (e.g., if you change the seed after placing cells). Click to re-initialize the cells' random properties.
• Reset Simulation Button: This is a hard reset. It clears the arena, clears all history, and generates a new random seed.
Common Properties (All Types)
Each cell type has independent parameters for Replication (division time, set mean to -1 to disable) and Movement (cooldown, probability, and directionality preference for empty space).
Replication Reward System
Attackers and Defenders can be rewarded for their effectiveness. For every set number of lyses they cause, they can receive a replication reward. This can either kick-start a new replication cycle or accelerate their current one. This feature is configurable in the Attacker and Defender settings panels, allowing you to create dynamic fitness advantages.
Attacker Behavior
The firing logic of the attackers follows a clear priority:
• Contact Sensing: First, it decides whether to target a specific adjacent contact (cell or barrier) or fire randomly, based on the Contact Sensing Bias %. If it attempts a contact-biased shot but no targets are available, the firing is aborted for that turn.
• Kin Recognition: After a preliminary target is chosen, the Kin Exclusion % determines if self-recognition occurs when targeting another Attacker. The outcome is set by the penalty value (either cancelling the shot or smartly re-targeting a non-kin cell).
• Quorum Sensing (QS): The entire firing sequence is gated by a flexible Quorum Sensing system, which can activate firing based on local Attacker density.
• Prey Toxin Sensitivity: Attackers can absorb grid-based Prey toxins. They have configurable parameters for NL and L resistance chances, absorption rates (percentage absorbed per step), and thresholds (units required to die or lyse).
Prey Behavior
Prey are the primary targets but can have their own defense mechanisms:
• Capsule Synthesis: If enabled, Prey can produce up to 5 protective capsule layers, reducing damage from T6SS attacks. Synthesis can be constitutive (always on) or dependent on their own AI concentration.
• Toxin Production & Release: Prey can synthesize their own Bacteriocin NL and L toxins. They can release them in Continuous Mode (secreted directly and continuously into the hex grid; cells start producing stochastically and cease division while producing, returning to normal growth once their randomly selected target production level is reached. Visually indicated by a small mid-green center dot) or in Lysis-Dependent Mode (accumulated internally until a threshold is reached, causing the cell to lyse and release the toxins; this threshold is a random value within a configured range chosen exactly once upon first activation. While producing, division is arrested, and upon replication, internal toxins are split 50/50 and rounded down. Visually indicated by a green inner circle that darkens as it approaches the threshold). Production can be standard/constitutive, QS-regulated, or Attacker NL toxin-induced, with the stochastic start probability acting as an additional check on top of the QS and toxin triggers.
• Resistance: Prey have separate resistance percentages and toxin sensitivity thresholds against attacks from Attackers and Defenders.
• Reporter Release: Upon lysis, Prey release a set amount of LacZ enzyme, driving the CPRG color change.
Defender Behavior
Defenders are specialized cells that primarily counter-attack.
• Retaliation: Their key feature. After being hit by a T6SS, they have a set chance to fire a burst of shots back at their attacker.
• Random Firing: Defenders can also be set to fire randomly at adjacent cells based on a chance and cooldown timer.
• Immunity: Defenders are immune to toxin damage from other Defenders but will still sense the hit and retaliate.
• Prey Toxin Sensitivity: Defenders can absorb grid-based Prey toxins. They have separate NL and L resistance chances, absorption rates (percentage absorbed per step), and thresholds (units required to die or lyse).
Data Export & Import 💾
You can save and load both parameters and results, enabling reproducible experiments.
- Shareable Link 🔗: Use the 'Copy Shareable Link' button (in General Settings) to copy a URL to your clipboard. This link encodes your current Seed and any modified parameters, allowing anyone to instantly load your exact experimental setup.
- Settings (TSV): The 'Import/Export Settings' buttons let you save and load your entire parameter setup.
- Arena (TSV): The 'Import/Export Arena' buttons save or load the specific spatial layout of cells you have placed manually.
- Simulation Data (TSV): From the final report, download a time-series table of cell counts and cumulative events, ideal for plotting.
- Arena Images (ZIP): Enables downloading a ZIP file containing a PNG image of the arena for every time step. This feature must be enabled by checking the 'Arena Images' box in the 'Exports' panel before starting the simulation.
- Full Session (.bft6): If 'Full State History' is enabled, you can save the entire simulation—settings and complete step-by-step history—into a single, compact binary file. This is the best way to archive an exact experiment for later re-loading and analysis. During import, you can click 'Stop & Save History Loaded' to immediately cancel reading further steps, preserving the history loaded up to that point.
- Additive Session Merging: If you import a `.bft6` file when history is already present, the simulation will validate that the seed and arena radius match, then merge the timelines together, allowing you to assemble very long simulation sessions segment-by-segment.
- Export Step (JSON): From the 'Time-Travel Control' panel, you can export the complete state of the currently viewed step—including all cell properties, AI grids, and settings—to a single JSON file. This is ideal for restoring simulations from a certain step.
- Import Step (JSON): From the 'Time-Travel Control' panel, you can import a previously exported Step state JSON file. This will perfectly replicate the conditions of that step, including all settings and the precise RNG state, allowing you to replicate previous simulation or start a new simulation from that exact point with a new set of random numbers.
- History Autoplay & Steps: While paused, scrub history with the scrub slider, step backward/forward one step at a time with the `◀` and `▶` step buttons (or left/right arrow shortcuts), or play/stop autoplay to play back the steps automatically using the step delay.
- Save All Data & Workspace Access: Clicking "Save All Data" prompts for a local folder choice via the browser's File System Access API. Once approved, the simulation silently saves the population TSV, layouts ZIP, images ZIP, and the `.bft6` session directly to your local workspace, avoiding repeated browser download prompts.
Memory Management & Database Offloading
Saving per-step data (like images, arena states, and full history) can consume a large amount of browser memory. To prevent crashes during long runs, you can configure maximum RAM buffer thresholds (in MB) for history, arena layouts, and step images inside the "Exports & Buffers" panel.
-
Silent Database Offloading: When any data buffer exceeds its defined limit in memory (RAM), the simulation automatically offloads the heavy data (e.g., detailed frame objects, captured base64 images, or arena TSV layouts) to the browser's local database (IndexedDB).
-
RAM Protection: The offloaded data is cleared from RAM, leaving only lightweight references in memory. This happens silently in the background, allowing the simulation to run uninterrupted without needing user interaction or intermediate file downloads.
-
On-Demand Retrieval: When you download or save files (such as downloading ZIPs of images/arena layouts, or saving the full `.bft6` session), the application automatically retrieves the offloaded frames and files from the database to build the download archive.
License and Attribution
This "BacFighT6", Simulation of T6SS-mediated Bacterial Interactions, is
Copyright (c) 2025 Marek Basler.
It is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
Source code is available at GitHub.
Support
Development of BacFighT6 runs on coffee! If you find it useful, please consider a small donation ... Thank you!