Group 16 · IF3070 Foundations of Artificial Intelligence · STEI ITB
A web interface for solving the 5×5×5 diagonal magic cube with local search and metaheuristic algorithms.
This repository holds a SvelteKit application that renders the cube in 3D, plots the
objective function value over the course of the search, and replays the search as an
animation. The algorithms themselves do not run in the browser: the app calls a Go + Fiber
solver API that lives in a separate repository, magic-cube-core.
Built with
SvelteKit
Chart.js
Tailwind
Vite
Links — Live demo · Solver API · Report (PDF, Indonesian)
Make sure the following are installed:
- Node.js (version 20 or newer): https://nodejs.org
- Git: https://git-scm.com/downloads
-
Clone this repository:
git clone https://github.com/fetiai/magic-cube.git cd magic-cube -
Install dependencies:
npm install
-
Start the development server:
npm run dev
Open
http://localhost:8000/magic-cube/. -
Build for production:
npm run build npm run preview
The build produces static files in the
build/directory, ready to be served by GitHub Pages with no Node runtime.
All settings are read from environment variables at build time. Their values
are inlined into the bundle, so changing one requires a rebuild. Copy
.env.example to .env.local for local development.
| Variable | Default | Description |
|---|---|---|
PUBLIC_MAGIC_CUBE_API |
https://magic-cube.faizath.com |
Address of the solver API |
BASE_PATH |
/magic-cube |
Subpath the site is served from |
The app is deployed to https://fetiai.github.io/magic-cube/, which is a
subpath rather than a domain root. BASE_PATH is what prefixes every asset
address; leaving it empty produces a build for a domain root.
⚠️ The API must allow this page's origin. The page and the API always sit on different origins, so CORS applies. SetMAGIC_CUBE_CORS_ORIGINSon the server to includehttps://fetiai.github.iofor production and the Vite development server's address for local work. Note that an origin consists of the scheme and host only — the/magic-cube/path is not part of it. Without this, every request is blocked by the browser with no meaningful message, and the symptoms look like a dead server.
To develop without a deployed API, run the solver locally from the
magic-cube-core repository with go run ./cmd/server, then set
PUBLIC_MAGIC_CUBE_API=http://127.0.0.1:3000.
- Pick an algorithm. The list, along with each algorithm's parameters, defaults and bounds, comes straight from the API rather than being written into the app.
- Fill in parameters if needed. Leaving a field empty means using the server's default.
- Fill in
seedif you want an exactly repeatable run. If left empty, the server picks a seed and reports it with the result. - Press Run. The search runs as a background job, and its progress is shown while it proceeds. A running search can be cancelled.
- Once it finishes, use the slider and the play button to replay the search, one swap at a time.
genetic is a population method: it has no single sequence of swaps to replay,
so its initial and final cubes are shown side by side as static views next to
the chart, with no slider.
Thalita Zahra Sutejo 18222023 |
|
Irfan Musthofa 18222056 |
|
Eleanor Cordelia 18222059 |
|
Muhammad Faiz Atharrahman 18222063 |
|
IF3070 Foundations of Artificial Intelligence · STEI ITB · 2024/2025-1
More at fetiai.github.io




