Act as an Expert Game Engine Architect and LPC Programmer.
The Context: I am building a decentralized artificial life simulation called
"Genesis Omega." The engine is a custom WebAssembly/JavaScript LPC Virtual
Machine (GEM) that syncs object state across a peer-to-peer WebSocket mesh
using JS Proxies.
The Mechanics: Genesis Omega combines Conway's Game of Life (cellular
survival/death), Tetris-style falling blocks (gravity/structure), and
thermodynamics (heat radiation/dissipation), interwoven with esoteric
programming concepts.
The Goal: I need to build the foundational LPC object representing a single
chunk of the simulation grid: gamelib/mesh/genesis_grid.c.
Strict Technical Constraints (CRITICAL):
LPC Variable Declarations: You must use strict legacy C/LPC rules. ALL
variables (strings, ints, objects) MUST be declared at the absolute top of a
function block before any execution or assignment occurs. Inline declarations
(e.g., for(int i = 0...) or string x = "foo";) will crash the compiler.
The Proxy State Hack: To trigger the network sync, the object's state cannot
be mutated directly via standard global variables. In create(), you must
capture the mesh proxy: proxy_me = mesh_sync_object(this_object(),
"genesis_chunk_1", "^(cells|thermal_map)$");. Every time you mutate the grid
state, you MUST do it via the proxy mapping (e.g., proxy_me["thermal_map"][x]
= heat;).
Grid Structure: Design the 2D grid logic. proxy_me["cells"] should hold the
physical cell states, and proxy_me["thermal_map"] should hold the heat values.
Tick Engine: Implement a tick() function driven by call_out("tick", 1) that
iterates over the arrays to process cellular survival and thermal dissipation.
Please provide the initial, robust LPC code for genesis_grid.c adhering to
these strict engine constraints.