AI Coder Rules - ProkopHapala/FireCore GitHub Wiki
Rule 1 (Gemini)
# General Guidelines
- Strive for modularity and reusability.
- Avoid duplication: before writing a new function, check for existing similar ones and generalize if needed.
- Avoid `private` methods or variables - full transparency preferred.
- Avoid excessive boilerplate; design functions with light, general-purpose interfaces.
- The goal is correctness, performance, and fidelity to physical equations - not formal software engineering.
- Fail fast and visibly; silent error handling can be more dangerous than a crash.
- Security, privacy, and strict modularization are secondary - this code is for scientific insight, not for end users or clients.
# Formatting Style
- Prioritize simplicity and clarity.
- Use short, symbolic names for variables and functions (e.g., `E` for energy, `F` for force).
- Numerical code should reflect equations directly, unless performance requires otherwise.
- Prefer one-liners when readable; no enforced line-length limits.
- Place comments inline (after the code) rather than above.
- Avoid unnecessary empty lines and line breaks.
# Performance
- Performance is important, but only after correctness is ensured.
- Cache and reuse common sub-expressions and partial results - avoid redundant computation.
# Debugging
- Add debug print statements early, especially for important intermediate physical quantities or control flow - but avoid placing them in hot loops.
# Language-Specific Guidelines
## Python
- Prefer `numpy` operations (broadcasting, fancy indexing, masking) over explicit loops in numeric code.
- prefer concise constructs like list comprehensions over loops as long as they remain readable.
- Avoid overusing `dict` where tuples suffice, especially for return values.
## C/C++
- Favor raw C-style arrays over `std::vector`; use pointer arithmetic and C-style type casting.
- Prefer C-style I/O (`stdio.h`, `printf()`) over C++ iostreams.
- Use `std::unordered_map` or `std::set` when associative containers are needed.
- Assume availability of `Vec2d`, `Vec3d` as 2D and 3D vectors with basic arithmetic operators.
- Style: place `{` on the same line as control structures (e.g., `if (...) {`, `void func(...) {`).
- Avoid exceptions; use `printf()` and `exit()` for error handling to ensure failures are visible.
## Parallel computing (OpenMP, OpenCL, CUDA, Compute Shaders)
- Try to minimize need for synchronization.
- Try to minimize global memory access by use shared/local or private memory buffering.