Initial project version
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Ein Fehler oder ein unerwartetes Verhalten in der Test-/Audit-Suite.
|
||||
title: '[Bug] '
|
||||
labels: ['bug', 'needs triage']
|
||||
---
|
||||
|
||||
## Beschreibung
|
||||
|
||||
Beschreibe knapp, was fehlerhaft ist und was du stattdessen **erwartet** hättest.
|
||||
|
||||
**Fehlermeldung / Exit-Code (falls vorhanden):**
|
||||
|
||||
```text
|
||||
```
|
||||
|
||||
## Reproduktion
|
||||
|
||||
Wie kann der Fehler reproduziert werden? Bitte als schrittweise Anleitung:
|
||||
|
||||
1. Gehe zu …
|
||||
2. Führe aus `npm run …`
|
||||
3. Siehe Fehler …
|
||||
|
||||
**Betroffenes Skript:**
|
||||
|
||||
- [ ] `tests/audit.mjs`
|
||||
- [ ] `tests/selfplay.mjs`
|
||||
- [ ] `tests/perf-test.mjs`
|
||||
- [ ] `tests/report.mjs`
|
||||
- [ ] CI-Workflow (`.gitea/workflows/aegis.yml`)
|
||||
- [ ] Sonstiges: …
|
||||
|
||||
## Erwartetes vs. tatsächliches Verhalten
|
||||
|
||||
| | Verhalten |
|
||||
|---|---|
|
||||
| **Erwartet** | … |
|
||||
| **Tatsächlich** | … |
|
||||
|
||||
## Erzeugte Artefakte (falls vorhanden)
|
||||
|
||||
Füge relevante Ausschnitte bei (z. B. `audit-result.json`, `perf-result.json`, `selfplay-results.json`):
|
||||
|
||||
```json
|
||||
```
|
||||
|
||||
## Umgebung
|
||||
|
||||
| Feld | Wert |
|
||||
|---|---|
|
||||
| OS | |
|
||||
| Node.js-Version | |
|
||||
| Playwright / Chromium | |
|
||||
| Game-`Aegis-Labyrinth.html`-Version | |
|
||||
| Suite-Version | |
|
||||
|
||||
## Zusätzliche Hinweise
|
||||
|
||||
Screenshots, Logs oder weitere Kontext-Informationen.
|
||||
@@ -0,0 +1,11 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Dokumentation (in-Repo)
|
||||
url: https://git.spaeth.biz/Lila-Kuh/Laby#dokumentation
|
||||
about: API, Audits, CI und Ausgabe-Formate sind in docs/ dokumentiert.
|
||||
- name: Changelog & Versionen
|
||||
url: https://git.spaeth.biz/Lila-Kuh/Laby/blob/main/CHANGELOG.md
|
||||
about: Laufende Version + Historie (Game + Suite).
|
||||
- name: Frage / allgemeine Hilfe
|
||||
url: https://git.spaeth.biz/Lila-Kuh/Laby/issues/new?template=bug_report.md
|
||||
about: Falls du dir unsicher bist, welcher Template-Typ passt.
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Ein Vorschlag für eine neue Funktion, Erweiterung oder Verbesserung.
|
||||
title: '[Feat] '
|
||||
labels: ['enhancement', 'needs triage']
|
||||
---
|
||||
|
||||
## Kurzzusammenfassung
|
||||
|
||||
Worum geht es in einem Satz?
|
||||
|
||||
## Motivation
|
||||
|
||||
Warum ist diese Funktion / Erweiterung wichtig? Welchen konkreten Nutzen bringt sie?
|
||||
|
||||
- **Problem / Ziel:** …
|
||||
- **Nutzen für das Projekt:** …
|
||||
|
||||
## Vorschlag (konkret)
|
||||
|
||||
Beschreibe den gewünschten Ablauf oder die gewünschte Implementierung. Je konkreter, desto besser.
|
||||
|
||||
- Betroffene Skripte / Bereiche:
|
||||
- [ ] `tests/audit.mjs`
|
||||
- [ ] `tests/selfplay.mjs`
|
||||
- [ ] `tests/perf-test.mjs`
|
||||
- [ ] `tests/report.mjs`
|
||||
- [ ] CI-Workflow (`.gitea/workflows/aegis.yml`)
|
||||
- [ ] Dokumentation (`docs/`)
|
||||
- [ ] Sonstiges: …
|
||||
|
||||
## Alternativen (falls vorhanden)
|
||||
|
||||
Welche anderen Ansätze hast du schon in Betracht gezogen oder kennst du?
|
||||
|
||||
## Zusätzliche Hinweise
|
||||
|
||||
Beispiele, Links, Mockups oder verwandte Issues.
|
||||
@@ -0,0 +1,49 @@
|
||||
---
|
||||
name: Performance Issue
|
||||
about: Ein Performance-Problem (FPS, Heap, Frame-Timing) im getesteten Game oder in der Suite.
|
||||
title: '[Perf] '
|
||||
labels: ['performance', 'needs triage']
|
||||
---
|
||||
|
||||
## Zusammenfassung
|
||||
|
||||
Kurz: Was ist langsam / wo genau?
|
||||
|
||||
## Messwerte
|
||||
|
||||
| Metrik | Wert | Ziel |
|
||||
|---|---|---|
|
||||
| FPS (Ø) | | ≥ 55 |
|
||||
| Heap (used) | | |
|
||||
| Frame-Timing (max) | | |
|
||||
|
||||
## Setup / Lastprofil
|
||||
|
||||
| Feld | Wert |
|
||||
|---|---|
|
||||
| Level (Index / Name) | |
|
||||
| Anzahl Türme | |
|
||||
| Messdauer (ms) | |
|
||||
| Anzahl Feinde | |
|
||||
|
||||
## `perf-result.json` (Ausschnitt)
|
||||
|
||||
```json
|
||||
```
|
||||
|
||||
## Beobachtete Problemzonen
|
||||
|
||||
- [ ] Particles (`Game.particles`)
|
||||
- [ ] Projectiles (`Game.projectiles`)
|
||||
- [ ] Holograms (`Game.holograms`)
|
||||
- [ ] Beams (`Game.beams`)
|
||||
- [ ] Enemy-Update (O(n²))
|
||||
- [ ] Sonstiges: …
|
||||
|
||||
## Erwartung
|
||||
|
||||
Was sollte erreicht werden (FPS-Ziel, Heap-Limit, spürbar glatter)?
|
||||
|
||||
## Hinweise / Reproduktion
|
||||
|
||||
Level, Turm-Aufstellung, Schritte. Siehe auch `docs/06_Refactoring_Game.md`.
|
||||
@@ -0,0 +1,120 @@
|
||||
name: Aegis CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'Aegis-Labyrinth.html'
|
||||
- 'tests/*.mjs'
|
||||
- '.gitea/workflows/aegis.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'Aegis-Labyrinth.html'
|
||||
- 'tests/*.mjs'
|
||||
- '.gitea/workflows/aegis.yml'
|
||||
schedule:
|
||||
- cron: '0 2 * * *' # Nightly: 02:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: gitea/checkout
|
||||
|
||||
- uses: gitea/setup-node
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install Playwright + Chromium
|
||||
run: npm i playwright && npx playwright install --with-deps chromium
|
||||
|
||||
- name: Run audits
|
||||
run: node tests/audit.mjs
|
||||
|
||||
- name: Assert audit results
|
||||
run: |
|
||||
node -e "
|
||||
const r = JSON.parse(require('fs').readFileSync('audit-result.json','utf8'));
|
||||
const fail = [];
|
||||
|
||||
// 1) Connectivity: jede Welle start- & exit-reachbar.
|
||||
if (!r.self.connectivity.every(c => c.reachable && c.exit)) fail.push('connectivity');
|
||||
|
||||
// 2) Attacks: jeder Turm muss entweder Projektile, Holos oder Schaden erzeugen.
|
||||
const badAttacks = r.self.attacks.filter(a => (a.projectiles||0)===0 && (a.holos||0)===0 && a.hurt===false);
|
||||
if (badAttacks.length) fail.push('attacks:' + badAttacks.map(a=>a.id).join(','));
|
||||
|
||||
// 3) Skills: alle Skills müssen Rank >= 4 erreichen.
|
||||
if (r.self.skills.some(s => (s.rank||0) < 4)) fail.push('skills');
|
||||
|
||||
// 4) Placement: Wall akzeptiert, Path abgelehnt.
|
||||
if (!r.self.placement || r.self.placement.wallAccepted === false || r.self.placement.pathAccepted === true) fail.push('placement');
|
||||
|
||||
if (fail.length) { console.error('FAIL:', fail.join(' | ')); process.exit(1); }
|
||||
console.log('✅ All audits passed');
|
||||
"
|
||||
|
||||
- name: Upload audit artifact
|
||||
if: always()
|
||||
uses: gitea/upload-artifact
|
||||
with:
|
||||
name: audit-result
|
||||
path: audit-result.json
|
||||
|
||||
perf:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: gitea/checkout
|
||||
- uses: gitea/setup-node
|
||||
with:
|
||||
node-version: 20
|
||||
- run: npm i playwright && npx playwright install --with-deps chromium
|
||||
- name: FPS measurement
|
||||
run: node tests/perf-test.mjs 10000 50
|
||||
- name: Upload perf artifact
|
||||
if: always()
|
||||
uses: gitea/upload-artifact
|
||||
with:
|
||||
name: perf-result
|
||||
path: perf-result.json
|
||||
|
||||
selfplay:
|
||||
needs: audit
|
||||
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: gitea/checkout
|
||||
- uses: gitea/setup-node
|
||||
with:
|
||||
node-version: 20
|
||||
- run: npm i playwright && npx playwright install --with-deps chromium
|
||||
- name: Run 50 self-play episodes
|
||||
run: node tests/selfplay.mjs 50
|
||||
- name: Upload self-play artifact
|
||||
if: always()
|
||||
uses: gitea/upload-artifact
|
||||
with:
|
||||
name: selfplay-results
|
||||
path: selfplay-results.json
|
||||
|
||||
report:
|
||||
needs: [audit, perf]
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: gitea/checkout
|
||||
- uses: gitea/setup-node
|
||||
with:
|
||||
node-version: 20
|
||||
- name: Download artifacts
|
||||
uses: gitea/download-artifact
|
||||
- name: Build HTML report
|
||||
run: node tests/report.mjs
|
||||
- name: Upload report
|
||||
uses: gitea/upload-artifact
|
||||
with:
|
||||
name: report
|
||||
path: report.html
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
# Game-Source (extern, manuell hinzufügen – siehe README)
|
||||
Aegis-Labyrinth.html
|
||||
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Test artifacts / output (generiert durch npm-Scripts)
|
||||
*-result.json
|
||||
*-results.json
|
||||
report.html
|
||||
audit-final.png
|
||||
*.png
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
@@ -0,0 +1,86 @@
|
||||
# Aegis Labyrinth – Changelog / Version History
|
||||
|
||||
> Zentrales **Version-Log** für das Game (`Aegis-Labyrinth.html`) **und** die Test- & Audit-Suite.
|
||||
> Es beantwortet die Frage: *„Welche Version hat das Game und wie ist es dorthin gekommen?"*
|
||||
>
|
||||
> **Konvention:**
|
||||
> - Chronologisch, neuestens oben.
|
||||
> - Versionsschema: SemVer `MAJOR.MINOR.PATCH` (z. B. `1.0.2`).
|
||||
> - Einträge: `## [Version] – [YYYY-MM-DD]` + Stichpunkte (Neu / Geändert / Fix / Impact).
|
||||
> - Jede Code-/Doku-Änderung an Game oder Suite wird hier **und** in `docs/05_Tasks_Backlog.md` vermerkt.
|
||||
>
|
||||
> **Single Source of Truth für die laufende Version:**
|
||||
> - Game: `const GAME_VERSION` in `Aegis-Labyrinth.html`
|
||||
> - Suite: `version` in `package.json`
|
||||
|
||||
---
|
||||
|
||||
## Aktuelle Versionen (Snapshot)
|
||||
|
||||
| Komponente | Version | Quelle |
|
||||
|---|---|---|
|
||||
| **Game** (`Aegis-Labyrinth.html`) | **`1.0.2`** | `const GAME_VERSION = '1.0.2';` |
|
||||
| **Test- & Audit-Suite** | **`1.0.0`** | `package.json → version` |
|
||||
| Skilltree-Schema (Persistenz) | `2` | `const SKILLTREE_VERSION = 2;` |
|
||||
| Campaign-Progress-Schema | `1` | `saveCampaignProgress()` payload `version:1` |
|
||||
| Custom-Level-Schema | `1` | `saveCustomLevel()` payload `version:1` |
|
||||
|
||||
> ⚠️ `SKILLTREE_VERSION` / Persistenz-`version`-Felder sind **Schema-Versionen** (kompatibles Lesen/
|
||||
> Schreiben von `localStorage`), **keine** Spiel-Release-Versionen. Nicht mit `GAME_VERSION` verwechseln.
|
||||
|
||||
---
|
||||
|
||||
## Game – `Aegis-Labyrinth.html`
|
||||
|
||||
### [1.0.2] – 2026-08-29 (aktuell)
|
||||
|
||||
- **Status:** Laufende Version, in `Aegis-Labyrinth.html` als `GAME_VERSION` gepinnt.
|
||||
- **Features (laut aktueller Source):**
|
||||
- Single-File-Browser-Game (HTML/CSS/JS, keine Build-Schritte).
|
||||
- Kampagne mit Levelauswahl (`Level 0–11`), Normal + Endless-Modus.
|
||||
- Skilltree (`SKILL_MAX_LEVEL = 3`, `SKILLTREE_VERSION = 2`) + Campaign-Progress in `localStorage`.
|
||||
- **Leveleditor** mit Custom-Layout-Speicherung (`CUSTOM_LEVEL_KEY`, `version:1`-Schema).
|
||||
- Debug-Konsole (F12) + In-Game-Debug-API `window.__AEGIS_DEBUG__`.
|
||||
- Drei eingebaute Audits: `runSelfAudit`, `runExtensionAudit`, `runRedesignAudit`.
|
||||
- i18n-Grundstruktur (`data-i18n`-Attribute, `options`/`help`).
|
||||
- **Impact:** Version, die die Test-Suite in `tests/*` primär gegenläuft.
|
||||
|
||||
### [1.0.x] – vorherige Releases
|
||||
|
||||
> **Hinweis:** Für frühere Versionen (`1.0.0`, `1.0.1`, …) liegt **kein** nachvollziehbares
|
||||
> Commit-/Changelog-Verzeichnis vor (Git-Verzeichnis im Repo ist aktuell nicht initialisiert).
|
||||
> Die ersten Releases sind daher nur als *historisch* vermerkt; Details wurden nicht rekonstruiert.
|
||||
|
||||
- `[1.0.0]` – Initialer Release (Grundgerüst: Map, Tower-Placement, Wave-Loop, Debug-API).
|
||||
- `[1.0.1]` – Erweiterte Debug-/Audit-Funktionalität, Skilltree v2-Persistenz.
|
||||
- `[1.0.2]` – Leveleditor + Custom-Layout-Persistenz, i18n-Grundlagen (aktueller Stand).
|
||||
|
||||
> ⚠️ Die drei letzten Punkte sind **Rekonstruktion aus der Source** (Feature-Inventar), **nicht**
|
||||
> aus Git-History. Sobald Git inititialisiert ist, bitte durch echte Commits ersetzen/verifizieren.
|
||||
|
||||
---
|
||||
|
||||
## Test- & Audit-Suite
|
||||
|
||||
### [1.0.0] – 2026-08-28 (aktuell)
|
||||
|
||||
- **Neu:** Vollständige Playwright-Suite: `audit.mjs`, `selfplay.mjs`, `perf-test.mjs`, `report.mjs`.
|
||||
- **Neu:** Doku-Set `docs/01–06` (Debug-API, Audits, CI, Resultate, Tasks/Backlog, Refactoring-Advisory).
|
||||
- **Geändert:** README auf Test-Suite-Framing umgestellt; Hinweis auf manuelle `Aegis-Labyrinth.html`.
|
||||
- **Fix:** CI-Gate prüft `summary.fail` (statt nicht existierendem `"failed"`); Schemata an echten Skript-Output angepasst.
|
||||
- **Impact:** Suite lauffähig & dokumentiert; Details in `docs/05_Tasks_Backlog.md` §2.
|
||||
|
||||
---
|
||||
|
||||
## Analyse- & Änderungs-Log (laufend)
|
||||
|
||||
> Jeder Arbeitsschritt, den **diese Assistenten-Sitzung** an Game oder Suite vornimmt oder analysiert,
|
||||
> wird hier mit Datum + Kurzbeschreibung festgehalten. Abgeschlossene, größer werdende Tasks zusätzlich
|
||||
> in `docs/05_Tasks_Backlog.md` §2 spiegeln.
|
||||
|
||||
### [2026-08-29] Version-Erfassung etabliert
|
||||
|
||||
- **Analyse:** `GAME_VERSION = '1.0.2'` in `Aegis-Labyrinth.html` identifiziert; Suite auf `1.0.0` (`package.json`).
|
||||
- **Geändert:** Diese Datei (`CHANGELOG.md`) angelegt – zentrales Version-/Changelog-Register.
|
||||
- **Neu:** „Aktuelle Versionen (Snapshot)" + Schema- vs. Release-Versionen entkoppelt.
|
||||
- **Impact:** Versionsstand ist jetzt auf einen Blick dokumentiert und nachvollziehbar.
|
||||
@@ -0,0 +1,232 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
testtest
|
||||
Copyright (C) 2026 Lila-Kuh
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
testtest Copyright (C) 2026 Lila-Kuh
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,187 @@
|
||||
# Aegis Labyrinth – Test- & Audit-Suite
|
||||
|
||||
> Automatisierte **Test-, Audit- und Performance-Suite** für das Single-File-Browser-Game `Aegis-Labyrinth.html`.
|
||||
> Dieses Repo enthält **nicht** das Spiel selbst – es enthält die Werkzeuge, um die Game-Source-Datei im vollen Umfang zu testen, zu auditieren und als Audit-Bericht auszuwerten.
|
||||
|
||||
**Ziel:** Jede Änderung an `Aegis-Labyrinth.html` automatisch validieren – Funktionalität (3 Audits), Regressionsschutz (Self-Play), Performance (FPS/Heap) und einen maschinenlesbaren + HTML-Bericht erzeugen.
|
||||
|
||||

|
||||
|
||||
> 📜 **Version & Historie:** Laufende Version + Changelog in [`CHANGELOG.md`](./CHANGELOG.md)
|
||||
> (aktuell: **Game `1.0.2`**, **Suite `1.0.0`**).
|
||||
|
||||
## ⚠️ Voraussetzung: Game-Datei manuell legen
|
||||
|
||||
Die zu testende Datei **`Aegis-Labyrinth.html`** gehört **nicht** zu diesem Repo (wird nicht versioniert).
|
||||
Lege/kopiere sie **vor** dem ersten Testlauf in die Projekt-Root:
|
||||
|
||||
```
|
||||
Laby/
|
||||
├── Aegis-Labyrinth.html ← ⚠️ MANUELL HINZUFÜGEN (Source of truth, extern)
|
||||
└── ...
|
||||
```
|
||||
|
||||
Alle Test-Skripte erwarten die Datei an genau diesem Ort (Projekt-Root).
|
||||
Fehlt sie, bricht `audit.mjs` mit `❌ Aegis-Labyrinth.html nicht gefunden!` ab.
|
||||
|
||||
> Tipp: Damit die Datei nicht versehentlich committet wird, `Aegis-Labyrinth.html` in die `.gitignore` aufnehmen.
|
||||
|
||||
---
|
||||
|
||||
## Was wird getestet?
|
||||
|
||||
| Suite | Skript | Was es prüft | Ausgabe |
|
||||
|---|---|---|---|
|
||||
| **Audit** | `tests/audit.mjs` | Die 3 eingebauten Audits: `runSelfAudit`, `runExtensionAudit`, `runRedesignAudit` + JS-Page-Errors + Assertions | `audit-result.json` |
|
||||
| **Self-Play** | `tests/selfplay.mjs` | Deterministischer Bot spielt Level 0 durch → Regressionsschutz & Balance | `selfplay-results.json` |
|
||||
| **Performance** | `tests/perf-test.mjs` | FPS unter Last (schweres Level + viele Türme) + Heap | `perf-result.json` |
|
||||
| **Report** | `tests/report.mjs` | Fügt alle `*-result.json` zu einem HTML-Report zusammen | `report.html` |
|
||||
|
||||
---
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
# 1. Dependencies (Playwright + Chromium)
|
||||
npm install
|
||||
npx playwright install chromium
|
||||
|
||||
# 2. Game-Datei in die Projekt-Root legen
|
||||
# → Aegis-Labyrinth.html manuell kopieren (siehe oben)
|
||||
```
|
||||
|
||||
> `node >= 18` wird empfohlen (Top-Level-`await` in den `.mjs`-Skripten).
|
||||
|
||||
---
|
||||
|
||||
## Quick-Start / Ausführung
|
||||
|
||||
Jedes Skript ist auch als npm-Script verfügbar:
|
||||
|
||||
```bash
|
||||
npm run audit # node tests/audit.mjs → audit-result.json
|
||||
npm run selfplay # node tests/selfplay.mjs [n] → selfplay-results.json (Default 10 Episoden)
|
||||
npm run perf # node tests/perf-test.mjs [ms] [towers] → perf-result.json (Default 15000ms / 50 Türme)
|
||||
npm run report # node tests/report.mjs → report.html
|
||||
|
||||
# Kompletter Lauf (Audit + Self-Play + Perf)
|
||||
npm test
|
||||
```
|
||||
|
||||
Direkt aufrufen (nützlich für CI / Parameter):
|
||||
|
||||
```bash
|
||||
node tests/selfplay.mjs 50 # 50 Episoden
|
||||
node tests/perf-test.mjs 30000 80 # 30 s messen, 80 Türme
|
||||
```
|
||||
|
||||
### Exit-Code-Vertrag
|
||||
|
||||
| Skript | `exit 0` | `exit ≠ 0` |
|
||||
|---|---|---|
|
||||
| `audit.mjs` | alle Assertions grün, keine Page-Errors | ≥ 1 Fehler (Assertion / Page-Error) → `1`, Crash → `2` |
|
||||
| `perf-test.mjs` | FPS ≥ Zielwert (55) | FPS < Zielwert → `1` |
|
||||
| `selfplay.mjs` | (liefert immer 0) | – |
|
||||
| `report.mjs` | (liefert immer 0) | – |
|
||||
|
||||
---
|
||||
|
||||
## Die getestete Debug-API
|
||||
|
||||
Die Suite hängt vollständig an der **öffentlichen Debug-API** des Games (`window.__AEGIS_DEBUG__`) plus frei im Global Scope liegenden Funktionen. Details: [`docs/01_Debug_API.md`](./docs/01_Debug_API.md).
|
||||
|
||||
```js
|
||||
// State lesen
|
||||
window.__AEGIS_DEBUG__.getState()
|
||||
|
||||
// Level / Credits / Wave
|
||||
window.__AEGIS_DEBUG__.selectLevel(0)
|
||||
window.__AEGIS_DEBUG__.setCredits(999999)
|
||||
window.__AEGIS_DEBUG__.startWave()
|
||||
|
||||
// Die 3 Audits
|
||||
window.__AEGIS_DEBUG__.runSelfAudit()
|
||||
window.__AEGIS_DEBUG__.runExtensionAudit()
|
||||
window.__AEGIS_DEBUG__.runRedesignAudit()
|
||||
```
|
||||
|
||||
> **Wichtig (Playwright):** `const`/`let` im Global Scope (`TOWER_TYPES`, `Game`, `placeTower`, `buySkill`, `simulate`, …) liegen **nicht** auf `window`. In `page.evaluate()` müssen sie als **bare Identifier** referenziert werden.
|
||||
|
||||
---
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```
|
||||
Laby/
|
||||
├── Aegis-Labyrinth.html # ⚠️ Game-Source – MANUELL HINZUFÜGEN (nicht versioniert)
|
||||
├── package.json # npm-Scripts (audit, selfplay, perf, report, test, setup)
|
||||
├── package-lock.json
|
||||
├── .gitignore
|
||||
├── LICENSE # GNU GPL v3
|
||||
├── README.md # diese Datei
|
||||
├── CHANGELOG.md # Version-Historie (Game + Suite) & Änderungs-Log
|
||||
├── tests/
|
||||
│ ├── audit.mjs # Playwright-Audit-Suite (3 Audits + Assertions)
|
||||
│ ├── selfplay.mjs # Self-Play-Bot (deterministisch, Level 0)
|
||||
│ ├── perf-test.mjs # FPS/Heap-Messung unter Last
|
||||
│ └── report.mjs # HTML-Report-Generator (report.html)
|
||||
└── docs/
|
||||
├── 01_Debug_API.md # __AEGIS_DEBUG__-API & In-Game-Console (Test-Orakel)
|
||||
├── 02_Audits.md # Die 3 Audits im Detail + Assertions + Exit-Codes
|
||||
├── 03_Automatisierung_CI.md # Playwright-Automatisierung, Self-Play, Perf, CI
|
||||
├── 04_Resultate_Report.md # Ausgabe-Dateien & report.html (Schema-Referenz)
|
||||
├── 05_Tasks_Backlog.md # Implementierte Tasks (Changelog) & Backlog
|
||||
└── 06_Refactoring_Game.md # (Advisory) Refactoring-/Performance-Empfehlungen für die Game-Datei
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Erzeugte Artefakte (werden NICHT committet)
|
||||
|
||||
| Datei | Von | Beschreibung |
|
||||
|---|---|---|
|
||||
| `audit-result.json` | `audit.mjs` | Raw-Audit-Reports + Assertions + Page-Errors + Summary |
|
||||
| `selfplay-results.json` | `selfplay.mjs` | Episoden-Log + Win-Rate + Aggregates |
|
||||
| `perf-result.json` | `perf-test.mjs` | FPS, Heap, Setup-Metadaten |
|
||||
| `report.html` | `report.mjs` | Zusammengefasster, menschlich lesbarer CI-Report |
|
||||
| `audit-final.png` | `audit.mjs` | Finaler Screenshot des Headless-Browsers |
|
||||
|
||||
Schema-Details: [`docs/04_Resultate_Report.md`](./docs/04_Resultate_Report.md).
|
||||
|
||||
---
|
||||
|
||||
## CI / Automatisierung
|
||||
|
||||
Empfohlene Stufen (Details in [`docs/03_Automatisierung_CI.md`](./docs/03_Automatisierung_CI.md)):
|
||||
|
||||
| Stufe | Inhalt | Wann |
|
||||
|---|---|---|
|
||||
| **Pre-Commit / Push** | `npm run audit` (schnell) | bei jedem Commit / PR |
|
||||
| **Nightly** | Audit + `selfplay.mjs 50` + `perf-test.mjs` | zeitplangetrieben |
|
||||
| **Release** | Audit + `selfplay.mjs 500` + Perf + Report-Artifact | Tagging |
|
||||
|
||||
> ⚠️ In CI muss die `Aegis-Labyrinth.html` als **Secret/Artifact** bereitgestellt werden, da sie nicht im Repo liegt.
|
||||
|
||||
---
|
||||
|
||||
## Dokumentation
|
||||
|
||||
| Datei | Inhalt |
|
||||
|---|---|
|
||||
| [`01_Debug_API.md`](./docs/01_Debug_API.md) | Komplette `__AEGIS_DEBUG__`-API + In-Game-Debug-Console |
|
||||
| [`02_Audits.md`](./docs/02_Audits.md) | Was `self`/`extension`/`redesign` prüfen, Assertions, Exit-Codes |
|
||||
| [`03_Automatisierung_CI.md`](./docs/03_Automatisierung_CI.md) | Playwright-Aufruf, Self-Play-Konzept, Perf, CI-Workflows |
|
||||
| [`04_Resultate_Report.md`](./docs/04_Resultate_Report.md) | JSON-Schemata + `report.html`-Aufbau |
|
||||
| [`05_Tasks_Backlog.md`](./docs/05_Tasks_Backlog.md) | Abgeschlossene Tasks (Changelog) + offenes Backlog |
|
||||
| [`06_Refactoring_Game.md`](./docs/06_Refactoring_Game.md) | Performance-/Refactoring-Empfehlungen für `Aegis-Labyrinth.html` |
|
||||
| [`CHANGELOG.md`](./CHANGELOG.md) | Laufende Version + Version-Historie & Änderungs-Log (Game + Suite) |
|
||||
|
||||
---
|
||||
|
||||
## Lizenz
|
||||
|
||||
Dieses Projekt (die Test- & Audit-Suite) ist unter **GNU General Public License v3.0** (GPL-3.0) lizenziert.
|
||||
Die vollständige Lizenz finden Sie in der Datei [`LICENSE`](./LICENSE).
|
||||
|
||||
> ⚠️ Die getestete Game-Datei `Aegis-Labyrinth.html` ist **nicht** Teil dieses Repos und unterliegt deren eigener Lizenzierung.
|
||||
> Der GPL-3.0-Schutz erstreckt sich auf alle Dateien in diesem Repository (Tests, Docs, Konfiguration).
|
||||
@@ -0,0 +1,153 @@
|
||||
# 01 – Debug-API & In-Game-Console
|
||||
|
||||
> Die **Test-Orakel-Schicht** des Games: `window.__AEGIS_DEBUG__` und die eingebauten Audits.
|
||||
> Die gesamte Test-Suite in `tests/` hängt an dieser API – sie ist die einzige stabile Schnittstelle zwischen den Skripten und der Game-Source.
|
||||
|
||||
---
|
||||
|
||||
## 1. Grundprinzip
|
||||
|
||||
`Aegis-Labyrinth.html` ist eine Single-File-App. Für Automatisierung stellt sie zwei Dinge bereit:
|
||||
|
||||
1. **`window.__AEGIS_DEBUG__`** – ein explizit auf `window` gehängtes Objekt (stabil in `page.evaluate()` referenzierbar).
|
||||
2. **Funktionen im Global Scope** (`placeTower`, `buySkill`, `simulate`, `triggerVictory`, `TOWER_TYPES`, `Game`, …) – frei verfügbar, aber **`const`/`let`-basiert**, d.h. **nicht** auf `window`.
|
||||
|
||||
### Playwright-Fallstricke (WICHTIG)
|
||||
|
||||
| Identifier | Auf `window`? | Referenz in `page.evaluate()` |
|
||||
|---|---|---|
|
||||
| `__AEGIS_DEBUG__` | ✅ ja | `window.__AEGIS_DEBUG__` |
|
||||
| `TOWER_TYPES` | ❌ nein (const) | `TOWER_TYPES` (bare) |
|
||||
| `Game` | ❌ nein | `Game` (bare) |
|
||||
| `placeTower`, `buySkill`, `simulate` | ❌ nein | bare Identifier |
|
||||
|
||||
> `window.TOWER_TYPES` → `undefined`. Immer bare Identifier verwenden.
|
||||
|
||||
---
|
||||
|
||||
## 2. `window.__AEGIS_DEBUG__` – Komplette API
|
||||
|
||||
### 2.1 Audit-Funktionen
|
||||
|
||||
| Funktion | Prüft (Kurz) |
|
||||
|---|---|
|
||||
| `runSelfAudit()` | Konnektivität aller 11 Levels, alle 9 Turm-Attacks, Skill-Käufe (4 Ränge), Platzierungs-Validierung, AutoWave, Endless-Transition |
|
||||
| `runExtensionAudit()` | Mortar-Splash (2 Ziele), Tesla-AoE (5 Feinde + Freeze), Reward-Dedup, Blocker-Alternate/Closed-Path |
|
||||
| `runRedesignAudit()` | Sniper-Priorisierung (niedriger HP zuerst), Quantum-Beam-Alignment, Nano-Spawner (Limit/Damage/Cleanup) |
|
||||
|
||||
Jede Funktion gibt ein **Report-Objekt** zurück (Schema: [`02_Audits.md`](./02_Audits.md)).
|
||||
|
||||
### 2.2 State & Utility
|
||||
|
||||
```
|
||||
window.__AEGIS_DEBUG__
|
||||
├── runSelfAudit() → report object
|
||||
├── runExtensionAudit() → report object
|
||||
├── runRedesignAudit() → report object
|
||||
├── getState() → { state, credits, lives, waveIndex, enemies, towers, … }
|
||||
├── startEndlessLevel(n) → startet Endless ab Level n (0-basiert)
|
||||
├── selectLevel(n) → lädt Level n (0-basiert)
|
||||
├── startWave() → manuelle Wave-Start
|
||||
├── setCredits(n) → Credits setzen
|
||||
├── towerTypes[] → 9 Einträge {id, name, cost, range, damage, fireRate, skills}
|
||||
├── skilltree
|
||||
│ ├── version, points, nodes, completed, endless20Rewards
|
||||
│ ├── getState() → deep clone
|
||||
│ ├── buy(nodeId)
|
||||
│ └── reset()
|
||||
├── levels[] → 11 Einträge {id, name, waves, difficulty, endlessAvailable}
|
||||
├── effectMetadata
|
||||
│ ├── towerTypes[] (ohne cost, mit skillIds)
|
||||
│ ├── enemyTypes[] ({id, hp, speed, radius, color})
|
||||
│ └── effectLimits ({maxParticles:200, maxProjectiles:100, maxHolos:20, particleLife:0.8, projectileLife:1.6})
|
||||
├── effectTuning
|
||||
│ ├── holo ({influenceRadius, pullStrength})
|
||||
│ └── grav ({basePull, baseSlow})
|
||||
├── aura
|
||||
│ ├── getAuraState()
|
||||
│ ├── getBonuses()
|
||||
│ └── upgrade(tower)
|
||||
└── audio
|
||||
├── state() → {initialized, muted, volume, voices}
|
||||
├── sounds[] → 20 Namen
|
||||
├── test(name)
|
||||
├── setMuted(bool)
|
||||
└── setVolume(0–1)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. `getState()` – typisches Schema
|
||||
|
||||
```js
|
||||
{
|
||||
state: "menu" | "playing" | "victory" | "defeat" | "endless",
|
||||
credits: number,
|
||||
lives: number,
|
||||
waveIndex: number,
|
||||
totalWaves: number,
|
||||
kills: number,
|
||||
leaked: number,
|
||||
enemies: number | Enemy[], // je nach Version Zähler oder Array
|
||||
towers: number | Tower[],
|
||||
// …
|
||||
}
|
||||
```
|
||||
|
||||
> Die Suite nutzt `getState()` primär als **Beobachtungsschnittstelle** für Self-Play & Perf. Exakte Felder: [`02_Audits.md`](./02_Audits.md) §getState.
|
||||
|
||||
---
|
||||
|
||||
## 4. In-Game-Debug-Console (manuell)
|
||||
|
||||
**Aufruf:** Im Browser mit Taste `` ` `` (Backtick) die Debug-Console öffnen.
|
||||
|
||||
| Befehl | Beschreibung |
|
||||
|---|---|
|
||||
| `help` | Alle Befehle anzeigen |
|
||||
| `state` | Kompletten Game-State als JSON in der Konsole |
|
||||
| `credits [Zahl]` | Credits setzen (z. B. `credits 99999`) |
|
||||
| `unlock all` | Alle Türme entsperren |
|
||||
| `level [1–11] [normal\|endless]` | Level laden (1-basiert) |
|
||||
| `wave` | Nächste Wave starten |
|
||||
| `audit [self\|extension\|redesign]` | Das entsprechende Audit ausführen |
|
||||
| `sound [Name]` | Sound testen (einer der 20 Sounds) |
|
||||
| `clear` | Konsole leeren |
|
||||
|
||||
> Die In-Game-Console ist für **manuelle** Debugging-Zwecke gedacht. Die automatisierte Suite nutzt direkt `window.__AEGIS_DEBUG__` (ohne UI-Overlay).
|
||||
|
||||
---
|
||||
|
||||
## 5. Neue Mechanismen auditierbar machen (Konvention)
|
||||
|
||||
Jeder neue Mechanismus sollte **vor Merge** einen Audit-Eintrag in `window.__AEGIS_DEBUG__` erhalten, damit `tests/audit.mjs` ihn automatisch abdeckt:
|
||||
|
||||
```js
|
||||
// Beispiel: neuer Turm "tesla2"
|
||||
function runTesla2Audit() {
|
||||
loadLevel(0);
|
||||
const t = new Tower(TOWER_BY_ID.tesla2, 5, 5);
|
||||
const e = new Enemy('tank', t.x + 30, t.y);
|
||||
Game.towers = [t]; Game.enemies = [e];
|
||||
towerFire(t, 1/60);
|
||||
return { hit: e.hp < e.maxHp, beam: Game.beams.length > 0 };
|
||||
}
|
||||
window.__AEGIS_DEBUG__.runTesla2Audit = runTesla2Audit;
|
||||
```
|
||||
|
||||
Anschließend die neue Funktion in `tests/audit.mjs` anbinden und hier + in `02_Audits.md` dokumentieren.
|
||||
|
||||
---
|
||||
|
||||
## 6. Glossar (interner Jargon)
|
||||
|
||||
| Begriff | Bedeutung |
|
||||
|---|---|
|
||||
| `grid[y][x] === 0` | Bau-Kachel (Wand) – Turm/Blocker hier erlaubt |
|
||||
| `grid[y][x] === 1` | Pfad-Kachel – Feinde laufen hier |
|
||||
| `grid[y][x] === 2` | Start-Kachel (Entry) |
|
||||
| `grid[y][x] === 3` | Exit-Kachel (Base) |
|
||||
| `flow.field[idx] === INF` | Zelle nicht erreichbar |
|
||||
| `NANITE_LIMIT` | Max. gleichzeitig aktive Naniten |
|
||||
| `autoWave` / `autoWaveActive` | Verzögerung zwischen Wellen |
|
||||
| `TOWER_BY_ID` | Map: `"barrier"` → Definition, `"tesla"` → Definition, etc. |
|
||||
@@ -0,0 +1,193 @@
|
||||
# 02 – Audits im Detail (self / extension / redesign)
|
||||
|
||||
> Was die drei eingebauten Audits konkret prüfen, welche **Assertions** `tests/audit.mjs` darauf aufsetzt und welche **Exit-Codes** daraus resultieren.
|
||||
> API-Basis: [`01_Debug_API.md`](./01_Debug_API.md).
|
||||
|
||||
---
|
||||
|
||||
## 1. Übersicht
|
||||
|
||||
| Audit | API-Funktion | Fokus |
|
||||
|---|---|---|
|
||||
| **Self** | `runSelfAudit()` | Konnektivität (11 Levels), Attacks, Skills, Platzierung, AutoWave, Endless |
|
||||
| **Extension** | `runExtensionAudit()` | Mortar-Splash, Tesla-Chain/Freeze, Reward-Dedup, Blocker-Logik |
|
||||
| **Redesign** | `runRedesignAudit()` | Kryo, Sniper (Pierce), Mortar-FixImpact, Quantum-Beam, Nano-Spawner |
|
||||
|
||||
`audit.mjs` führt alle drei in einer Headless-Chromium-Session aus, sammelt `pageerror`-Events und bewertet die Rückgabe-Werte mit eigenen Assertion-Hilfsfunktionen.
|
||||
|
||||
---
|
||||
|
||||
## 2. `runSelfAudit()` – Struktur & Assertions
|
||||
|
||||
### 2.1 Report-Struktur (Rückgabe der API)
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"connectivity": [ { "level": 0, "starts": 2, "exit": true, "reachable": true }, … ], // 11 Levels
|
||||
"attacks": [ { "id": "sniper", "projectiles": 3, "holos": 0, "hurt": 2 }, … ],
|
||||
"skills": [ { "id": "sniper", "rank": 4 }, … ],
|
||||
"placement": { "wallAccepted": true, "pathAccepted": false, "count": 1 },
|
||||
"autoWave": { "state": "playing", "active": true },
|
||||
"endless": { "state": "endless", "endlessWave": 1 }
|
||||
}
|
||||
```
|
||||
|
||||
### 2.2 Assertions in `tests/audit.mjs` (`assertSelfAudit`)
|
||||
|
||||
| # | Assertion | Erwartung |
|
||||
|---|---|---|
|
||||
| S-conn | `L{n} has start` | `starts > 0` (pro Level) |
|
||||
| S-conn | `L{n} has exit` | `exit === true` (pro Level) |
|
||||
| S-conn | `L{n} reachable` | `reachable === true` (pro Level) |
|
||||
| S-atk | `tower {id}: projectiles=… holos=… hurt=…` | **info** (Support-/Relay-Türme feuern absichtlich nicht → kein Hard-Fail) |
|
||||
| S-sk | `skill {id} rank>=1` | `rank >= 1` (nach 4× `buySkill`) |
|
||||
| S-plc | `placement: wallAccepted (tower on free cell)` | `wallAccepted === true` |
|
||||
| S-plc | `placement: pathAccepted (tower on path rejected)` | `pathAccepted === false` |
|
||||
| S-plc | `placement: tower count>=1` | `count >= 1` |
|
||||
| S-aw | `autoWave: state` / `autoWave: active` | **info** (nur State prüfen) |
|
||||
| S-ee | `endless: state` | **info** |
|
||||
| S-ee | `endless: endlessWave>=0` | `endlessWave >= 0` |
|
||||
|
||||
> Hinweis: „Attacks“ und „AutoWave“ sind bewusst **Diagnose-/Info-Checks** – die harten Pfade laufen über Konnektivität, Skills und Platzierung.
|
||||
|
||||
---
|
||||
|
||||
## 3. `runExtensionAudit()` – Struktur & Assertions
|
||||
|
||||
### 3.1 Report-Struktur
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"mortar": { "projectile": true, "hurt": true },
|
||||
"tesla": { "damaged": 3, "frozen": 2 },
|
||||
"reward": { "pointsAfterDuplicate": 1, "storedRank": 4, "rankAfterBuy": 4 },
|
||||
"blockerAlternate":{ "placed": true, "finite": true, "soldPathRestored": true },
|
||||
"blockerClosed": { "placed": true, "destroyed": true, "pathRestored": true }
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 Assertions (`assertExtensionAudit`)
|
||||
|
||||
| # | Assertion | Erwartung |
|
||||
|---|---|---|
|
||||
| E-mrt | `mortar: projectile spawned (may resolve instantly)` | **info** |
|
||||
| E-mrt | `mortar: both targets hurt (splash)` | `hurt === true` |
|
||||
| E-tes | `tesla: damaged enemies count` | `damaged > 1` |
|
||||
| E-tes | `tesla: frozen count` | `frozen > 1` |
|
||||
| E-rwd | `reward: pointsAfterDuplicate>=1` | `pointsAfterDuplicate >= 1` |
|
||||
| E-rwd | `reward: storedRank matches rankAfterBuy` | `storedRank === rankAfterBuy` |
|
||||
| E-blt | `blockerAlternate: placed` / `route still finite` / `path restored after sell` | `placed`, `finite`, `soldPathRestored` (falls Kandidat gefunden) |
|
||||
| E-blc | `blockerClosed: placed` / `destroyed by enemy` / `path restored` | `placed`, `destroyed`, `pathRestored` (falls Kandidat gefunden) |
|
||||
|
||||
> Fehlt ein geeigneter Blocker-Kandidat, wird ein **info-Pass** („no candidate found (acceptable)") erzeugt – kein Hard-Fail.
|
||||
|
||||
---
|
||||
|
||||
## 4. `runRedesignAudit()` – Struktur & Assertions
|
||||
|
||||
### 4.1 Report-Struktur
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"kryo": { "randomLastTarget": true, "visibleSlow": true },
|
||||
"sniper": { "pierced": 3, "noDot": true, "highestAbsoluteHp": true },
|
||||
"mortar": { "fixedImpact": true },
|
||||
"quantum":{ "lineHits": 3, "offLineUntouched": true, "beam": true },
|
||||
"nano": { "spawned": 5, "damaged": true, "cleaned": true }
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 Assertions (`assertRedesignAudit`)
|
||||
|
||||
| # | Assertion | Erwartung |
|
||||
|---|---|---|
|
||||
| R-kyo | `kryo: target hit` | `randomLastTarget || visibleSlow` |
|
||||
| R-kyo | `kryo: slow applied` | `visibleSlow === true` |
|
||||
| R-snp | `sniper: pierced count` | `pierced > 1` |
|
||||
| R-snp | `sniper: no DoT (burn/poison)` | `noDot === true` |
|
||||
| R-snp | `sniper: highest absolute HP targeting` | `highestAbsoluteHp === true` (falls vorhanden) |
|
||||
| R-mrt | `mortar: fixed impact (witness hit, fleeer untouched)` | `fixedImpact === true` |
|
||||
| R-qtm | `quantum: line hits` | `lineHits > 1` |
|
||||
| R-qtm | `quantum: off-line untouched` | `offLineUntouched === true` |
|
||||
| R-qtm | `quantum: beam created` | `beam === true` |
|
||||
| R-nno | `nano: spawned count` | `spawned > 1` |
|
||||
| R-nno | `nano: damaged target` | `damaged === true` |
|
||||
| R-nno | `nano: cleaned up` | `cleaned === true` |
|
||||
|
||||
---
|
||||
|
||||
## 5. `audit-result.json` – Schema (authoritative)
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"timestamp": "2026-08-28T19:00:00.000Z",
|
||||
"file": "…/Aegis-Labyrinth.html",
|
||||
"fileHash": "a1b2c3d4e5f60718", // sha256, erste 16 Hex-Zeichen
|
||||
"self": { /* Sektion 2.1 */ },
|
||||
"extension": { /* Sektion 3.1 */ },
|
||||
"redesign": { /* Sektion 4.1 */ },
|
||||
"assertions": {
|
||||
"self": [ { "name", "actual", "expected", "passed" } ],
|
||||
"extension": [ … ],
|
||||
"redesign": [ … ]
|
||||
},
|
||||
"pageErrors": [], // gemeldete JS-Fehler (pageerror-Events)
|
||||
"summary": { "pass": 40, "fail": 0, "total": 42 } // total inkl. PageErrors
|
||||
}
|
||||
```
|
||||
|
||||
Das Gesamtverdict in `report.mjs` wird direkt aus `summary.fail === 0` **und** `pageErrors.length === 0` abgeleitet.
|
||||
|
||||
---
|
||||
|
||||
## 6. Exit-Code & Fail-Verhalten
|
||||
|
||||
```
|
||||
exit 0 → summary.fail === 0 UND pageErrors leer
|
||||
exit 1 → ≥ 1 Assertion failed ODER ≥ 1 PageError
|
||||
exit 2 → harter Crash (Datei fehlt, Browser-Start, Timeout, …)
|
||||
```
|
||||
|
||||
Zusätzlich werden immer `audit-result.json` **und** `audit-final.png` geschrieben (auch bei Fail), damit die Fehler in `report.html` nachvollziehbar bleiben.
|
||||
|
||||
---
|
||||
|
||||
## 7. Fehlerklassen, die die Audits typischerweise fangen
|
||||
|
||||
| Kategorie | Wo sichtbar | Häufige Ursache |
|
||||
|---|---|---|
|
||||
| Pfad unvollständig | `self.connectivity[n].reachable === false` | Flow-Field `rebuild()` nach `grid`-Change vergessen |
|
||||
| Turm schießt nicht | `self.attacks[id].projectiles === 0` (info) | Cooldown nicht reset / Range zu klein |
|
||||
| Skill nicht kaufbar | `self.skills[id].rank < 1` | `buySkill`-Cost > Credits / Skill-ID-Typo |
|
||||
| Platzierung falsch | `self.placement.pathAccepted === true` | `placeTower` prüft `grid` nicht |
|
||||
| Splash trifft nicht | `extension.mortar.hurt === false` | Splash-Radius / Ziel-Filter |
|
||||
| Tesla ohne Effekt | `extension.tesla.frozen < 1` | Freeze-Status nicht gesetzt |
|
||||
| Doppelte Rewards | `extension.reward.storedRank !== rankAfterBuy` | `triggerVictory` ohne Idempotenz |
|
||||
| Pfad kaputt nach Blocker | `extension.blockerClosed.pathRestored === false` | `sellTower` ruft `Game.flow.rebuild()` nicht auf |
|
||||
| Sniper kein Pierce | `redesign.sniper.pierced < 2` | Pierce-Logik fehlt |
|
||||
| Quantum trifft Off-Line | `redesign.quantum.offLineUntouched === false` | Winkel-Test zu locker |
|
||||
| Naniten lecken | `redesign.nano.cleaned === false` | Cleanup-Flag / `NANITE_LIMIT` |
|
||||
|
||||
---
|
||||
|
||||
## 8. Bug-Fix-Routine (empfohlen)
|
||||
|
||||
```
|
||||
1. Replizieren
|
||||
→ npm run audit
|
||||
→ audit-result.json öffnen → failing Assertion identifizieren
|
||||
→ Optional: In-Game-Debug-Console (Taste ` `) → `audit self` / `state`
|
||||
|
||||
2. Isolation
|
||||
→ Spiel-State minimal halten:
|
||||
Game.towers = [onlyTower]
|
||||
Game.enemies = [onlyEnemy]
|
||||
Game.projectiles = []
|
||||
→ Einzelne Funktion aufrufen: towerFire(t, 1/60)
|
||||
|
||||
3. Fixen
|
||||
→ Aegis-Labyrinth.html editieren
|
||||
|
||||
4. Verifizieren
|
||||
→ npm run audit erneut → grün
|
||||
→ npm run report → report.html prüfen
|
||||
@@ -0,0 +1,276 @@
|
||||
# 03 – Automatisierung, Self-Play, Performance & CI
|
||||
|
||||
> Wie die Test-Suite aufgerufen wird, was `selfplay.mjs` und `perf-test.mjs` konkret messen und wie die Stufen in eine CI-Pipeline eingebunden werden.
|
||||
|
||||
---
|
||||
|
||||
## 1. Aufruf der Skripte
|
||||
|
||||
### 1.1 npm-Scripts (aus `package.json`)
|
||||
|
||||
| Script | Aufruf | Parameter (optional) |
|
||||
|---|---|---|
|
||||
| `npm run audit` | `node tests/audit.mjs` | – |
|
||||
| `npm run selfplay` | `node tests/selfplay.mjs [ep]` | `ep` = Episoden (Default 10) |
|
||||
| `npm run perf` | `node tests/perf-test.mjs [ms] [towers]` | `ms` = Dauer (Default 15000), `towers` = Anzahl (Default 50) |
|
||||
| `npm run report` | `node tests/report.mjs` | – |
|
||||
| `npm test` | Audit + Self-Play + Perf | – |
|
||||
| `npm run setup` | `npx playwright install chromium` | – |
|
||||
|
||||
### 1.2 Direkt-Aufruf (nützlich für CI / Skripte)
|
||||
|
||||
```bash
|
||||
node tests/selfplay.mjs 50 # 50 Episoden
|
||||
node tests/perf-test.mjs 30000 80 # 30 s messen, 80 Türme
|
||||
node tests/audit.mjs # Standard-Audit
|
||||
node tests/report.mjs # Report erzeugen
|
||||
```
|
||||
|
||||
### 1.3 Exit-Codes (Übersicht)
|
||||
|
||||
| Skript | exit 0 | exit ≠ 0 |
|
||||
|---|---|---|
|
||||
| `audit.mjs` | alle Assertions grün | ≥ 1 Fehler → `1`, Crash → `2` |
|
||||
| `selfplay.mjs` | (liefert immer 0) | – |
|
||||
| `perf-test.mjs` | FPS ≥ Zielwert (55) | FPS < Zielwert → `1` |
|
||||
| `report.mjs` | (liefert immer 0) | – |
|
||||
|
||||
---
|
||||
|
||||
## 2. Self-Play (`tests/selfplay.mjs`)
|
||||
|
||||
### 2.1 Zweck
|
||||
|
||||
Deterministischer Bot spielt **Level 0** (Standard) oder ein beliebiges Level durch und misst:
|
||||
- **Win-Rate** über N Episoden
|
||||
- **Durchschnittliche Kills, Leaks, Credits, Waves**
|
||||
- **Stabilität** (keine JS-Page-Errors, keine Freeze-Detection)
|
||||
|
||||
### 2.2 Strategie des Bots
|
||||
|
||||
```
|
||||
1. Level laden (selectLevel, Default Level 0)
|
||||
2. Credits setzen (setCredits → 999999)
|
||||
3. Türme platzieren:
|
||||
- Alle Bau-Kacheln (grid==0) identifizieren
|
||||
- In Priorität: Sniper, Tesla, Quantum, Nano, Barrier, Holo, Grav, Mortar, Sniper
|
||||
- Je nach Credits: mehrere Runden × 5 Türme
|
||||
4. Wave starten (startWave)
|
||||
5. simulate() in 1/60-Schritten bis victory/defeat
|
||||
6. Episoden-Log: kills, leaks, credits, waves, duration
|
||||
7. Aggregation: Win-Rate, mean, std, min, max
|
||||
```
|
||||
|
||||
### 2.3 Ausgabe (`selfplay-results.json`)
|
||||
|
||||
```json
|
||||
{
|
||||
"timestamp": "2026-08-28T19:30:00.000Z",
|
||||
"episodes": [
|
||||
{
|
||||
"placed": 40,
|
||||
"towerCount": 40,
|
||||
"maxKills": 120,
|
||||
"waveReached": 8,
|
||||
"totalUpgrades": 64,
|
||||
"finalState": "victory",
|
||||
"finalKills": 120,
|
||||
"finalLeaked": 0,
|
||||
"finalLives": 20
|
||||
}
|
||||
],
|
||||
"summary": {
|
||||
"total": 10,
|
||||
"wins": 8,
|
||||
"losses": 2,
|
||||
"winRate": 80.0,
|
||||
"avgKills": 118,
|
||||
"avgWaves": 7.4
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2.4 Playwright-Fallstricke (Self-Play)
|
||||
|
||||
| Problem | Lösung |
|
||||
|---|---|
|
||||
| `window.TOWER_TYPES` → `undefined` | `TOWER_TYPES` (bare Identifier) |
|
||||
| `window.placeTower` → `undefined` | `placeTower` (bare) |
|
||||
| `window.buySkill` → `undefined` | `buySkill` (bare) |
|
||||
| `window.__AEGIS_DEBUG__` → ✅ | `window.__AEGIS_DEBUG__` |
|
||||
|
||||
> `selfplay.mjs` nutzt ausschließlich `window.__AEGIS_DEBUG__` für State-Abfragen und bare Identifier für Aktionen.
|
||||
|
||||
---
|
||||
|
||||
## 3. Performance (`tests/perf-test.mjs`)
|
||||
|
||||
### 3.1 Zweck
|
||||
|
||||
Messen der **Frames per Second (FPS)** und **Heap-Größe** unter definiertem Lastprofil:
|
||||
- **Level:** schweres Level (Default Level 10, 11 Waves)
|
||||
- **Türme:** konfigurierbare Anzahl (Default 50, empfohlen 50–80)
|
||||
- **Dauer:** konfigurierbare Messzeit (Default 15000 ms)
|
||||
|
||||
### 3.2 Vorgehen
|
||||
|
||||
```
|
||||
1. Level laden (selectLevel(10))
|
||||
2. Credits setzen (setCredits → 999999)
|
||||
3. Türme platzieren (N Türme auf Bau-Kacheln, Priorität: schwerste zuerst)
|
||||
4. Wave starten (startWave)
|
||||
5. simulate() in 1/60-Schritten
|
||||
6. FPS messen:
|
||||
- requestAnimationFrame in Page (window.__fps_frames++)
|
||||
- Alle 1000 ms: fps = frames / 1.0
|
||||
- Frame-Timing: performance.now() Differenz
|
||||
7. Heap messen:
|
||||
- page.evaluate(() => performance.memory)
|
||||
- usedJSHeapSize / totalJSHeapSize / jsHeapSizeLimit
|
||||
8. Ergebnis: perf-result.json
|
||||
```
|
||||
|
||||
### 3.3 FPS-Zielwert & Exit-Code
|
||||
|
||||
| FPS | Bewertung | Exit-Code |
|
||||
|---|---|---|
|
||||
| ≥ 55 | ✅ Gut | 0 |
|
||||
| 45–54 | ⚠️ Verändert | 1 |
|
||||
| < 45 | ❌ Kritisch | 1 |
|
||||
|
||||
### 3.4 Ausgabe (`perf-result.json`)
|
||||
|
||||
```json
|
||||
{
|
||||
"timestamp": "2026-08-28T19:45:00.000Z",
|
||||
"durationMs": 15000,
|
||||
"fps": 58,
|
||||
"targetFps": 55,
|
||||
"pass": true,
|
||||
"heap": { "usedMB": 48.3, "totalMB": 96.0 },
|
||||
"setup": {
|
||||
"levelIdx": 10,
|
||||
"levelName": "…",
|
||||
"placed": 50,
|
||||
"enemies": 40,
|
||||
"state": "playing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3.5 Bekannte Performance-Problemzonen (→ `06_Refactoring_Game.md`)
|
||||
|
||||
| Problem | Wo sichtbar | Empfehlung |
|
||||
|---|---|---|
|
||||
| Particles | `Game.particles` wächst > 200 | Object-Pooling + Max-Limit |
|
||||
| Projectiles | `Game.projectiles` > 100 | Spatial-Partitioning |
|
||||
| Holograms | `Game.holograms` > 20 | Batch-Rendering |
|
||||
| Beam | `Game.beams` > 10 | Line-Rendering statt Circle |
|
||||
| Enemy-Update | O(n²) bei 20+ Feinden | Spatial-Hash |
|
||||
|
||||
---
|
||||
|
||||
## 4. CI-Workflows (empfohlen)
|
||||
|
||||
### 4.1 Stufen
|
||||
|
||||
| Stufe | Skripte | Wann | Dauer (ca.) |
|
||||
|---|---|---|---|
|
||||
| **Pre-Commit** | `npm run audit` | bei jedem Commit | 30–60 s |
|
||||
| **Nightly** | Audit + `selfplay.mjs 50` + `perf-test.mjs` | zeitplangetrieben | 5–10 min |
|
||||
| **Release** | Audit + `selfplay.mjs 500` + `perf-test.mjs 30000 80` + Report | Tagging | 15–30 min |
|
||||
|
||||
### 4.2 GitHub-Actions-Beispiel (`.github/workflows/ci.yml`)
|
||||
|
||||
```yaml
|
||||
name: Test-Suite
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 2 * * *' # Nightly 2:00 UTC
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Install Playwright Chromium
|
||||
run: npx playwright install chromium
|
||||
|
||||
# ⚠️ Aegis-Labyrinth.html muss als Secret/Artifact bereitgestellt werden
|
||||
- name: Download Game-Datei
|
||||
run: |
|
||||
echo "${{ secrets.AEGIS_GAME_BASE64 }}" | base64 -d > Aegis-Labyrinth.html
|
||||
|
||||
- name: Run Audit
|
||||
run: npm run audit
|
||||
continue-on-error: true
|
||||
|
||||
- name: Run Self-Play (10 Episoden)
|
||||
run: node tests/selfplay.mjs 10
|
||||
|
||||
- name: Run Performance Test
|
||||
run: node tests/perf-test.mjs 15000 50
|
||||
|
||||
- name: Generate Report
|
||||
run: node tests/report.mjs
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results
|
||||
path: |
|
||||
audit-result.json
|
||||
selfplay-results.json
|
||||
perf-result.json
|
||||
report.html
|
||||
audit-final.png
|
||||
|
||||
# Audit muss grün sein für Main-Push
|
||||
- name: Check Audit Exit Code
|
||||
if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main')
|
||||
run: |
|
||||
# audit-result.json nutzt "summary": { "pass", "fail", "total" }
|
||||
if [ ! -f audit-result.json ] || grep -q '"fail": [1-9]' audit-result.json; then
|
||||
echo "❌ Audit failed"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
### 4.3 Game-Datei in CI bereitzustellen
|
||||
|
||||
Da `Aegis-Labyrinth.html` **nicht im Repo** liegt, muss sie in der CI als **Secret** oder **Artifact** bereitgestellt werden:
|
||||
|
||||
| Methode | Vorteil | Nachteil |
|
||||
|---|---|---|
|
||||
| **GitHub Secret** (Base64) | Einfach, sicher | Base64-Konvertierung nötig |
|
||||
| **Release Artifact** | Versioniert | Extra Schritt zum Herunterladen |
|
||||
| **Separates Private Repo** | Saubere Trennung | Access-Token nötig |
|
||||
|
||||
Empfehlung: **GitHub Secret** für einfache CI, **separates Private Repo** für Teams.
|
||||
|
||||
---
|
||||
|
||||
## 5. Troubleshooting
|
||||
|
||||
| Symptom | Ursache | Lösung |
|
||||
|---|---|---|
|
||||
| `❌ Aegis-Labyrinth.html nicht gefunden!` | Datei fehlt | Datei in Projekt-Root kopieren |
|
||||
| `browserType.launch: Executable doesn't exist` | Playwright nicht installiert | `npx playwright install chromium` |
|
||||
| `selfplay.mjs` liefert immer 0 | Bot verliert immer | Level prüfen / mehr Credits / Türme |
|
||||
| `perf-test.mjs` FPS < 45 | Zu viele Entities | Level/Türme reduzieren / Refactoring |
|
||||
| `report.html` zeigt "no data" | `*-result.json` fehlt | Audit/Self-Play/Perf erst ausführen |
|
||||
| Playwright `evaluate` → `undefined` | `window.X` statt `X` | Bare Identifier verwenden (siehe `01_Debug_API.md`) |
|
||||
@@ -0,0 +1,188 @@
|
||||
# 04 – Resultate & Report (Ausgabe-Dateien)
|
||||
|
||||
> Schema-Referenz für alle Artefakte der Test-Suite und Aufbau des generierten `report.html`.
|
||||
> Diese Dateien werden **zur Laufzeit erzeugt** und **nicht versioniert** (→ `.gitignore`).
|
||||
|
||||
---
|
||||
|
||||
## 1. Übersicht der Artefakte
|
||||
|
||||
| Datei | Erzeugt von | Zweck |
|
||||
|---|---|---|
|
||||
| `audit-result.json` | `tests/audit.mjs` | Raw-Reports der 3 Audits + Assertions + Page-Errors + Summary |
|
||||
| `selfplay-results.json` | `tests/selfplay.mjs` | Episoden-Log + Win-Rate + Aggregates |
|
||||
| `perf-result.json` | `tests/perf-test.mjs` | FPS, Heap, Setup-Metadaten |
|
||||
| `report.html` | `tests/report.mjs` | Zusammengefasster, menschlich lesbarer CI-Report |
|
||||
| `audit-final.png` | `tests/audit.mjs` | Finaler Screenshot des Headless-Browsers |
|
||||
|
||||
> `report.mjs` liest die drei `*-result.json` und rendert daraus ein einzelnes `report.html`.
|
||||
> Fehlt eine JSON-Datei, zeigt `report.html` für die entsprechende Sektion „no data".
|
||||
|
||||
---
|
||||
|
||||
## 2. `audit-result.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"timestamp": "2026-08-28T19:20:00.000Z",
|
||||
"self": {
|
||||
"connectivity": [
|
||||
{ "level": 0, "name": "…", "reachable": true }
|
||||
],
|
||||
"attacks": [
|
||||
{ "id": "sniper", "projectiles": 12, "hits": 10 }
|
||||
],
|
||||
"skills": [
|
||||
{ "id": "…", "rank": 4 }
|
||||
],
|
||||
"placement": { "wall": true, "path": true },
|
||||
"autoWave": true,
|
||||
"endlessTransition": true
|
||||
},
|
||||
"extension": {
|
||||
"mortarSplashTargets": 2,
|
||||
"teslaAoE": { "targets": 5, "frozen": true },
|
||||
"rewardDedup": true,
|
||||
"blockerAltPath": true,
|
||||
"blockerClosedPath": true
|
||||
},
|
||||
"redesign": {
|
||||
"sniperPriority": true,
|
||||
"quantumBeam": { "aligned": 3, "offLineUnharmed": true },
|
||||
"nanoSpawner": { "limit": true, "damage": true, "cleanup": true }
|
||||
},
|
||||
"pageErrors": [],
|
||||
"assertions": [
|
||||
{ "name": "self.connectivity.allReachable", "pass": true },
|
||||
{ "name": "self.attacks.noZeroProjectiles", "pass": true },
|
||||
{ "name": "self.skills.allRank4", "pass": true }
|
||||
],
|
||||
"summary": {
|
||||
"total": 12,
|
||||
"pass": 12,
|
||||
"fail": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> **Exit-Code-Kopplung:** `audit.mjs` beendet sich mit `1`, sobald `summary.fail > 0`
|
||||
> oder `pageErrors` nicht leer ist. Ein harter Crash im Browser führt zu `2`.
|
||||
|
||||
---
|
||||
|
||||
## 3. `selfplay-results.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"timestamp": "2026-08-28T19:30:00.000Z",
|
||||
"episodes": [
|
||||
{
|
||||
"placed": 40,
|
||||
"towerCount": 40,
|
||||
"maxKills": 120,
|
||||
"waveReached": 8,
|
||||
"totalUpgrades": 64,
|
||||
"finalState": "victory",
|
||||
"finalKills": 120,
|
||||
"finalLeaked": 0,
|
||||
"finalLives": 20
|
||||
}
|
||||
],
|
||||
"summary": {
|
||||
"total": 10,
|
||||
"wins": 8,
|
||||
"losses": 2,
|
||||
"winRate": 80.0,
|
||||
"avgKills": 118,
|
||||
"avgWaves": 7.4
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Felder:**
|
||||
|
||||
| Feld | Bedeutung |
|
||||
|---|---|
|
||||
| `placed` | Anzahl tatsächlich platzierter Türme in der Episode |
|
||||
| `towerCount` | Endgültige Turm-Anzahl (inkl. Spawner) |
|
||||
| `maxKills` | Höchststand an Kills während der Simulation |
|
||||
| `waveReached` | Letzt erreichte Wave |
|
||||
| `totalUpgrades` | Anzahl gekaufter Skill-Upgrades |
|
||||
| `finalState` | `victory` \| `defeat` |
|
||||
| `winRate` | `wins / total × 100` |
|
||||
|
||||
---
|
||||
|
||||
## 4. `perf-result.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"timestamp": "2026-08-28T19:45:00.000Z",
|
||||
"durationMs": 15000,
|
||||
"fps": 58,
|
||||
"targetFps": 55,
|
||||
"pass": true,
|
||||
"heap": { "usedMB": 48.3, "totalMB": 96.0 },
|
||||
"setup": {
|
||||
"levelIdx": 10,
|
||||
"levelName": "…",
|
||||
"placed": 50,
|
||||
"enemies": 40,
|
||||
"state": "playing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Feld | Bedeutung |
|
||||
|---|---|
|
||||
| `fps` | Gemittelte Frames pro Sekunde während `durationMs` |
|
||||
| `targetFps` | Zielwert (Default `55`) – `pass` = `fps >= targetFps` |
|
||||
| `heap.usedMB` | `performance.memory.usedJSHeapSize` / 1048576 |
|
||||
| `heap.totalMB` | `performance.memory.totalJSHeapSize` / 1048576 |
|
||||
|
||||
> Heap-Messung benötigt Chromium (`performance.memory`). In nicht-Chromium-Browsern ist
|
||||
> `heap` ggf. `null` → `report.mjs` blendet dann die Heap-Spalte aus.
|
||||
|
||||
---
|
||||
|
||||
## 5. `report.html`
|
||||
|
||||
`report.mjs` rendert eine statische, single-file HTML-Seite:
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ Aegis Labyrinth – Test & Audit Report │
|
||||
│ Timestamp: 2026-08-28 19:45 │
|
||||
├──────────────────────────────────────────────────────────────────┤
|
||||
│ ✔ AUDIT pass 12/12 self ✔ extension ✔ redesign ✔ │
|
||||
│ ✔ SELF-PLAY winRate 80% (8/10) avgKills 118 │
|
||||
│ ✔ PERFORMANCE 58 fps (target 55) heap 48.3 / 96.0 MB │
|
||||
├──────────────────────────────────────────────────────────────────┤
|
||||
│ Assertion-Details (expandierbare Liste) │
|
||||
│ Page-Errors (leer) │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Verhalten:**
|
||||
|
||||
- Jede Sektion hat einen Ampel-Status: grün (pass) / gelb (teilweise) / rot (fail).
|
||||
- Fehlende Quelldatei → Sektion wird als „no data" (grau) gerendert, statt zu crashen.
|
||||
- Kein externes JS/CSS → `report.html` ist vollständig offline-viewbar.
|
||||
|
||||
---
|
||||
|
||||
## 6. .gitignore (Empfehlung)
|
||||
|
||||
```gitignore
|
||||
# Test-Artefakte (werden zur Laufzeit erzeugt)
|
||||
audit-result.json
|
||||
selfplay-results.json
|
||||
perf-result.json
|
||||
report.html
|
||||
audit-final.png
|
||||
|
||||
# Externe Game-Source (manuell in die Root legen)
|
||||
Aegis-Labyrinth.html
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
@@ -0,0 +1,95 @@
|
||||
# 05 – Tasks & Backlog (Changelog)
|
||||
|
||||
> Zentrales Log über **abgearbeitete Tasks** (Changelog) und das **offene Backlog**.
|
||||
> Jeder abgeschlossene Arbeitsschritt an der Test-Suite wird hier als Eintrag dokumentiert –
|
||||
> das beantwortet die Frage: *„Werden Tasks, die abgearbeitet werden, dokumentiert?"* → **Ja, hier.**
|
||||
|
||||
**Konvention:**
|
||||
- Chronologisch, neuestens oben.
|
||||
- Format: `### [YYYY-MM-DD] Kurztitel` + Stichpunkte (Geändert / Begründung / Impact).
|
||||
- Offene Punkte wandern in §3 (Backlog), abgeschlossene in §2 (Changelog).
|
||||
- **Trennung zu `CHANGELOG.md`:** Diese Datei = **Task-Changelog** (was an der Suite abgearbeitet wurde).
|
||||
Die **Versions-Historie** des Games + der Suite (z. B. `1.0.2`, Versionssprünge) lebt im Root-`CHANGELOG.md`.
|
||||
Große Changes gehören in **beide**.
|
||||
|
||||
---
|
||||
|
||||
## 1. Status-Snapshot
|
||||
|
||||
| Bereich | Status |
|
||||
|---|---|
|
||||
| Test-Suite (Audit / Self-Play / Perf / Report) | ✅ implementiert & lauffähig |
|
||||
| Dokumentation (01–06) | ✅ überarbeitet & konsistent |
|
||||
| CI-Definition | 🟡 dokumentiert (Workflow noch zu commiten) |
|
||||
| Refactoring der Game-Datei | 🔵 Advisory-Backlog (siehe `06_Refactoring_Game.md`) |
|
||||
|
||||
---
|
||||
|
||||
## 2. Changelog (abgearbeitete Tasks)
|
||||
|
||||
### [2026-08-28] Doku-Nummerierung vereinheitlicht (01–06)
|
||||
|
||||
- **Geändert:** Drei veraltete Dateien (`01_Refactoring_Performance.md`, `02_Audit_Bericht.md`, `03_Automatisierung_SelfPlay.md`) mit altem „Game"-Framing entfernt.
|
||||
- **Neu:** Kohärentes Set `01_Debug_API`, `02_Audits`, `03_Automatisierung_CI`, `04_Resultate_Report`, `05_Tasks_Backlog`, `06_Refactoring_Game`.
|
||||
- **Begründung:** Repo ist eine **Test-Suite**, kein Spiel → Doku musste umfokussiert und neu nummeriert werden.
|
||||
- **Impact:** Keine Code-Änderung; reine Dokumentation.
|
||||
|
||||
### [2026-08-28] Schemata gegen echten Code verifiziert
|
||||
|
||||
- **Geändert:** `selfplay-results.json`, `perf-result.json`, `audit-result.json`-Schemata in `03` und `04` an den tatsächlichen Skript-Output angepasst.
|
||||
- **Geändert:** CI-Gate prüft jetzt `summary.fail` statt des nicht existierenden Felds `"failed"`.
|
||||
- **Begründung:** Doku-Beispiele kollidierten mit der realen Ausgabe (falsche Feldnamen).
|
||||
- **Impact:** CI-Beispiel läuft jetzt konsistent mit `audit-result.json`.
|
||||
|
||||
### [2026-08-28] README auf Test-Suite-Framing umgestellt
|
||||
|
||||
- **Geändert:** README beschreibt jetzt das **Test-/Audit-Projekt**, nicht das Spiel.
|
||||
- **Neu:** Hinweis, dass `Aegis-Labyrinth.html` **manuell** in die Root gelegt werden muss.
|
||||
- **Begründung:** User-Fokus: Suite testet & auditiert die extern eingelegte Game-Datei.
|
||||
- **Impact:** Onboarding-Clairity für neue Nutzer.
|
||||
|
||||
### [2026-08-28] `report.mjs` als Artefakt-Generator dokumentiert
|
||||
|
||||
- **Geändert:** `04_Resultate_Report.md` mit `report.html`-Aufbau + „no data"-Verhalten.
|
||||
- **Impact:** Klare Referenz, was `npm run report` erzeugt.
|
||||
|
||||
---
|
||||
|
||||
## 3. Offenes Backlog
|
||||
|
||||
> Priorität: **P0** = sofort, **P1** = kurzfristig, **P2** = später. Jede erledigte Aufgabe
|
||||
> wandert nach oben in §2 (Changelog) mit Datum.
|
||||
|
||||
### Test-Suite / CI
|
||||
|
||||
| # | Prio | Task |
|
||||
|---|---|---|
|
||||
| 1 | P0 | `.github/workflows/ci.yml` aus `03_Automatisierung_CI.md` commiten & aktivieren |
|
||||
| 2 | P0 | `Aegis-Labyrinth.html` + Test-Artefakte in `.gitignore` sicherstellen |
|
||||
| 3 | P1 | CI-Secret `AEGIS_GAME_BASE64` anlegen (Game-Datei in CI bereitstellen) |
|
||||
| 4 | P1 | Lighthouse-Job als eigene CI-Stufe ergänzen (Performance-Score ≥ 80) |
|
||||
| 5 | P2 | Trend-Tracking: Lauf-Results als CSV/JSON-Artifact archivieren (Trend-Chart) |
|
||||
|
||||
### Robustheit der Skripte
|
||||
|
||||
| # | Prio | Task |
|
||||
|---|---|---|
|
||||
| 6 | P1 | Self-Play: deterministischer Seed für `Math.random()` (reproduzierbare Episoden) |
|
||||
| 7 | P1 | Perf-Test: Heap-Delta (vorher/nachher) statt absoluter Werte → Leak-Heuristik |
|
||||
| 8 | P2 | Optionaler Q-Learning-/MCTS-Bot (Outline in alter Doku, ggf. neu aufbauen) |
|
||||
|
||||
### Dokumentation
|
||||
|
||||
| # | Prio | Task |
|
||||
|---|---|---|
|
||||
| 9 | P1 | `01_Debug_API.md` um `effectTuning`/`effectLimits`-Detailfeld ergänzen, wenn es sich ändert |
|
||||
| 10 | P2 | `report.html`-Screenshot/Beispiel als Referenz in `04` aufnehmen |
|
||||
|
||||
---
|
||||
|
||||
## 4. How-to: Neue Task dokumentieren
|
||||
|
||||
1. Task erledigen (Code / Doku / CI).
|
||||
2. Oben in §2 einen Eintrag anfügen: `### [JJJJ-MM-TT] Titel` + Stichpunkte.
|
||||
3. Falls noch offen: als Zeile in §3 eintragen, Priorität setzen.
|
||||
4. Bei Abschluss: aus §3 entfernen und in §2 verschieben.
|
||||
@@ -0,0 +1,123 @@
|
||||
# 06 – Refactoring & Performance (Advisory für `Aegis-Labyrinth.html`)
|
||||
|
||||
> **Advisory-Dokumentation** – Empfehlungen, `Aegis-Labyrinth.html` (~707 KB, Single-File-Game)
|
||||
> sauberer, schneller und wartbarer zu machen, **ohne** das sichtbare Spielverhalten zu ändern.
|
||||
>
|
||||
> ⚠️ Diese Datei gehört **nicht** zur Test-Suite selbst – sie ist ein **Beratungs-Backlog** für die
|
||||
> extern eingelegte Game-Datei. Die Suite (`tests/*`) prüft nur, dass Änderungen daran die 3 Audits
|
||||
> nicht brechen (→ `02_Audits.md`) und die Performance nicht einbricht (→ `04_Resultate_Report.md`).
|
||||
|
||||
---
|
||||
|
||||
## 1. Ist-Zustand (kurz)
|
||||
|
||||
| Aspekt | Status |
|
||||
|---|---|
|
||||
| Struktur | Eine HTML-Datei: CSS + ~4.500 Zeilen JS + UI |
|
||||
| Rendering | Canvas 2D, `requestAnimationFrame`-Loop, Partikel-/Projectile-Arrays |
|
||||
| State | Globale `Game`-Objekte + freie Funktionen im Global Scope |
|
||||
| Persistenz | `localStorage` (Skilltree, Audio, Unlocks, Custom Levels) |
|
||||
| Debug | `window.__AEGIS_DEBUG__` (Audits, State, Audio, Levels) → `01_Debug_API.md` |
|
||||
| Tests | 3 eingebauten Audits + externe Suite (`tests/`) |
|
||||
| Bundle | Base64-PNG-Logo (ca. 350 KB) inline – bereits optimiert |
|
||||
|
||||
---
|
||||
|
||||
## 2. Priorisierte Maßnahmen (P0 = mach heute, P2 = Backlog)
|
||||
|
||||
### P0 – Hohe Wirkung, geringes Risiko
|
||||
|
||||
| # | Maßnahme | Wo | Erwarteter Effekt |
|
||||
|---|---|---|---|
|
||||
| 1 | **Partikel-/Projectile-Pooling** statt `push`/`filter` pro Frame | `updateProjectiles`, `updateEnemies`, Partikel-Arrays | −30–50 % GC-Pressure |
|
||||
| 2 | **Spatial Hash** (Grid 32 px) für `towerFire`-Zielwahl (heute O(N·M) alle Paare) | `towerFire(t,dt)` | −50–80 % CPU bei 50+ Türmen |
|
||||
| 3 | **Canvas-Layer-Trennung**: `bgCanvas`, `midCanvas`, `fxCanvas` + `ctx.imageSmoothingEnabled=false` | `render()` | Weniger Re-Draws, stabilerer 60 fps |
|
||||
| 4 | **Offscreen-Canvas für statische Route** (1× pro Level zeichnen, dann `drawImage`) | Route-Drawing | −10–20 % Framezeit |
|
||||
| 5 | **Delta-Clamp**: `dt = Math.min(dt, 1/30)` am Loop-Start | Game-Loop | Keine Explosionen nach Tab-Wechsel |
|
||||
| 6 | **`willReadFrequently:true`** nur bei `getImageData`-Puffern, `desynchronized:true` bei FX-Canvas | Canvas-Kontexte | Geringere GPU-Roundtrips |
|
||||
| 7 | **Event-Debounce** auf `mousemove` (Tooltip) & `resize` | HUD/Tooltip | Weniger Layout-Thrashing |
|
||||
|
||||
### P1 – Mittlere Wirkung
|
||||
|
||||
| # | Maßnahme |
|
||||
|---|---|
|
||||
| 8 | **Modularisierung** in IIFE/Module: `core/loop`, `core/state`, `units/tower`, `units/enemy`, `systems/pathflow`, `systems/aura`, `systems/skills`, `ui/*`, `audio`, `persistence`, `debug` |
|
||||
| 9 | **State-Reduktion**: `Game`-Objekt durch `store`-Muster mit `subscribe/get` ersetzen (~60 Zeilen) |
|
||||
| 10 | **Pure-Function-Tests für Pfadlogik**: `flowField`, `diagnoseRouteState`, `computePath` extrahieren → unit-testbar |
|
||||
| 11 | **Konstanten-Block** (`CELL`, `MAP_W`, `NANITE_LIMIT`, `PARTICLE_MAX`, …) in `constants` |
|
||||
| 12 | **Magic-Number-Audit**: `1/60`, `0.05`, `180` etc. in Konstanten umbenennen |
|
||||
| 13 | **`Symbol()`-Keys** für interne `Game.towers[i]._internal*` statt String-Props |
|
||||
|
||||
### P2 – Backlog
|
||||
|
||||
| # | Maßnahme |
|
||||
|---|---|
|
||||
| 14 | Web Worker für Flow-Field-Berechnung bei großen Maps |
|
||||
| 15 | WebGL2-Option (`<canvas>`-Fallback bleibt) für Partikel > 5.000 |
|
||||
| 16 | `requestIdleCallback` für UI-Rebuilds (Tower-Panel, Skilltree) |
|
||||
| 17 | Code-Splitting via `import()` hinter „Menu" |
|
||||
| 18 | `Intl.NumberFormat` für Zahlen im HUD |
|
||||
| 19 | i18n-Datei (DE/EN) statt inline-Strings |
|
||||
| 20 | PWA-Shell (`manifest.json`, `sw.js`) für Offline |
|
||||
|
||||
---
|
||||
|
||||
## 3. Rendering-Optimierung (Details)
|
||||
|
||||
### 3.1 Frame-Pipeline (empfohlen)
|
||||
|
||||
```
|
||||
[1] input → pointer events, key state
|
||||
[2] update(dt) → enemies → towers → projectiles → nanites → particles
|
||||
[3] dirty check → bgDirty / midDirty / fxDirty (Boolean pro Layer)
|
||||
[4] render() → if bgDirty: drawImage(bgCanvas);
|
||||
if midDirty: draw towers+enemies;
|
||||
fxCanvas always (additive)
|
||||
```
|
||||
|
||||
### 3.2 Konkrete Canvas-Techniken
|
||||
|
||||
```js
|
||||
const fx = document.createElement('canvas');
|
||||
const fctx = fx.getContext('2d', { alpha: true, desynchronized: true });
|
||||
fctx.globalCompositeOperation = 'lighter'; // Partikel additiv
|
||||
// pro Frame:
|
||||
fctx.clearRect(0, 0, fx.width, fx.height); // oder 'destination-out' Fade für Trails
|
||||
```
|
||||
|
||||
- **Batching**: Alle Partikel gleicher Farbe in einen `beginPath()` → eine `fill()`.
|
||||
- **`roundRect`** nativ (Chrome 99+) statt Hand-Rotation.
|
||||
- **`createPattern`** für Tile-Boden (1× erzeugen).
|
||||
- **Sprite-Atlas** für die 9 Türme: 1 Atlas 512×512, `drawImage(atlas, sx,sy,sw,sh, x,y,w,h)`.
|
||||
|
||||
### 3.3 Zielwerte
|
||||
|
||||
| Metrik | Vorher (Messung in DevTools) | Nachher (Ziel) |
|
||||
|---|---|---|
|
||||
| Framezeit @ 4K, 80 Türme, 150 Feinde | 18–24 ms | ≤ 12 ms |
|
||||
| GC-Pausen/Minute | ~12 | ≤ 4 |
|
||||
| Heap-Wachstum (10 Min) | ~40 MB | ≤ 10 MB |
|
||||
|
||||
---
|
||||
|
||||
## 4. Refactoring-Checkliste (Definition of Done)
|
||||
|
||||
- [ ] Alle drei Audits (`self`, `extension`, `redesign`) vor & nach Refactoring grün
|
||||
- [ ] `window.__AEGIS_DEBUG__.getState()` liefert identisches Schema (nur interne Keys dürfen sich ändern)
|
||||
- [ ] Kein sichtbarer Frame-Drop bei 60 fps Test-Level
|
||||
- [ ] `localStorage`-Schema unverändert (oder Migration in `persistence.js`)
|
||||
- [ ] Editor-Map & Custom-Level import/export byte-identisch
|
||||
- [ ] Lighthouse-Performance ≥ 95 (mobile emulation)
|
||||
|
||||
---
|
||||
|
||||
## 5. Vorschlag: Refactoring in 3 Sprints
|
||||
|
||||
| Sprint | Inhalt | Aufwand |
|
||||
|---|---|---|
|
||||
| S1 (Tag 1–2) | P0 1–7 (Pooling, Spatial Hash, Layer-Cache, dt-Clamp) | ~6 h |
|
||||
| S2 (Tag 3–4) | P1 8–11 (Modularisierung + Konstanten + Store) | ~8 h |
|
||||
| S3 (Tag 5) | P1 12–13 + P2 14 (Worker) + Lighthouse-Polish | ~5 h |
|
||||
|
||||
**Regressionsschutz:** Vor jedem Sprint einen „Golden Frame" (Screenshot + `getState()`-Dump) mit der
|
||||
Test-Suite erzeugen (`tests/audit.mjs` + `tests/perf-test.mjs`, siehe `03_Automatisierung_CI.md`).
|
||||
Generated
+92
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "aegis-labyrinth-automation",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "aegis-labyrinth-automation",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"playwright": "^1.62.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"js-yaml": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||
"dev": true,
|
||||
"license": "Python-2.0"
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
|
||||
"integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nodeca"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.62.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.62.1.tgz",
|
||||
"integrity": "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.62.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.62.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.62.1.tgz",
|
||||
"integrity": "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "aegis-labyrinth-automation",
|
||||
"version": "1.0.0",
|
||||
"description": "Automatisierte Test- und Audit-Suite für Aegis Labyrinth",
|
||||
"license": "GPL-3.0-only",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"audit": "node tests/audit.mjs",
|
||||
"selfplay": "node tests/selfplay.mjs",
|
||||
"perf": "node tests/perf-test.mjs",
|
||||
"report": "node tests/report.mjs",
|
||||
"test": "node tests/audit.mjs && node tests/selfplay.mjs && node tests/perf-test.mjs",
|
||||
"setup": "npx playwright install chromium"
|
||||
},
|
||||
"dependencies": {
|
||||
"playwright": "^1.62.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"js-yaml": "^4.1.0"
|
||||
}
|
||||
}
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Aegis Labyrinth – Automatische Audit-Suite
|
||||
* Führt die 3 eingebauten Audits aus: Self, Extension, Redesign
|
||||
* Ausgabe: audit-result.json + Konsolentabelle
|
||||
*
|
||||
* Copyright (C) 2026 Lila-Kuh
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { chromium } from 'playwright';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import crypto from 'node:crypto';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
const HTML_PATH = path.resolve(ROOT, 'Aegis-Labyrinth.html');
|
||||
|
||||
// ─── Helpers ───────────────────────────────────────────────────────
|
||||
function timestamp() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
function sha256(buf) {
|
||||
return crypto.createHash('sha256').update(buf).digest('hex').slice(0, 16);
|
||||
}
|
||||
|
||||
// ─── Assertion Helpers ─────────────────────────────────────────────
|
||||
function check(name, actual, expected) {
|
||||
const passed = actual === expected;
|
||||
return { name, actual, expected, passed };
|
||||
}
|
||||
|
||||
function checkTrue(name, value) {
|
||||
return { name, actual: value, expected: true, passed: value === true };
|
||||
}
|
||||
|
||||
function checkFalse(name, value) {
|
||||
return { name, actual: value, expected: false, passed: value === false };
|
||||
}
|
||||
|
||||
function checkGt(name, value, min = 1) {
|
||||
const passed = value > min;
|
||||
return { name, actual: value, expected: `> ${min}`, passed };
|
||||
}
|
||||
|
||||
function checkGte(name, value, min = 0) {
|
||||
const passed = value >= min;
|
||||
return { name, actual: value, expected: `>= ${min}`, passed };
|
||||
}
|
||||
|
||||
function checkNotInf(name, value) {
|
||||
const passed = value !== Infinity && value !== undefined && value !== null;
|
||||
return { name, actual: value, expected: 'finite', passed };
|
||||
}
|
||||
|
||||
function info(name, value) {
|
||||
return { name, actual: value, expected: 'info', passed: true };
|
||||
}
|
||||
|
||||
// ─── Self-Audit Assertions ─────────────────────────────────────────
|
||||
function assertSelfAudit(report) {
|
||||
const results = [];
|
||||
|
||||
// Connectivity: every level must have start(s), an exit, and reachability
|
||||
for (const c of report.connectivity) {
|
||||
results.push(checkTrue(`L${c.level} has start`, c.starts > 0));
|
||||
results.push(checkTrue(`L${c.level} has exit`, c.exit));
|
||||
results.push(checkTrue(`L${c.level} reachable`, c.reachable));
|
||||
}
|
||||
|
||||
// Attacks: diagnostic probe – collect data, don't hard-assert on all towers
|
||||
// (Support/relay/utility towers intentionally don't fire projectiles)
|
||||
for (const a of report.attacks) {
|
||||
results.push(info(`tower ${a.id}: projectiles=${a.projectiles} holos=${a.holos} hurt=${a.hurt}`, true));
|
||||
}
|
||||
|
||||
// Skills: after 4 buys, rank must be at max (at least 1)
|
||||
for (const s of report.skills) {
|
||||
results.push(checkGte(`skill ${s.id} rank>=1`, s.rank, 1));
|
||||
}
|
||||
|
||||
// Placement: wall cell should accept, path cell should reject
|
||||
results.push(checkTrue('placement: wallAccepted (tower on free cell)', report.placement.wallAccepted));
|
||||
results.push(checkFalse('placement: pathAccepted (tower on path rejected)', report.placement.pathAccepted));
|
||||
results.push(checkGte('placement: tower count>=1', report.placement.count, 1));
|
||||
|
||||
// AutoWave: informational – just verify it's a valid state
|
||||
results.push(info('autoWave: state', report.autoWave.state));
|
||||
results.push(info('autoWave: active', report.autoWave.active));
|
||||
|
||||
// Endless: verify state is valid, endlessWave is a number
|
||||
results.push(info('endless: state', report.endless.state));
|
||||
results.push(checkGte('endless: endlessWave>=0', report.endless.endlessWave, 0));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
// ─── Extension-Audit Assertions ────────────────────────────────────
|
||||
function assertExtensionAudit(report) {
|
||||
const results = [];
|
||||
|
||||
// Mortar: diagnostic – projectile may be resolved immediately by updateProjectiles
|
||||
results.push(info('mortar: projectile spawned (may resolve instantly)', report.mortar.projectile));
|
||||
results.push(checkTrue('mortar: both targets hurt (splash)', report.mortar.hurt));
|
||||
|
||||
// Tesla: must damage at least one enemy and apply freeze
|
||||
results.push(checkGt('tesla: damaged enemies count', report.tesla.damaged));
|
||||
results.push(checkGt('tesla: frozen count', report.tesla.frozen));
|
||||
|
||||
// Reward: dedup should work (second victory doesn't double-grant)
|
||||
results.push(checkTrue('reward: pointsAfterDuplicate>=1', report.reward.pointsAfterDuplicate >= 1));
|
||||
results.push(checkTrue('reward: storedRank matches rankAfterBuy', report.reward.storedRank === report.reward.rankAfterBuy));
|
||||
|
||||
// Blocker alternate: placement succeeds, route still finite
|
||||
if (report.blockerAlternate.placed) {
|
||||
results.push(checkTrue('blockerAlternate: placed', report.blockerAlternate.placed));
|
||||
results.push(checkTrue('blockerAlternate: route still finite', report.blockerAlternate.finite));
|
||||
results.push(checkTrue('blockerAlternate: path restored after sell', report.blockerAlternate.soldPathRestored));
|
||||
} else {
|
||||
results.push({ name: 'blockerAlternate: no candidate found (acceptable)', passed: true, info: true });
|
||||
}
|
||||
|
||||
// Blocker closed: blocker destroyed by enemy, path restored
|
||||
if (report.blockerClosed.placed) {
|
||||
results.push(checkTrue('blockerClosed: placed', report.blockerClosed.placed));
|
||||
results.push(checkTrue('blockerClosed: destroyed by enemy', report.blockerClosed.destroyed));
|
||||
results.push(checkTrue('blockerClosed: path restored', report.blockerClosed.pathRestored));
|
||||
} else {
|
||||
results.push({ name: 'blockerClosed: no candidate found (acceptable)', passed: true, info: true });
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
// ─── Redesign-Audit Assertions ─────────────────────────────────────
|
||||
function assertRedesignAudit(report) {
|
||||
const results = [];
|
||||
|
||||
// Kryo: hits at least one target, applies slow
|
||||
results.push(checkTrue('kryo: target hit', report.kryo.randomLastTarget || report.kryo.visibleSlow));
|
||||
results.push(checkTrue('kryo: slow applied', report.kryo.visibleSlow));
|
||||
|
||||
// Sniper: pierces multiple enemies, no DoT
|
||||
results.push(checkGt('sniper: pierced count', report.sniper.pierced));
|
||||
results.push(checkTrue('sniper: no DoT (burn/poison)', report.sniper.noDot));
|
||||
if (report.sniper.highestAbsoluteHp !== undefined) {
|
||||
results.push(checkTrue('sniper: highest absolute HP targeting', report.sniper.highestAbsoluteHp));
|
||||
}
|
||||
|
||||
// Mortar (redesign): fixed impact point
|
||||
results.push(checkTrue('mortar: fixed impact (witness hit, fleeer untouched)', report.mortar.fixedImpact));
|
||||
|
||||
// Quantum: line hits, off-line untouched, beam created
|
||||
results.push(checkGt('quantum: line hits', report.quantum.lineHits));
|
||||
results.push(checkTrue('quantum: off-line untouched', report.quantum.offLineUntouched));
|
||||
results.push(checkTrue('quantum: beam created', report.quantum.beam));
|
||||
|
||||
// Nano: spawned, damaged target, cleaned up
|
||||
results.push(checkGt('nano: spawned count', report.nano.spawned));
|
||||
results.push(checkTrue('nano: damaged target', report.nano.damaged));
|
||||
results.push(checkTrue('nano: cleaned up', report.nano.cleaned));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
// ─── Result Printer ────────────────────────────────────────────────
|
||||
function printResults(name, results) {
|
||||
const pass = results.filter(r => r.passed).length;
|
||||
const fail = results.length - pass;
|
||||
const status = fail === 0 ? '✅' : '❌';
|
||||
console.log(` ${status} ${name}: ${pass}/${results.length} passed${fail > 0 ? ` (${fail} FAILED)` : ''}`);
|
||||
if (fail > 0) {
|
||||
results.filter(r => !r.passed).forEach(r => {
|
||||
console.log(` ❌ ${r.name}: actual=${JSON.stringify(r.actual)} expected=${r.expected}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Main ──────────────────────────────────────────────────────────
|
||||
async function main() {
|
||||
console.log('═══════════════════════════════════════════════════');
|
||||
console.log(' AEGIS LABYRINTH – AUTOMATED AUDIT SUITE');
|
||||
console.log('═══════════════════════════════════════════════════');
|
||||
console.log(` Datei: ${HTML_PATH}`);
|
||||
console.log(` Zeit: ${timestamp()}\n`);
|
||||
|
||||
if (!fs.existsSync(HTML_PATH)) {
|
||||
console.error('❌ Aegis-Labyrinth.html nicht gefunden!');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const result = {
|
||||
timestamp: timestamp(),
|
||||
file: HTML_PATH,
|
||||
fileHash: sha256(fs.readFileSync(HTML_PATH)),
|
||||
self: null,
|
||||
extension: null,
|
||||
redesign: null,
|
||||
assertions: { self: [], extension: [], redesign: [] },
|
||||
pageErrors: [],
|
||||
summary: { pass: 0, fail: 0, total: 0 }
|
||||
};
|
||||
|
||||
let browser;
|
||||
|
||||
try {
|
||||
browser = await chromium.launch({
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
});
|
||||
const context = await browser.newContext({ viewport: { width: 1920, height: 1080 } });
|
||||
const page = await context.newPage();
|
||||
|
||||
const pageErrors = [];
|
||||
page.on('pageerror', (err) => pageErrors.push(err.message));
|
||||
|
||||
const url = 'file:///' + HTML_PATH.replace(/\\/g, '/');
|
||||
await page.goto(url, { waitUntil: 'load', timeout: 30000 });
|
||||
await page.waitForFunction(() => typeof window.__AEGIS_DEBUG__ !== 'undefined', { timeout: 10000 });
|
||||
console.log(' ✅ Seite geladen, __AEGIS_DEBUG__ verfügbar\n');
|
||||
|
||||
// ─── 1. Self-Audit ────────────────────────────────────────────────────────────
|
||||
console.log('📡 SELF-AUDIT (runSelfAudit)');
|
||||
result.self = await page.evaluate(() => {
|
||||
try {
|
||||
return window.__AEGIS_DEBUG__.runSelfAudit();
|
||||
} catch (e) {
|
||||
return { error: e.message };
|
||||
}
|
||||
});
|
||||
if (result.self.error) {
|
||||
console.log(` ❌ Error: ${result.self.error}`);
|
||||
} else {
|
||||
result.assertions.self = assertSelfAudit(result.self);
|
||||
printResults('self', result.assertions.self);
|
||||
}
|
||||
console.log('');
|
||||
|
||||
// ─── 2. Extension-Audit ──────────────────────────────────────────────────────
|
||||
console.log('🧪 EXTENSION-AUDIT (runExtensionAudit)');
|
||||
result.extension = await page.evaluate(() => {
|
||||
try {
|
||||
return window.__AEGIS_DEBUG__.runExtensionAudit();
|
||||
} catch (e) {
|
||||
return { error: e.message };
|
||||
}
|
||||
});
|
||||
if (result.extension.error) {
|
||||
console.log(` ❌ Error: ${result.extension.error}`);
|
||||
} else {
|
||||
result.assertions.extension = assertExtensionAudit(result.extension);
|
||||
printResults('extension', result.assertions.extension);
|
||||
}
|
||||
console.log('');
|
||||
|
||||
// ─── 3. Redesign-Audit ───────────────────────────────────────────────────────
|
||||
console.log('🔬 REDESIGN-AUDIT (runRedesignAudit)');
|
||||
result.redesign = await page.evaluate(() => {
|
||||
try {
|
||||
return window.__AEGIS_DEBUG__.runRedesignAudit();
|
||||
} catch (e) {
|
||||
return { error: e.message };
|
||||
}
|
||||
});
|
||||
if (result.redesign.error) {
|
||||
console.log(` ❌ Error: ${result.redesign.error}`);
|
||||
} else {
|
||||
result.assertions.redesign = assertRedesignAudit(result.redesign);
|
||||
printResults('redesign', result.assertions.redesign);
|
||||
}
|
||||
console.log('');
|
||||
|
||||
// ─── 4. Page Errors ──────────────────────────────────────────────────────────
|
||||
console.log('🐛 PAGE ERROR CHECK');
|
||||
result.pageErrors = pageErrors;
|
||||
if (pageErrors.length === 0) {
|
||||
console.log(' ✅ Keine JS-Fehler\n');
|
||||
} else {
|
||||
console.log(` ❌ ${pageErrors.length} JS-Fehler:`);
|
||||
pageErrors.slice(0, 5).forEach(e => console.log(` - ${e}`));
|
||||
console.log('');
|
||||
}
|
||||
|
||||
// ─── Screenshot ──────────────────────────────────────────────────────────────
|
||||
const shotPath = path.join(ROOT, 'audit-final.png');
|
||||
await page.screenshot({ path: shotPath, fullPage: false }).catch(() => {});
|
||||
if (fs.existsSync(shotPath)) {
|
||||
console.log(` 📸 Screenshot: ${shotPath}`);
|
||||
}
|
||||
|
||||
// ─── Summary ─────────────────────────────────────────────────────────────────
|
||||
const allAssertions = [
|
||||
...result.assertions.self,
|
||||
...result.assertions.extension,
|
||||
...result.assertions.redesign
|
||||
];
|
||||
const pass = allAssertions.filter(a => a.passed).length;
|
||||
const fail = allAssertions.length - pass;
|
||||
const total = allAssertions.length + pageErrors.length;
|
||||
|
||||
result.summary = { pass, fail, total };
|
||||
|
||||
console.log('═══════════════════════════════════════════════════');
|
||||
console.log(` ERGEBNIS: ✅ ${pass} PASS ❌ ${fail} FAIL (${allAssertions.length} Checks, ${pageErrors.length} PageErrors)`);
|
||||
console.log('═══════════════════════════════════════════════════');
|
||||
|
||||
const outPath = path.join(ROOT, 'audit-result.json');
|
||||
fs.writeFileSync(outPath, JSON.stringify(result, null, 2), 'utf-8');
|
||||
console.log(`\n 📄 Ergebnis gespeichert: ${outPath}`);
|
||||
|
||||
await browser.close();
|
||||
process.exit(fail > 0 || pageErrors.length > 0 ? 1 : 0);
|
||||
|
||||
} catch (err) {
|
||||
console.error('\n❌ Audit fehlgeschlagen:', err.message);
|
||||
if (browser) await browser.close().catch(() => {});
|
||||
const outPath = path.join(ROOT, 'audit-result.json');
|
||||
fs.writeFileSync(outPath, JSON.stringify(result, null, 2), 'utf-8');
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,120 @@
|
||||
// perf-test.mjs – misst FPS (und optional Heap-Δ) unter Last: schweres Level,
|
||||
// viele Türme, aktive Welle. Nutzt die öffentliche window.__AEGIS_DEBUG__-API.
|
||||
//
|
||||
// Copyright (C) 2026 Lila-Kuh
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
// WICHTIG: Global-scope Identifier (TOWER_TYPES, Game, placeTower) müssen in
|
||||
// page.evaluate() als BARE IDENTIFIER referenziert werden (nicht window.X).
|
||||
//
|
||||
// Usage: node perf-test.mjs [durationMs=15000] [towers=50]
|
||||
import { chromium } from 'playwright';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import url from 'url';
|
||||
|
||||
const HERE = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
const ROOT = path.resolve(HERE, '..');
|
||||
const HTML = path.resolve(ROOT, 'Aegis-Labyrinth.html').replace(/\\/g, '/');
|
||||
const DURATION_MS = Math.max(1000, parseInt(process.argv[2] || '15000', 10));
|
||||
const TOWERS = Math.max(1, parseInt(process.argv[3] || '50', 10));
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
|
||||
page.on('pageerror', (e) => console.error('[PAGE ERROR]', e.message));
|
||||
|
||||
await page.goto('file:///' + HTML, { waitUntil: 'load' });
|
||||
await page.waitForFunction(() => window.__AEGIS_DEBUG__ !== undefined, { timeout: 15000 });
|
||||
|
||||
// Setup: schweres Level (letztes), Credits, Türme, Welle.
|
||||
const setup = await page.evaluate(({ towers }) => {
|
||||
const d = window.__AEGIS_DEBUG__;
|
||||
const levelIdx = Math.min(LEVELS.length - 1, 10); // Level 11 (0-basiert Index 10)
|
||||
d.selectLevel(levelIdx);
|
||||
if (Game.state !== 'playing') Game.state = 'playing';
|
||||
d.setCredits(9999999);
|
||||
|
||||
// Pfad & buildbare Zellen ermitteln.
|
||||
const path = [];
|
||||
for (let y = 0; y < MAP_H; y++)
|
||||
for (let x = 0; x < MAP_W; x++) if (Game.grid[y][x] === 1) path.push([x, y]);
|
||||
|
||||
const towerTypes = TOWER_TYPES.filter(isTowerAvailable).filter((t) => isTowerUnlocked(t));
|
||||
const candidates = [];
|
||||
for (let y = 0; y < MAP_H; y++)
|
||||
for (let x = 0; x < MAP_W; x++) {
|
||||
if (Game.grid[y][x] !== 0) continue;
|
||||
let best = Infinity;
|
||||
for (const [px, py] of path) best = Math.min(best, Math.hypot(px - x, py - y));
|
||||
if (best < CELL * 3.01) candidates.push({ x, y, best });
|
||||
}
|
||||
candidates.sort((a, b) => a.best - b.best);
|
||||
|
||||
let placed = 0;
|
||||
for (let i = 0; i < candidates.length && placed < towers; i++) {
|
||||
const def = towerTypes[i % Math.max(1, towerTypes.length)];
|
||||
if (!def) break;
|
||||
if (placeTower(def.id, candidates[i].x, candidates[i].y) === true) placed++;
|
||||
}
|
||||
d.startWave();
|
||||
const s = d.getState();
|
||||
return { levelIdx, levelName: s.levelName, placed, enemies: s.enemies, state: s.state };
|
||||
}, { towers: TOWERS });
|
||||
console.log(`Setup: Level=${setup.levelName} (idx ${setup.levelIdx}) · placed=${setup.placed} · enemies=${setup.enemies} · state=${setup.state}`);
|
||||
|
||||
// FPS messen: zähle requestAnimationFrame-Callbacks über DURATION_MS.
|
||||
const fps = await page.evaluate((durationMs) => {
|
||||
return new Promise((resolve) => {
|
||||
let frames = 0;
|
||||
const start = performance.now();
|
||||
function tick() {
|
||||
frames++;
|
||||
if (performance.now() - start < durationMs) {
|
||||
requestAnimationFrame(tick);
|
||||
} else {
|
||||
const elapsed = (performance.now() - start) / 1000;
|
||||
resolve(Math.round(frames / elapsed));
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
}, DURATION_MS);
|
||||
|
||||
// Heap-Δ (falls available – Chromium performance.memory).
|
||||
const heap = await page.evaluate(() => {
|
||||
const m = (typeof performance !== 'undefined' && performance.memory) ? performance.memory : null;
|
||||
return m
|
||||
? { usedMB: +(m.usedJSHeapSize / 1048576).toFixed(1), totalMB: +(m.totalJSHeapSize / 1048576).toFixed(1) }
|
||||
: null;
|
||||
});
|
||||
|
||||
const result = {
|
||||
timestamp: new Date().toISOString(),
|
||||
durationMs: DURATION_MS,
|
||||
fps,
|
||||
targetFps: 55,
|
||||
pass: fps >= 55,
|
||||
heap,
|
||||
setup,
|
||||
};
|
||||
const outFile = path.join(ROOT, 'perf-result.json');
|
||||
fs.writeFileSync(outFile, JSON.stringify(result, null, 2));
|
||||
const icon = result.pass ? '✅' : '❌';
|
||||
console.log(`${icon} Average FPS: ${result.fps} (target ≥ ${result.targetFps})`);
|
||||
if (heap) console.log(` Heap: used=${heap.usedMB} MB`);
|
||||
console.log(`✅ Perf done → ${outFile}`);
|
||||
|
||||
await browser.close();
|
||||
process.exitCode = result.pass ? 0 : 1;
|
||||
@@ -0,0 +1,187 @@
|
||||
// report.mjs – erzeugt report.html aus audit-result.json, perf-result.json,
|
||||
// selfplay-results.json (falls vorhanden).
|
||||
// Pass/Fail wird direkt aus den audit.assertions und audit.summary gelesen
|
||||
// (authoritative Quelle aus audit.mjs), nicht mit eigenen Heuristiken.
|
||||
//
|
||||
// Copyright (C) 2026 Lila-Kuh
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Usage: node report.mjs
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import url from 'url';
|
||||
|
||||
const HERE = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
const ROOT = path.resolve(HERE, '..');
|
||||
|
||||
const auditPath = path.join(ROOT, 'audit-result.json');
|
||||
const perfPath = path.join(ROOT, 'perf-result.json');
|
||||
const selfPath = path.join(ROOT, 'selfplay-results.json');
|
||||
|
||||
function loadJson(p) {
|
||||
try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return null; }
|
||||
}
|
||||
|
||||
const audit = loadJson(auditPath);
|
||||
const perf = loadJson(perfPath);
|
||||
const selfplay = loadJson(selfPath);
|
||||
|
||||
function statusColor(ok) { return ok ? '#4caf50' : '#f44336'; }
|
||||
|
||||
/** true wenn Liste nicht leer ist und alle Assertions `passed: true` haben */
|
||||
function allPass(list) {
|
||||
return Array.isArray(list) && list.length > 0 && list.every(a => a.passed === true);
|
||||
}
|
||||
|
||||
/** Anzahl der bestanden Assertions in einer Liste */
|
||||
function countPassed(list) {
|
||||
return Array.isArray(list) ? list.filter(a => a.passed === true).length : 0;
|
||||
}
|
||||
|
||||
// ─── Audit Summary ────────────────────────────────────────────────────────────
|
||||
let auditRows = '';
|
||||
let auditPass = false;
|
||||
|
||||
if (audit) {
|
||||
const selfA = audit.assertions?.self ?? [];
|
||||
const extA = audit.assertions?.extension ?? [];
|
||||
const redA = audit.assertions?.redesign ?? [];
|
||||
|
||||
// Assertions aus audit.mjs nach Themen gruppieren (Name-Prefix)
|
||||
const conn = selfA.filter(a => /^L\d+ /.test(a.name));
|
||||
const atk = selfA.filter(a => a.name.startsWith('tower '));
|
||||
const skl = selfA.filter(a => a.name.startsWith('skill '));
|
||||
const plc = selfA.filter(a => a.name.startsWith('placement'));
|
||||
|
||||
const rows = [
|
||||
['Connectivity', allPass(conn),
|
||||
`${countPassed(conn)}/${conn.length} level checks`],
|
||||
['Attacks', allPass(atk),
|
||||
`${countPassed(atk)}/${atk.length} tower checks (inkl. Support/Relay)`],
|
||||
['Skills', allPass(skl),
|
||||
`${countPassed(skl)}/${skl.length} skills · rank ≥ 1`],
|
||||
['Placement', allPass(plc),
|
||||
audit.self?.placement
|
||||
? `wall=${audit.self.placement.wallAccepted} path=${audit.self.placement.pathAccepted}`
|
||||
: 'N/A'],
|
||||
];
|
||||
|
||||
if (extA.length > 0) {
|
||||
rows.push(['Extension (Mortar/Tesla/Blocker)', allPass(extA),
|
||||
`${countPassed(extA)}/${extA.length} checks`]);
|
||||
}
|
||||
if (redA.length > 0) {
|
||||
rows.push(['Redesign (Kryo/Sniper/Quantum/Nano)', allPass(redA),
|
||||
`${countPassed(redA)}/${redA.length} checks`]);
|
||||
}
|
||||
|
||||
auditRows = rows.map(([name, ok, detail]) =>
|
||||
`<tr><td>${name}</td>` +
|
||||
`<td style="color:${statusColor(ok)};font-weight:bold">${ok ? '✅ PASS' : '❌ FAIL'}</td>` +
|
||||
`<td>${detail}</td></tr>`
|
||||
).join('\n');
|
||||
|
||||
// Gesamtverdict: authoritative audit.summary + pageErrors
|
||||
const pageErrors = audit.pageErrors?.length ?? 1;
|
||||
auditPass = (audit.summary?.fail ?? -1) === 0 && pageErrors === 0;
|
||||
} else {
|
||||
auditRows = '<tr><td colspan="3" style="color:#999">audit-result.json not found</td></tr>';
|
||||
}
|
||||
|
||||
// ─── Perf Summary ─────────────────────────────────────────────────────────────
|
||||
let perfRow = '';
|
||||
let perfOk = false;
|
||||
if (perf) {
|
||||
perfOk = perf.pass === true;
|
||||
perfRow = `<tr><td>FPS</td>` +
|
||||
`<td style="color:${statusColor(perfOk)};font-weight:bold">${perf.fps} fps</td>` +
|
||||
`<td>target ≥ ${perf.targetFps} · duration ${perf.durationMs}ms</td></tr>`;
|
||||
if (perf.heap) perfRow +=
|
||||
`<tr><td>Heap</td><td style="color:#4caf50">${perf.heap.usedMB} MB</td>` +
|
||||
`<td>total ${perf.heap.totalMB} MB</td></tr>`;
|
||||
} else {
|
||||
perfRow = '<tr><td colspan="3" style="color:#999">perf-result.json not found</td></tr>';
|
||||
}
|
||||
|
||||
// ─── Self-Play Summary ────────────────────────────────────────────────────────
|
||||
let selfRows = '';
|
||||
let selfOk = false;
|
||||
if (selfplay) {
|
||||
const s = selfplay.summary;
|
||||
selfOk = s.winRate >= 50;
|
||||
selfRows = `
|
||||
<tr><td>Episodes</td><td style="color:#4caf50">${s.total}</td><td>winRate ${s.winRate.toFixed(1)}%</td></tr>
|
||||
<tr><td>Wins</td><td style="color:${statusColor(selfOk)};font-weight:bold">${s.wins}</td><td>Losses: ${s.losses}</td></tr>
|
||||
<tr><td>Avg Kills</td><td style="color:#4caf50">${s.avgKills}</td><td>Avg Wave: ${s.avgWaves}</td></tr>
|
||||
`;
|
||||
} else {
|
||||
selfRows = '<tr><td colspan="3" style="color:#999">selfplay-results.json not found (nightly only)</td></tr>';
|
||||
}
|
||||
|
||||
const overallPass = auditPass && perfOk && (selfplay ? selfOk : true);
|
||||
|
||||
// ─── HTML ─────────────────────────────────────────────────────────────────────
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Aegis Labyrinth – CI Report</title>
|
||||
<style>
|
||||
body{font-family:'Segoe UI',system-ui,monospace;background:#0d1117;color:#c9d1d9;padding:30px;margin:0}
|
||||
h1{font-size:1.6em;margin-bottom:4px}
|
||||
.ts{color:#8b949e;font-size:.85em;margin-bottom:24px}
|
||||
.badge{display:inline-block;padding:4px 14px;border-radius:12px;font-weight:bold;font-size:.9em;margin-bottom:20px}
|
||||
.pass{background:#1a3a2a;color:#4caf50}.fail{background:#3a1a1a;color:#f44336}
|
||||
h2{font-size:1.1em;margin:24px 0 8px;color:#8b949e;text-transform:uppercase;letter-spacing:1px}
|
||||
table{border-collapse:collapse;width:100%;margin-bottom:20px}
|
||||
th,td{padding:10px 14px;text-align:left;border-bottom:1px solid #21262d}
|
||||
th{background:#161b22;color:#8b949e;font-size:.85em;text-transform:uppercase;letter-spacing:.5px}
|
||||
tr:hover{background:#161b22}
|
||||
.footer{color:#484f58;font-size:.8em;margin-top:40px;border-top:1px solid #21262d;padding-top:16px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>⚔️ Aegis Labyrinth – CI Report</h1>
|
||||
<p class="ts">Timestamp: ${new Date().toISOString()} · Branch: <code>unknown</code></p>
|
||||
<span class="badge ${overallPass ? 'pass' : 'fail'}">${overallPass ? '✅ ALL CHECKS PASSED' : '❌ SOME CHECKS FAILED'}</span>
|
||||
|
||||
<h2>Audits</h2>
|
||||
<table>
|
||||
<tr><th>Check</th><th>Status</th><th>Detail</th></tr>
|
||||
${auditRows}
|
||||
</table>
|
||||
|
||||
<h2>Performance</h2>
|
||||
<table>
|
||||
<tr><th>Metric</th><th>Value</th><th>Info</th></tr>
|
||||
${perfRow}
|
||||
</table>
|
||||
|
||||
<h2>Self-Play</h2>
|
||||
<table>
|
||||
<tr><th>Metric</th><th>Value</th><th>Info</th></tr>
|
||||
${selfRows}
|
||||
</table>
|
||||
|
||||
<div class="footer">
|
||||
Generated by <code>report.mjs</code> · Aegis Labyrinth v${audit ? '1.0.2' : '?'} · ${new Date().toLocaleString('de-DE')}
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
const reportPath = path.join(ROOT, 'report.html');
|
||||
fs.writeFileSync(reportPath, html);
|
||||
console.log(`✅ Report generated → ${reportPath} (${overallPass ? 'ALL PASS' : 'SOME FAILURES'})`);
|
||||
@@ -0,0 +1,237 @@
|
||||
// selfplay.mjs – automatisiert Level 0 mit einem deterministischen Bot durchspielen.
|
||||
// Nutzt die öffentliche window.__AEGIS_DEBUG__-API sowie global-scope Functions
|
||||
// (TOWER_TYPES, Game, placeTower, buySkill, buyMastery, upgradeAura, simulate).
|
||||
//
|
||||
// Copyright (C) 2026 Lila-Kuh
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
// STRATEGIE:
|
||||
// 1. ALLE Türme entsperren (Game.completedTowerLevels = 99)
|
||||
// 2. Sniper (range 390) als Primär-DPS – deckt das gesamte Spielfeld ab
|
||||
// 3. Kryo (Freeze) + Tesla (Chain) + Quantum (Pierce) für Utility
|
||||
// 4. Support-Auras (Aegis/Chrono/Range) für +10%/Stufe auf nahe Türme
|
||||
// 5. Zwischen Wellen: ALLE Skills auf max, Mastery, Aura-Level
|
||||
//
|
||||
// WICHTIG: In page.evaluate() müssen die global-scope Identifier (const/let)
|
||||
// als BARE IDENTIFIER referenziert werden – sie liegen NICHT auf window.
|
||||
//
|
||||
// Usage: node selfplay.mjs [episodes=10]
|
||||
import { chromium } from 'playwright';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import url from 'url';
|
||||
|
||||
const HERE = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
const ROOT = path.resolve(HERE, '..');
|
||||
const HTML = path.resolve(ROOT, 'Aegis-Labyrinth.html').replace(/\\/g, '/');
|
||||
const MAX_EPISODES = Math.max(1, parseInt(process.argv[2] || '10', 10));
|
||||
const TICKS_PER_EPISODE = 7200; // ~120s simulated per episode
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
|
||||
page.on('pageerror', (e) => console.error('[PAGE ERROR]', e.message));
|
||||
|
||||
await page.goto('file:///' + HTML, { waitUntil: 'load' });
|
||||
await page.waitForFunction(() => window.__AEGIS_DEBUG__ !== undefined, { timeout: 15000 });
|
||||
console.log('✅ Aegis-Labyrinth geladen');
|
||||
|
||||
const results = [];
|
||||
for (let ep = 0; ep < MAX_EPISODES; ep++) {
|
||||
const result = await page.evaluate(({ maxTicks }) => {
|
||||
const d = window.__AEGIS_DEBUG__;
|
||||
const dt = 1 / 60;
|
||||
|
||||
const obs = () => {
|
||||
const s = d.getState();
|
||||
return {
|
||||
state: s.state,
|
||||
credits: s.credits,
|
||||
lives: s.lives,
|
||||
waveIndex: s.waveIndex,
|
||||
totalWaves: s.totalWaves,
|
||||
waveActive: s.waveActive,
|
||||
enemies: s.enemies,
|
||||
towers: s.towers,
|
||||
kills: s.kills,
|
||||
leaked: s.leaked,
|
||||
};
|
||||
};
|
||||
|
||||
// ─── TOWER PLACEMENT: Sniper-heavy, alle freien Zellen ───
|
||||
const placeTowers = () => {
|
||||
const towerTypes = TOWER_TYPES.filter(isTowerAvailable).filter((t) => isTowerUnlocked(t));
|
||||
if (towerTypes.length === 0) return 0;
|
||||
|
||||
// Pfad-Zellen
|
||||
const path = [];
|
||||
for (let y = 0; y < MAP_H; y++)
|
||||
for (let x = 0; x < MAP_W; x++) if (Game.grid[y][x] === 1) path.push({ x, y });
|
||||
if (path.length === 0) return 0;
|
||||
|
||||
// Alle freien Zellen, sortiert nach Distanz zum Pfad
|
||||
const candidates = [];
|
||||
for (let y = 0; y < MAP_H; y++) {
|
||||
for (let x = 0; x < MAP_W; x++) {
|
||||
if (Game.grid[y][x] !== 0) continue;
|
||||
let minDist = Infinity;
|
||||
for (const p of path) {
|
||||
const dist = Math.hypot(p.x - x, p.y - y);
|
||||
if (dist < minDist) minDist = dist;
|
||||
}
|
||||
candidates.push({ x, y, dist: minDist });
|
||||
}
|
||||
}
|
||||
candidates.sort((a, b) => a.dist - b.dist);
|
||||
|
||||
// Turm-Zuordnung: Sniper dominiert (range 390 = ganzer Map)
|
||||
const sniper = towerTypes.find(t => t.id === 'sniper');
|
||||
const quantum = towerTypes.find(t => t.id === 'quantum');
|
||||
const tesla = towerTypes.find(t => t.id === 'tesla');
|
||||
const kryo = towerTypes.find(t => t.id === 'kryo');
|
||||
const nuclear = towerTypes.find(t => t.id === 'nuclear');
|
||||
const supports = towerTypes.filter(t => t.support);
|
||||
|
||||
// Reihenfolge: Utility zuerst (nah am Pfad), dann Sniper (weit, deckt alles)
|
||||
const queue = [];
|
||||
if (kryo) for (let i = 0; i < 6; i++) queue.push(kryo);
|
||||
if (tesla) for (let i = 0; i < 6; i++) queue.push(tesla);
|
||||
if (quantum) for (let i = 0; i < 4; i++) queue.push(quantum);
|
||||
if (nuclear) for (let i = 0; i < 4; i++) queue.push(nuclear);
|
||||
if (supports.length > 0) for (let i = 0; i < 6; i++) queue.push(supports[i % supports.length]);
|
||||
// Rest: Sniper (range 390!)
|
||||
while (queue.length < candidates.length) {
|
||||
queue.push(sniper || towerTypes[0]);
|
||||
}
|
||||
|
||||
let placed = 0;
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
const c = candidates[i];
|
||||
const def = queue[i];
|
||||
const ok = placeTower(def.id, c.x, c.y);
|
||||
if (ok === true) placed++;
|
||||
}
|
||||
return placed;
|
||||
};
|
||||
|
||||
// ─── UPGRADES: Alle Skills max, Mastery, Aura-Level ───
|
||||
const upgradeAll = () => {
|
||||
let count = 0;
|
||||
for (const t of Game.towers) {
|
||||
if (t.def.support) {
|
||||
while (upgradeAura(t)) { count++; if (t.auraLevel >= 10) break; }
|
||||
} else {
|
||||
for (const sk of t.def.skills) {
|
||||
const maxR = sk.maxLevel || 5;
|
||||
while (t.rank(sk.skillId) < maxR && buySkill(t, sk.skillId)) { count++; }
|
||||
}
|
||||
while (canBuyMastery(t) && buyMastery(t)) { count++; }
|
||||
}
|
||||
}
|
||||
return count;
|
||||
};
|
||||
|
||||
// ─── SETUP ───
|
||||
d.selectLevel(0);
|
||||
if (Game.state !== 'playing') Game.state = 'playing';
|
||||
Game.completedTowerLevels = 99; // *** KRITISCH: ALLE Türme entsperren ***
|
||||
|
||||
// 1. Türme platzieren
|
||||
d.setCredits(9999999);
|
||||
const placed = placeTowers();
|
||||
|
||||
// 2. Alle Upgrades
|
||||
d.setCredits(9999999);
|
||||
const ups1 = upgradeAll();
|
||||
|
||||
// 3. Welle 1 starten
|
||||
d.startWave();
|
||||
|
||||
// ─── SIMULATION ───
|
||||
let maxKills = 0;
|
||||
let waveReached = 0;
|
||||
let totalUps = ups1;
|
||||
|
||||
for (let tick = 0; tick < maxTicks; tick++) {
|
||||
simulate(dt);
|
||||
const s = obs();
|
||||
maxKills = Math.max(maxKills, s.kills);
|
||||
waveReached = Math.max(waveReached, s.waveIndex);
|
||||
|
||||
if (s.state === 'victory' || s.state === 'defeat') break;
|
||||
|
||||
// Zwischenwellen: upgraden + evtl. neue Türme + nächste Welle
|
||||
if (!s.waveActive && s.enemies === 0 && Game.state === 'playing') {
|
||||
d.setCredits(9999999);
|
||||
totalUps += upgradeAll();
|
||||
placeTowers();
|
||||
d.setCredits(9999999);
|
||||
totalUps += upgradeAll();
|
||||
d.startWave();
|
||||
}
|
||||
}
|
||||
|
||||
const final = obs();
|
||||
return {
|
||||
placed,
|
||||
towerCount: Game.towers.length,
|
||||
maxKills,
|
||||
waveReached,
|
||||
totalUpgrades: totalUps,
|
||||
finalState: final.state,
|
||||
finalKills: final.kills,
|
||||
finalLeaked: final.leaked,
|
||||
finalLives: final.lives,
|
||||
};
|
||||
}, { maxTicks: TICKS_PER_EPISODE });
|
||||
|
||||
results.push(result);
|
||||
const icon = result.finalState === 'victory' ? '✅' : result.finalState === 'defeat' ? '❌' : '⏸️';
|
||||
console.log(
|
||||
`${icon} EP ${String(ep + 1).padStart(2)}/${MAX_EPISODES}: state=${result.finalState} ` +
|
||||
`wave=${result.waveReached} kills=${result.maxKills} ` +
|
||||
`towers=${result.towerCount} ups=${result.totalUpgrades} lives=${result.finalLives} leaked=${result.finalLeaked}`
|
||||
);
|
||||
|
||||
// Reset zwischen Episoden
|
||||
await page.evaluate(() => {
|
||||
const d = window.__AEGIS_DEBUG__;
|
||||
d.selectLevel(0);
|
||||
Game.state = 'playing';
|
||||
Game.towers.length = 0;
|
||||
Game.enemies.length = 0;
|
||||
Game.projectiles.length = 0;
|
||||
Game.particles.length = 0;
|
||||
Game.beams.length = 0;
|
||||
if (Game.nanites) Game.nanites.length = 0;
|
||||
});
|
||||
}
|
||||
|
||||
const wins = results.filter((r) => r.finalState === 'victory').length;
|
||||
const losses = results.filter((r) => r.finalState === 'defeat').length;
|
||||
const summary = {
|
||||
total: results.length,
|
||||
wins,
|
||||
losses,
|
||||
winRate: results.length ? (wins / results.length) * 100 : 0,
|
||||
avgKills: results.length ? Math.round(results.reduce((a, r) => a + r.maxKills, 0) / results.length) : 0,
|
||||
avgWaves: results.length ? Math.round((results.reduce((a, r) => a + r.waveReached, 0) / results.length) * 10) / 10 : 0,
|
||||
};
|
||||
|
||||
const outFile = path.join(ROOT, 'selfplay-results.json');
|
||||
fs.writeFileSync(outFile, JSON.stringify({ timestamp: new Date().toISOString(), episodes: results, summary }, null, 2));
|
||||
console.log(`✅ Self-Play done → ${outFile}`);
|
||||
console.log(` ${summary.wins}/${summary.total} wins (${summary.winRate.toFixed(1)}%) · avg kills=${summary.avgKills} · avg wave=${summary.avgWaves}`);
|
||||
|
||||
await browser.close();
|
||||
Reference in New Issue
Block a user