How Countrydle Answers Questions
Rather than trusting raw LLM hallucinations, Countrydle uses a hybrid engine: sub-millisecond deterministic template compilers, Gemini 2.5 Flash Lite as a formal AST parser, curated local SQLite relational fact tables, and verifiable semantic vector RAG.
Zero LLM overhead
Structured query plan
SQLite verifies truth
Countries, states, counties
Question Flow Graph & Anti-Hallucination Shield
Click any step in the pipeline flow to inspect the exact code, queries, and anti-hallucination defense applied.
Sub-millisecond Template Compiler
Fast-path in-memory compiler executing compiled regex trees across 672 country forms, 50 states, Polish counties, borders, seas, license plates, and population ranges. Intercepts ~50% of all player questions.
Zero hallucination probability. The question completely bypasses generative language models and translates deterministically into an AST node directly in RAM.
def compile_template(q: str):
if re.search(r"\b(landlocked|srodladow\w*)\b", q):
return [_node("exists", "water_access"), {"operator": "not", "args": [0]}]Interactive Pipeline Inspector
Select a real query from the uniform grid to inspect its wire AST plan, SQLite queries, and ground truth proof.
"Is it landlocked?"
[
{
"entity": "target_country",
"relation": "water_access",
"operator": "exists"
},
{
"operator": "not",
"args": [
0
]
}
]Common natural language templates (landlocked, island, borders, driving side) compile into abstract syntax trees in sub-millisecond memory without invoking any LLM, costing zero tokens.
Formal AST Operator Specification
The intermediate representation executed against our offline facts databases.
Tests strict equality between a scalar property and an expected value.
"Is it an island?" → equals(is_island, True)
Evaluates numeric thresholds for population, square area, admission order, or year.
"Does it have more than 50 million people?"
Checks membership in one-to-many sets: water bodies, border neighbors, or international organizations.
"Does it border France?"
Unary operator checking if a relation contains at least one record (e.g. has coastline or mountain ranges).
"Does this state have mountain ranges?"
Geographic coordinate comparison across longitudes or latitudes against reference entities.
"Is it east of Germany?"
Case-insensitive prefix or suffix matching on entity names or license plate codes.
"Does the country name start with B?"
Compares the exact letter count of the name, ignoring spaces and hyphens.
"Does the name have 6 letters?"
Topological node combinators chaining sub-conditions with strict boolean algebra.
"Is it in Europe and landlocked?"
Offline Relational Facts Catalog
Every game mode operates on dedicated, curated relational SQLite tables with indexed foreign keys.
country_facts.sqlite
16 relational tables: continents, borders, water bodies, capitals, currencies, languages, historical unions (USSR, Yugoslavia), driving sides.
us_state_facts.sqlite
8 tables: state/international borders, ocean access (Pacific, Atlantic, Great Lakes), mountain ranges, interstates, 13 colonies, Civil War side.
voivodeship_facts.sqlite
7 tables: neighboring country borders, Baltic coastline, dual capital seats, river courses (Wisła, Odra), macro-regional geographic tags.
powiat_facts.sqlite
6 tables: city vs land county flags, registration plate codes, neighboring voivodeship borders, international frontiers, seat cities.
Why Zero Hallucinations? The Architecture
The architectural contrast between conversational chatbots and Countrydle’s query engine.
The Model Generates the Truth
- High hallucination rate: answers are guessed probabilistically via stochastic token sampling.
- Non-deterministic: identical questions can yield contradictory answers across sessions.
- Zero auditability: players have no guarantee whether the AI remembered facts correctly.
The Model is Only a Parser; Database Computes Truth
- 0.0% local hallucination: ground truth is evaluated mathematically by relational SQLite queries.
- Sub-millisecond latency: regex compilers resolve common templates instantly in RAM.
- Complete audit trail: every answer provides an exact human proof and audit relation tag.