code wiki / _hdl_build / nx_wiki_econsim_page.nx

nx_wiki_econsim_page.nx source

↩ module page · 89 lines · 6967 B

1// nx_wiki_econsim_page.nx -- GENERATE the live "EconSim" wiki article, a TYPED Diataxis TUTORIAL page 2// built through the sovereign page builder (nx_wiki_shell) so it clears the full MediaWiki feature bar 3// (measured by nx_wiki_exceed). EconSim is the in-browser Capitalism-Lab-style serious game, 100% sovereign 4// .nx, hardware-rung-up, LIVE at https://nishifamily.com/econsim. The page TEACHES the loop (run a firm, 5// set a price, compete) and LINKS to the live app. Walkable: full walk furniture via nx_wiki_shell. 6// Emits web_assets/econsim_wiki.html (-> nishifamily.com/wiki/econsim.html). license_tier: ORIGINAL 7 8import "nx_syscalls.nx" 9import "nx_wiki_shell.nx" 10 11const ES_OUT: *u8 = "web_assets/econsim_wiki.html" 12const ES_CAP: i64 = 262144 13 14func main() -> i64 { 15 let now: i64 = sys_now_realtime_sec() 16 let h: *u8 = sys_mmap(ES_CAP) 17 var w: i64 = 0 18 19 let wl: *NxWikiLinks = sys_mmap(128) as *NxWikiLinks 20 sh_links_load(wl, "knowledge/registry/wiki_links.tsv" as *u8) 21 let store: *NxWikiDocStore = sh_corpus_store() 22 23 w = sh_head(h, w, "EconSim" as *u8, "econsim" as *u8) 24 w = sh_nav(h, w, "econsim" as *u8) 25 w = sh_walk_furniture(h, w, wl, store, "econsim" as *u8) 26 27 w = sh_cat(h, w, "<h1>EconSim &mdash; the in-browser economy game</h1>\n" as *u8) 28 w = sh_cat(h, w, "<p class=\"fresh\">&#10227; Generated LIVE by <code>nx_wiki_econsim_page</code> at epoch=" as *u8) 29 w = sh_catn(h, w, now) 30 w = sh_cat(h, w, " &mdash; a Diataxis <strong>tutorial</strong> page. Play the live game at <a href=\"/econsim\"><strong>nishifamily.com/econsim</strong></a>.</p>\n" as *u8) 31 32 w = sh_cat(h, w, "<p class=\"lede\"><strong>EconSim</strong> is an in-browser Capitalism-Lab-style serious game: run a firm, set your price, and watch demand, profit, and competitors respond &mdash; learn-for-real economics while you play. The whole engine is sovereign Nishi <code>.nx</code> (no third-party game engine), built hardware-rung-up, and it publishes LIVE as it is built. Play it now: <a href=\"/econsim\">nishifamily.com/econsim &rarr;</a></p>\n" as *u8) 33 34 w = sh_infobox_open(h, w, "EconSim" as *u8) 35 w = sh_infobox_row(h, w, "Type" as *u8, "Tutorial / serious game" as *u8) 36 w = sh_infobox_row(h, w, "Play" as *u8, "nishifamily.com/econsim" as *u8) 37 w = sh_infobox_row(h, w, "Engine" as *u8, "100% sovereign .nx (no game engine)" as *u8) 38 w = sh_infobox_row(h, w, "R0 market" as *u8, "GREEN 15/15" as *u8) 39 w = sh_infobox_row(h, w, "R1 competition" as *u8, "GREEN 20/20" as *u8) 40 w = sh_infobox_row(h, w, "Contract" as *u8, "FAIR-F2P: teaches to RECOGNIZE predation, never to exploit" as *u8) 41 w = sh_infobox_close(h, w) 42 43 w = sh_toc_open(h, w) 44 w = sh_toc_item(h, w, "what" as *u8, "What you'll learn" as *u8) 45 w = sh_toc_item(h, w, "loop" as *u8, "The core loop" as *u8) 46 w = sh_toc_item(h, w, "model" as *u8, "What is modeled (and proven)" as *u8) 47 w = sh_toc_item(h, w, "play" as *u8, "Play it" as *u8) 48 w = sh_toc_item(h, w, "refs" as *u8, "References &amp; evidence" as *u8) 49 w = sh_toc_close(h, w) 50 51 w = sh_section(h, w, "what" as *u8, "What you'll learn" as *u8) 52 w = sh_cat(h, w, "<p>EconSim is a <strong>serious game</strong> &mdash; the skill transfers to reality. You learn how price sets demand, how demand and cost combine into profit, and how competitors split a market. The governance contract is <strong>FAIR-F2P</strong>: the game teaches you to <em>recognize</em> predatory pricing and market-power tactics, never to deploy them &mdash; understanding as defense, the same thesis as the civic + financial-literacy products.</p>\n" as *u8) 53 54 w = sh_section(h, w, "loop" as *u8, "The core loop" as *u8) 55 w = sh_cat(h, w, "<ol><li><strong>Set a price</strong> for your product.</li><li>The market computes <strong>demand</strong> at that price.</li><li>Demand &times; margin gives your <strong>profit</strong>; you find the optimal price.</li><li>Add <strong>competitors</strong>: market share splits by price and the total is conserved (no units invented or lost).</li><li>Iterate &mdash; margin &times; volume is the score.</li></ol>\n" as *u8) 56 57 w = sh_section(h, w, "model" as *u8, "What is modeled (and proven)" as *u8) 58 w = sh_cat(h, w, "<p>Two rungs are built and gated GREEN, sovereign-compiled:</p>\n" as *u8) 59 w = sh_cat(h, w, "<table><tr><th>Rung</th><th>Capability</th><th>Gate</th></tr>\n" as *u8) 60 w = sh_cat(h, w, "<tr><td><strong>R0 market</strong></td><td>single-firm demand &rarr; profit, optimal price</td><td>GREEN 15/15</td></tr>\n" as *u8) 61 w = sh_cat(h, w, "<tr><td><strong>R1 competition</strong></td><td>N-firm competition: share, largest-remainder conservation, margin&times;volume</td><td>GREEN 20/20</td></tr>\n" as *u8) 62 w = sh_cat(h, w, "</table>\n" as *u8) 63 w = sh_cat(h, w, "<p class=\"why\">Conservation is enforced mechanically: competitor shares sum to the whole market via largest-remainder allocation &mdash; the engine cannot leak or fabricate demand. That correctness is what makes the lesson trustworthy.</p>\n" as *u8) 64 65 w = sh_section(h, w, "play" as *u8, "Play it" as *u8) 66 w = sh_cat(h, w, "<p>The game is live and updated as it is built &mdash; the published page is the feedback surface (emit &rarr; push &rarr; fetch-verify):</p>\n" as *u8) 67 w = sh_cat(h, w, "<ul><li><a href=\"/econsim\"><strong>Play EconSim &rarr; nishifamily.com/econsim</strong></a></li><li><a href=\"/wiki/products.html\">See it in the product catalog (serious games) &rarr;</a></li><li><a href=\"/wiki/roadmap.html\">Where it sits on the roadmap &rarr;</a></li></ul>\n" as *u8) 68 69 w = sh_refs_open(h, w) 70 w = sh_cat(h, w, "<li><code>nx_caplab_market</code> &mdash; R0 single-firm demand/profit/optimal-price (gate 15/15 GREEN)</li>\n" as *u8) 71 w = sh_cat(h, w, "<li><code>nx_caplab_compete</code> &mdash; R1 N-firm competition, share + conservation (gate 20/20 GREEN)</li>\n" as *u8) 72 w = sh_cat(h, w, "<li><code>nx_econsim_page</code> &mdash; emits the live app page (pushed to nishifamily.com/econsim, fetch-verified)</li>\n" as *u8) 73 w = sh_cat(h, w, "<li>Product catalog: <code>education-serious-games / capitalism-lab</code> (X-EDU-BIZ-001)</li>\n" as *u8) 74 w = sh_refs_close(h, w) 75 76 w = sh_footer_wl(h, w, wl, "econsim" as *u8, now) 77 78 let fd: i64 = sys_openat_wr(ES_OUT, 0x1a4) 79 if fd < 0 { sys_write(2, "FATAL: cannot open econsim_wiki.html\n" as *u8, 37); sys_exit(2); return 2 } 80 sys_write(fd, h, w) 81 sys_close(fd) 82 sys_write(1, "[nx_wiki_econsim_page] wrote econsim_wiki.html bytes=" as *u8, 53) 83 let nb: *u8 = sys_mmap(28); var k2: i64 = 0; var m2: i64 = w 84 if m2 == 0 { nb[0] = 48 as u8; k2 = 1 } 85 while m2 > 0 { nb[k2] = (48 + (m2 % 10)) as u8; m2 = m2 / 10; k2 = k2 + 1 } 86 var q: i64 = k2 - 1; while q >= 0 { let o1: *u8 = sys_mmap(1); o1[0] = nb[q]; sys_write(1, o1, 1); q = q - 1 } 87 sys_write(1, "\n" as *u8, 1) 88 sys_exit(0); return 0 89}