Skip to content

Instantly share code, notes, and snippets.

View greghelton's full-sized avatar

Greg Helton greghelton

View GitHub Profile
@greghelton
greghelton / swift_backgammon_readme.md
Last active May 12, 2026 09:54
Swift Model Training and Gameplay for Backgammon

A backgammon game with a trained AI opponent.

Here's what has been built:

BackgammonEngine — a complete Swift game engine with legal move generation, all backgammon rules, and the TD(λ) neural network
BackgammonTrainer — a self-play training harness that ran 500,000 episodes in under 50 minutes on your M4 Macbook Pro
BackgammonApp — a SwiftUI iPhone game where you play against the trained AI


Set which developer toolchain runs by default.

@greghelton
greghelton / ai.clj
Last active May 11, 2026 19:07
Claude's Backgammon Game in Clojure trains a model that you then play against.
(ns backgammon.ai
"TD-Gammon inspired reinforcement learning AI for backgammon.
Architecture:
- Neural network: input(198) → hidden(40) → output(1)
- Input: Tesauro's 198-feature encoding of board state
- Output: estimated probability that White wins
- Training: TD(λ) temporal difference learning
- Eligibility traces for credit assignment across moves
@greghelton
greghelton / commands.md
Last active May 10, 2026 06:48
Backgammon Game in clojure. I'm creating a game that I can use to train an AI model.

I'm using the Calva extension in IntelliJ IDEA and sometimes I run the game from the REPL.

(play-until-winner initial-game-state)

Sometimes I run it from the bash command line.

java -cp "lib/spec.alpha-0.6.249.jar:lib/core.specs.alpha-0.5.81.jar:lib/clojure-1.12.0.jar:src/main/clojure" clojure.main -i src/main/clojure/backgammon/core.clj -e "(in-ns 'backgammon.core)" -e "(play-until-winner initial-game-state)"

@greghelton
greghelton / main.clj
Last active May 9, 2026 12:35
Running Clojure with Maven etc
(ns my-project.core
(:require [clojure.spec.alpha :as s]))
;; Define a simple spec for a 'User' map
(s/def ::name string?)
(s/def ::age int?)
(s/def ::user (s/keys :req [::name ::age]))
(defn -main [& args]
(let [valid-data {::name "Greg" ::age 30}
@greghelton
greghelton / lisp_in_emacs.md
Last active May 13, 2026 04:52
Emacs and Lisp Notes

Install emacs on a Mac
Commands Run:
brew install emacs
/opt/homebrew/opt/emacs/bin/emacs --fg-daemon
open new terminal tab
emacsclient -c

Using emacs
Note that on the Mac keyboard, Meta is ⌥ and Control is ^

@greghelton
greghelton / FPvsOO.md
Last active May 11, 2026 00:08
Quote - Functional vs Object-Oriented Programming

Whenever I write some code to deal with data about people then functional programming seems to work best. Whenever I write some code to simulate people then object-oriented programming seems to work best.
— Michael Fogus

Object oriented programming makes code understandable by encapsulating moving parts. Functional programming makes code understandable by minimizing moving parts.
— Michael Feathers

• A function doesn’t have to be 100% pure to get many of the benefits of purity.
• Of course you don’t want to use the fact that it’s not 100% pure as an excuse for making it even less pure.
• A more functional programming style often results in more parameters to a function.
• A functional style does lead to more parameters but, it is much easier to test the functions in isolation.

@greghelton
greghelton / TestInterestExample.java
Last active April 27, 2026 05:58
IBM's Decimal Arithmetic Library for Java
import com.ibm.arithmetic.decimal.DecimalPrecision;
import com.ibm.arithmetic.decimal.daa.DAAVariable;
import com.ibm.arithmetic.decimal.daa.DAAPrecision;
import com.ibm.arithmetic.decimal.daa.DAAFactory;
import com.ibm.arithmetic.decimal.daa.DAADecimal;
import com.ibm.arithmetic.decimal.edit.Formatter;
public class TestInterestExample {
private static final DAAFactory df = DAAFactory.INSTANCE;
@greghelton
greghelton / Install-Java-Devkit-and-Tools-on-Mac
Created May 20, 2025 19:45
Install the Adoptium Temurin JDK and other tools for the Java developer environment via Homebrew
Install homebrew per the instructions here: https://brew.sh/
brew install --cask temurin
brew install --cask intellij-idea-ce
brew install maven
brew install kotlin
@greghelton
greghelton / MS-SQL-Server-setup.md
Last active May 13, 2025 23:49
Setting up MS SQL Server in Docker on Mac.

% docker run --platform linux/amd64 -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=your-password"
-p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2022-latest

% docker ps

% brew install --no-quarantine mssql-tools

% sqlcmd -S localhost -U sa -P 'your-password'

The Lost Decades

A friend claims that software design evolved as an engineering disipline due to the move from waterfall SDLC (systems development lifecycle) to the agile project management process. He claims that the move from waterfall SDLC to agile methodology is what propelled application design from monolithic style applications to modular code that works with unit testing frameworks.

The first reference to SDLC dates to a 1968 software conference (https://en.wikipedia.org/wiki/NATO_Software_Engineering_Conferences) and ironically, waterfall SDLC was not proposed as a methodology that would succeed but rather it was presented as the antithesis of a workable methodology. His thesis is that methodology impacted the design of application code, pushing it from monolithic to modular. I too am interested in how the style of application code evolved from monolithic programs to modular code. Was it a top down movement driven by methodology or did programmers develop new goals for the code they wrote, going