Skip to content

ericbearyt/MCMCAlgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pachner Move Simulator

An interactive MCMC Triangulation Explorer that simulates 2-2 Pachner moves (diagonal flips) on a triangulated grid, using Metropolis-Hastings sampling with path length as the Hamiltonian.

Pachner Move Simulator

Features

  • Click to flip — Click any grid cell to perform a Pachner 2-2 move (diagonal flip)
  • BFS shortest path — Automatically finds and renders the shortest path from START → END
  • MCMC sampling — Metropolis-Hastings with configurable temperature and step count
  • Animated MCMC — Watch the Markov chain explore triangulation space in real-time
  • Energy histograms — Visualize the Boltzmann distribution over path lengths
  • Configurable grid — Resize from 2×2 to 10×10 cells

Quick Start (Web App)

cd web
python3 -m http.server 8080
# Open http://localhost:8080

Quick Start (C++ Terminal)

make
./pachner_sim              # Interactive mode
./pachner_sim -m 500       # MCMC batch mode (500 steps)
./pachner_sim -m 500 -t 0.5  # With temperature 0.5
./pachner_sim -s 6 6       # Custom grid size

How It Works

Pachner Moves

In 2D, a Pachner 2-2 move (also called a bistellar flip) flips the shared diagonal of two adjacent triangles in a triangulation. Given a quadrilateral divided by a \ diagonal, flipping it produces a / diagonal and vice versa.

MCMC Connection

Concept Implementation
State space All 2^(n×m) triangulations of the grid
Transition Pachner 2-2 move (diagonal flip)
Hamiltonian H Shortest path length from START → END
Ground state Triangulation minimizing path length
Metropolis criterion Accept if ΔE ≤ 0; else accept with prob exp(−ΔE/T)

Architecture

PachnerGrid (state)  →  PathFinder (BFS)  →  Renderer (Canvas/Terminal)
      ↑
  flip(r,c) = Pachner move = MCMC transition

Project Structure

MCMCAlgo/
├── web/               # Web application (localhost)
│   ├── index.html     # Main page
│   ├── styles.css     # Dark theme styling
│   └── app.js         # Grid, pathfinding, MCMC, Canvas rendering
├── main.cpp           # C++ interactive + MCMC batch mode
├── PachnerGrid.h      # Grid data structure with flip logic
├── PathFinder.h       # BFS shortest path
├── Renderer.h         # ANSI terminal renderer
└── Makefile           # C++17 build system

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors