How ncase/trust works
Project type and purpose
• This is a static, client-side, interactive educational web application (“The Evolution of Trust”).
• It uses HTML/CSS/JavaScript to present a series of slides and simulations about trust and game theory, runs entirely in the browser, and requires no backend server logic.
File structure
– Top level:
• index.html: the single-page entry point
• css/: site-wide styles (balloon tooltips, slide layouts)
• js/: all JavaScript, subdivided into core UI modules, third-party libraries, simulation logic, and slide definitions
• assets/: static assets (JSON data for animations/simulations, sounds, splash/tournament graphics)
• notes/ and peeps/: optional supplemental HTML and CSS for footnotes and credits
• words.html: all interactive text content
– js/core/: custom UI widgets (Buttons, Sliders, Loader, Scratcher, etc.)
– js/lib/: dependencies (Howler.js for audio, MinPubSub for events, PIXI.js indirectly via Pegasus, Q for promises)
– js/sims/: game-theory simulations (Iterated Prisoner’s Dilemma, Tournament, Sandbox UI, Splash screen)
– js/slides/: slide-by-slide definitions invoking sims and core UI
README for additional insights
– Describes the project as public-domain, client-side only, with no server components
– Lists all open-source libraries and assets used
– Explains translation workflow but not runtime architecture
a. Main components
1. Entry Point (index.html + words.html + CSS)
2. Core UI Module Layer (js/core): reusable widgets, layout managers, PubSub glue
3. Simulation Layer (js/sims): game-theory models and controllers
4. Slide Layer (js/slides): configuration for each interactive slide
5. Third-Party Libraries (js/lib): Howler (audio), Q (promises), MinPubSub (event bus), Pegasus (XHR), Tween.js (animations)
6. Asset Store (assets/…): JSON data, images, audio files
7. Supplemental Pages (notes/, peeps/)
b. Relationships and data flow
– Browser loads index.html → CSS and js/lib → main.js
– main.js initializes Loader (core module) → loads JSON assets (via Pegasus)
– Core modules register on MinPubSub bus → orchestrate UI updates, audio playback (Howler), animations (Tween.js)
– Simulation controllers (js/sims) publish simulation events (e.g., payoff results) → UI modules subscribe and render results
– Slide modules pick which simulation and UI combo to invoke
c. Architectural patterns and principles
– Modular JavaScript: separation into core widgets, sims, and slide configs
– Publish/Subscribe (MinPubSub) for decoupling modules
– Data-driven initialization: JSON asset files drive machine visuals, coin flips, payoffs
– Single-Page Application pattern without routing or server calls
d. Key technologies and frameworks
– HTML5/CSS3 for layout and styling (Balloon.css for tooltips)
– Vanilla JavaScript modules for application logic
– Howler.js for audio management
– Tween.js for animation timing
– MinPubSub for in-app event bus
– Q for promise management
– Pegasus for XHR-based asset loading
Elements
• Blue for custom modules (core, sims, slides)
• Green for third-party libraries
• Orange for static assets
– Annotation of PubSub event flows and asset requests