<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Minjia Hu</title>
    <description>The latest articles on DEV Community by Minjia Hu (@minjiahu).</description>
    <link>https://dev.to/minjiahu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4132423%2Ffac77607-9ec6-4cad-9d1a-e61c9bae4928.png</url>
      <title>DEV Community: Minjia Hu</title>
      <link>https://dev.to/minjiahu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/minjiahu"/>
    <language>en</language>
    <item>
      <title>Building interactive research reports with Python, Streamlit, and GitHub Pages</title>
      <dc:creator>Minjia Hu</dc:creator>
      <pubDate>Fri, 06 Nov 2026 12:31:39 +0000</pubDate>
      <link>https://dev.to/minjiahu/building-interactive-research-reports-with-python-streamlit-and-github-pages-5cmj</link>
      <guid>https://dev.to/minjiahu/building-interactive-research-reports-with-python-streamlit-and-github-pages-5cmj</guid>
      <description>&lt;p&gt;A chart can show that a research phrase is becoming more common. The next questions are harder: which institutions are working on it, and which papers should I read?&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;paper-trends&lt;/strong&gt; to connect those steps. It uses publication metadata from OpenAlex to generate interactive reports for academic conferences.&lt;/p&gt;

&lt;p&gt;You can try the &lt;a href="https://minjia-hu.github.io/paper-trends/cvpr.html" rel="noopener noreferrer"&gt;CVPR report&lt;/a&gt; without signing in. Click a phrase such as “diffusion models,” then click a related institution to keep exploring.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/Minjia-Hu/paper-trends" rel="noopener noreferrer"&gt;source code is on GitHub&lt;/a&gt;, under the MIT license.&lt;/p&gt;

&lt;h2&gt;
  
  
  Following a trend back to its papers
&lt;/h2&gt;

&lt;p&gt;The interaction starts with a phrase. Clicking it opens a panel with its yearly trend, related institutions, topics, and papers. Clicking an institution opens another view of its publication trends and characteristic phrases.&lt;/p&gt;

&lt;p&gt;Here is that interaction in the ECTC example, a conference focused on electronic packaging:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyrz86wlbst5sxr8gl6ik.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyrz86wlbst5sxr8gl6ik.gif" alt="ECTC report: explore a phrase, then a related institution" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The GIF shows an earlier interface snapshot, so individual figures may differ from the current online reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  One analysis pipeline, three ways to use it
&lt;/h2&gt;

&lt;p&gt;The project has three interfaces that share the same Python analysis code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A CLI for fetching data and generating reports.&lt;/li&gt;
&lt;li&gt;A Streamlit app for changing periods, comparing conferences, filtering papers, and exporting CSV files.&lt;/li&gt;
&lt;li&gt;Static HTML reports for sharing a particular analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pipeline is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve conference records from OpenAlex.&lt;/li&gt;
&lt;li&gt;Normalize and store the records locally.&lt;/li&gt;
&lt;li&gt;Calculate phrase trends, topics, and publication statistics.&lt;/li&gt;
&lt;li&gt;Build the report and its linked detail-panel data.&lt;/li&gt;
&lt;li&gt;Render the HTML output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sharing the analysis code keeps the counting rules consistent across the CLI, app, and reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping interactions in a static report
&lt;/h2&gt;

&lt;p&gt;The online demo runs on GitHub Pages. Clicking a phrase does not start a Python process or make an OpenAlex API request.&lt;/p&gt;

&lt;p&gt;The report generator precomputes the data needed by the detail panels. Browser-side JavaScript uses that data to display trends and navigate between related entities.&lt;/p&gt;

&lt;p&gt;This works well for a fixed report: the expensive analysis happens during generation, while readers can explore the result without installing anything or supplying an API key.&lt;/p&gt;

&lt;p&gt;There is a tradeoff. The report is a saved snapshot, and precomputed detail data adds to its size. Changing the analysis period or fetching another conference requires the local app or CLI and a new analysis.&lt;/p&gt;

&lt;p&gt;The public examples cover CVPR and ECTC from 2016 through 2025. The full Streamlit app runs locally, and fetching records requires an OpenAlex API key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Defining what a keyword trend means
&lt;/h2&gt;

&lt;p&gt;Counting every abstract that mentions a phrase once can include papers where the phrase is only background context.&lt;/p&gt;

&lt;p&gt;For the phrase trends, the project counts a paper when the normalized phrase appears:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In its title, or&lt;/li&gt;
&lt;li&gt;At least twice in its abstract.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The report compares shares of papers, which helps account for changes in the total number of publications.&lt;/p&gt;

&lt;p&gt;This is still a vocabulary-based measure. A paper can discuss a technique without using the exact phrase, and terminology can change over time. A falling phrase share does not necessarily mean the technique is being used less.&lt;/p&gt;

&lt;p&gt;Topic analysis is a separate view, using TF-IDF and non-negative matrix factorization (NMF). The resulting topics help organize the corpus, but they are not authoritative labels for a research field.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conference metadata needs checking
&lt;/h2&gt;

&lt;p&gt;One issue during validation was separating a main conference from its workshops.&lt;/p&gt;

&lt;p&gt;A source-name search could return both. Even records assigned to a main-conference source could contain metadata pointing to workshop proceedings.&lt;/p&gt;

&lt;p&gt;The fetch pipeline therefore uses source matching, configured DOI-prefix fallbacks, and checks for identifiable workshop records. Those checks use metadata supplied by OpenAlex, including source names and known workshop URL patterns.&lt;/p&gt;

&lt;p&gt;This improves the dataset, but it does not establish that the result exactly matches an official proceedings list. Coverage still depends on the upstream records.&lt;/p&gt;

&lt;p&gt;The practical lesson: a plausible paper count is not enough to validate a conference dataset. Inspecting source matches and unusual records can reveal problems that aggregate charts hide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recording when the data was fetched
&lt;/h2&gt;

&lt;p&gt;A report’s generation date and its data-fetch date describe different things.&lt;/p&gt;

&lt;p&gt;The project records a successful fetch timestamp in a sidecar file and associates it with the corpus using a SHA-256 hash. Reports can then show whether that provenance matches the data being analyzed.&lt;/p&gt;

&lt;p&gt;If the record is missing or does not match, the fetch date is shown as unknown. A file’s modification time is not used as a substitute: copying a dataset should not make it appear freshly fetched.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://minjia-hu.github.io/paper-trends/" rel="noopener noreferrer"&gt;Browse the online reports&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://minjia-hu.github.io/paper-trends/cvpr.html" rel="noopener noreferrer"&gt;Explore the CVPR example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Minjia-Hu/paper-trends" rel="noopener noreferrer"&gt;View the code and setup instructions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The project supports English and Chinese interfaces and reports.&lt;/p&gt;

&lt;p&gt;I’d be interested in feedback on the exploration workflow: when you notice a changing research phrase, what would you want to inspect next—institutions, related topics, or individual papers?&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>datascience</category>
      <category>webdev</category>
    </item>
    <item>
      <title>A browser arcade in plain TypeScript: 8 classic games, 35 kB, no framework</title>
      <dc:creator>Minjia Hu</dc:creator>
      <pubDate>Sat, 19 Sep 2026 05:50:26 +0000</pubDate>
      <link>https://dev.to/minjiahu/a-browser-arcade-in-plain-typescript-8-classic-games-35-kb-no-framework-41ha</link>
      <guid>https://dev.to/minjiahu/a-browser-arcade-in-plain-typescript-8-classic-games-35-kb-no-framework-41ha</guid>
      <description>&lt;p&gt;Play it: &lt;a href="https://minjia-hu.github.io/retro-arcade/" rel="noopener noreferrer"&gt;https://minjia-hu.github.io/retro-arcade/&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://github.com/Minjia-Hu/retro-arcade" rel="noopener noreferrer"&gt;https://github.com/Minjia-Hu/retro-arcade&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxzcnt1auwtwyhpvx9z6j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxzcnt1auwtwyhpvx9z6j.png" alt="Retro Arcade: eight classic games" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A retro-styled collection of browser games. Open the page and play, no install, no sign-up. Snake, Tetris, Breakout, Flappy, 2048, Minesweeper, Sudoku and Gomoku share one arcade-cabinet UI and work with both keyboard and touch.&lt;/p&gt;

&lt;p&gt;Beyond the basic rules, each game got the things that make you play one more round:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tetris: hold, hard drop, on-screen buttons&lt;/li&gt;
&lt;li&gt;2048: single-step undo&lt;/li&gt;
&lt;li&gt;Sudoku: pencil notes, auto-save&lt;/li&gt;
&lt;li&gt;Gomoku: two-player mode and three AI levels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw7qjofryxl19lz56u9ha.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw7qjofryxl19lz56u9ha.gif" alt="Tetris in play" width="472" height="690"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The numbers: plain TypeScript and Canvas 2D, zero runtime dependencies, about 35 kB gzipped for the whole build (fonts excluded); 269 unit tests and 28 Playwright end-to-end tests, all in CI; MIT licensed.&lt;/p&gt;

&lt;p&gt;Here are the parts of the implementation I think are worth writing down.&lt;/p&gt;
&lt;h2&gt;
  
  
  One cabinet, eight games
&lt;/h2&gt;

&lt;p&gt;The eight games share one shell: the top bar, the screen well, the result overlay, the key-hint bar. A game implements a single interface and receives a &lt;code&gt;GameContext&lt;/code&gt; with everything it is allowed to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;GameContext&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AudioFx&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// WebAudio-synthesised sound effects&lt;/span&gt;
  &lt;span class="nl"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ArcadeStorage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// localStorage wrapper&lt;/span&gt;
  &lt;span class="nl"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;InputService&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// keyboard + touch gestures&lt;/span&gt;
  &lt;span class="nf"&gt;overlay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;OverlayView&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// result card / start menu&lt;/span&gt;
  &lt;span class="nl"&gt;head&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// DOM slot above the screen&lt;/span&gt;
  &lt;span class="nl"&gt;side&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// side panel slot&lt;/span&gt;
  &lt;span class="nl"&gt;pad&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// touch-pad slot&lt;/span&gt;
  &lt;span class="nf"&gt;setHints&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hints&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To show a result card, a game makes one call and the shell draws it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;overlay&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GAME OVER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;tone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SCORE 000420&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;BEST 001330&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;▶ RETRY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;onPress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;retry&lt;/span&gt; &lt;span class="p"&gt;}],&lt;/span&gt;
  &lt;span class="na"&gt;hints&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SPACE / TAP TO RETRY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The payoff: result cards, pause, mute and back-to-hub look and behave the same across all eight games, while each game's code only deals with its own rules. Adding a ninth game does not touch the shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules and rendering never mix
&lt;/h2&gt;

&lt;p&gt;Each game is built around &lt;code&gt;logic.ts&lt;/code&gt; and &lt;code&gt;index.ts&lt;/code&gt; (Gomoku also has an AI module and a Worker). &lt;code&gt;logic.ts&lt;/code&gt; is state and rules only: no DOM, no Canvas, and the random source is passed in as a parameter. &lt;code&gt;index.ts&lt;/code&gt; draws the state and turns input into rule calls.&lt;/p&gt;

&lt;p&gt;In 2048, merging one row is an ordinary function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;slideLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt; &lt;span class="nl"&gt;gained&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tiles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;gained&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;gained&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// skip the tile that was merged in&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;SIZE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;gained&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its tests assert on input and output and run in Node, no browser needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;slideLine compresses and merges: [0,2,0,2] → [4,0,0,0] scores 4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;slideLine&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])).&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="na"&gt;gained&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This split earned its keep halfway through the project. There was a full visual redesign, from dark neon to the current warm paper look. It touched the rendering code, the shared shell and the stylesheet; the eight &lt;code&gt;logic.ts&lt;/code&gt; files and their tests did not change by a line. One command confirms it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="nt"&gt;--stat&lt;/span&gt; &amp;lt;base&amp;gt; &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="s1"&gt;'src/games/*/logic.ts'&lt;/span&gt; &lt;span class="s1"&gt;'tests/*-logic.test.ts'&lt;/span&gt;   &lt;span class="c"&gt;# must be empty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Boards on Canvas, controls in the DOM
&lt;/h2&gt;

&lt;p&gt;Grids, blocks and sprites are drawn, and the boards themselves take clicks on the Canvas. But the supporting controls, the number pad, the difficulty menu, the undo key, are real &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; elements. The reason is practical: real buttons come with focus rings, keyboard access and touch targets that are easy to size. Buttons painted on a Canvas need all of that written by hand, and it never comes out as well.&lt;/p&gt;

&lt;p&gt;The shell offers three DOM slots (above the screen, beside it, and a touch pad below). A game declares which ones it needs and the shell hands over the containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Gomoku AI runs in a Web Worker
&lt;/h2&gt;

&lt;p&gt;The Gomoku AI is minimax with alpha-beta pruning; the three difficulty levels are search depths 1, 2 and 4. Depth 4 on the main thread freezes the UI, so the search runs in a Worker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;worker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./ai.worker.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;module&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;postMessage&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;board&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;board&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="na"&gt;player&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;turn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;aiLevel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moving the search off-thread leaves one problem: the player can restart the game while the AI is thinking, and the old task's answer must not land on the new board. Every restart increments &lt;code&gt;token&lt;/code&gt;; the Worker's reply carries the token it was sent with, and the main thread checks it against the current game before using the move. This discards stale results, it does not cancel the old search. Keeping the Worker and ignoring stale replies avoids cancel-and-recreate logic; the cost is that the old search still burns CPU and can delay the next request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Size and first load
&lt;/h2&gt;

&lt;p&gt;No UI framework and no game engine means little runtime code to ship: the whole build is about 35 kB gzipped, fonts excluded. First load is a separate matter: the eight games load on demand through dynamic &lt;code&gt;import()&lt;/code&gt;. The hub loads only the shell and the router, and a game's module is fetched when you open it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;load&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./snake&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;createSnake&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are two different things: code splitting mostly reduces the first load, it does not by itself make the total build smaller.&lt;/p&gt;

&lt;p&gt;The only third-party requests are for Google Fonts. There is no backend; scores live in &lt;code&gt;localStorage&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  On working with AI
&lt;/h2&gt;

&lt;p&gt;The architecture and most of the code were written together with Claude Code. Every round of work starts with a short design note recording scope, trade-offs and where the result departs from the mockups; those live in &lt;code&gt;docs/design/&lt;/code&gt; in the repo. The lessons learned the hard way are collected in &lt;code&gt;CLAUDE.md&lt;/code&gt;, for example "a CSS inset shadow cannot cover a canvas" and "never auto-focus the result overlay's button, or one Space press triggers both the button and the game's own restart". They say more about how the project grew than the code does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known issues and what I would like to hear
&lt;/h2&gt;

&lt;p&gt;The controls could be easier to understand. Tetris's six touch buttons are icons only (⟳ rotate, ⇄ hold and so on), so a first-time player has to guess; hold can be used once per drop, and pressing it a second time does nothing without the UI saying why. The keyboard hint bar was missing the hold key (C); that is fixed. The touch labels and a "hold used" cue stay as they are for now: the first is a deliberate trade-off, the second would flicker on every piece.&lt;/p&gt;

&lt;p&gt;The mobile layout and feel are still being tuned. I would especially like to hear about anything that is hard to tap or easy to mis-tap, and which game you think is the most fun and which needs the most work. Comments here or a GitHub issue both work.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>opensource</category>
      <category>gamedev</category>
    </item>
  </channel>
</rss>
