From 13e34a6f424d9b2d9eae04211568a35ddb2badf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Thu, 9 Nov 2017 14:06:35 +0100 Subject: [PATCH] sicherung --- makefile | 49 ++- quelldatein/aufbau/aktor.ts | 17 + quelldatein/aufbau/akzeptoraufgabe.ts | 90 +++++ quelldatein/aufbau/akzeptortest.ts | 73 +++++ quelldatein/aufbau/annehmer.ts | 17 + quelldatein/aufbau/aufgabe.ts | 48 +++ quelldatein/aufbau/aufgabe_.ts | 69 ++++ quelldatein/aufbau/befoerderer.ts | 17 + quelldatein/aufbau/erzeuger.ts | 76 +++++ quelldatein/aufbau/figur.ts | 23 +- quelldatein/aufbau/leser.ts | 17 + quelldatein/aufbau/partie.ts | 211 ++++++++++++ quelldatein/aufbau/richtung.ts | 17 + quelldatein/aufbau/schreiber.ts | 17 + quelldatein/aufbau/stelle.ts | 17 + quelldatein/aufbau/symbol.ts | 17 + quelldatein/aufbau/test.ts | 43 +++ quelldatein/aufbau/transduktor.ts | 16 - quelldatein/aufbau/transduktoraufgabe.ts | 90 +++++ quelldatein/aufbau/transduktortest.ts | 74 +++++ quelldatein/aufbau/verwerfer.ts | 17 + quelldatein/aufbau/welt.ts | 125 +++---- quelldatein/aufbau/zustand.ts | 23 +- quelldatein/basis/fehlermonade.ts | 17 + quelldatein/basis/typen.ts | 17 + quelldatein/darstellung_steuerung/position.ts | 33 -- quelldatein/darstellung_steuerung/vtm.css | 17 - quelldatein/darstellung_steuerung/vtm.html | 17 - quelldatein/daten.ts | 62 ++++ quelldatein/daten/aufgaben.dat.js | 109 ++++++ quelldatein/daten/aufgaben.json | 27 -- quelldatein/haupt.ts | 199 +++++++---- quelldatein/helfer/hashmap.ts | 17 + quelldatein/helfer/mathematik.ts | 17 + quelldatein/helfer/vektor.ts | 17 + quelldatein/helfer/verschiedenes.ts | 17 + quelldatein/helfer/xmlknoten.ts | 17 + quelldatein/manifestation/manifestation.ts | 67 ++++ .../welt.css => manifestation/partie.css} | 7 +- .../welt.ts => manifestation/partie.ts} | 310 ++++++++++++------ quelldatein/manifestation/position.ts | 50 +++ .../svg.ts | 19 +- quelldatein/manifestation/vtm.css | 79 +++++ quelldatein/manifestation/vtm.html | 92 ++++++ quelldatein/test.ts | 54 --- readme.md | 10 + 46 files changed, 2030 insertions(+), 404 deletions(-) create mode 100644 quelldatein/aufbau/akzeptoraufgabe.ts create mode 100644 quelldatein/aufbau/akzeptortest.ts create mode 100644 quelldatein/aufbau/aufgabe.ts create mode 100644 quelldatein/aufbau/aufgabe_.ts create mode 100644 quelldatein/aufbau/erzeuger.ts create mode 100644 quelldatein/aufbau/partie.ts create mode 100644 quelldatein/aufbau/test.ts delete mode 100644 quelldatein/aufbau/transduktor.ts create mode 100644 quelldatein/aufbau/transduktoraufgabe.ts create mode 100644 quelldatein/aufbau/transduktortest.ts delete mode 100644 quelldatein/darstellung_steuerung/position.ts delete mode 100644 quelldatein/darstellung_steuerung/vtm.css delete mode 100644 quelldatein/darstellung_steuerung/vtm.html create mode 100644 quelldatein/daten.ts create mode 100644 quelldatein/daten/aufgaben.dat.js delete mode 100644 quelldatein/daten/aufgaben.json create mode 100644 quelldatein/manifestation/manifestation.ts rename quelldatein/{darstellung_steuerung/welt.css => manifestation/partie.css} (89%) rename quelldatein/{darstellung_steuerung/welt.ts => manifestation/partie.ts} (54%) create mode 100644 quelldatein/manifestation/position.ts rename quelldatein/{darstellung_steuerung => manifestation}/svg.ts (68%) create mode 100644 quelldatein/manifestation/vtm.css create mode 100644 quelldatein/manifestation/vtm.html delete mode 100644 quelldatein/test.ts create mode 100644 readme.md diff --git a/makefile b/makefile index 55177b9..e5ba112 100644 --- a/makefile +++ b/makefile @@ -1,15 +1,20 @@ -alles: erzeugnis/vtm.html erzeugnis/vtm.css erzeugnis/vtm.js +alles: erzeugnis/vtm.html erzeugnis/vtm.css erzeugnis/aufgaben.dat.js erzeugnis/vtm.js .PHONY: alles -erzeugnis/vtm.html: quelldatein/darstellung_steuerung/vtm.html +erzeugnis/vtm.html: quelldatein/manifestation/vtm.html @ echo "-- Struktur …" @ mkdir -p erzeugnis - @ cp quelldatein/darstellung_steuerung/vtm.html erzeugnis/vtm.html + @ cp quelldatein/manifestation/vtm.html erzeugnis/vtm.html -erzeugnis/vtm.css: quelldatein/darstellung_steuerung/vtm.css quelldatein/darstellung_steuerung/welt.css +erzeugnis/vtm.css: quelldatein/manifestation/vtm.css quelldatein/manifestation/partie.css @ echo "-- Gestaltung …" @ mkdir -p erzeugnis - @ cat quelldatein/darstellung_steuerung/vtm.css quelldatein/darstellung_steuerung/welt.css > erzeugnis/vtm.css + @ cat quelldatein/manifestation/vtm.css quelldatein/manifestation/partie.css > erzeugnis/vtm.css + +erzeugnis/aufgaben.dat.js: quelldatein/daten/aufgaben.dat.js + @ echo "-- Daten …" + @ mkdir -p erzeugnis + @ cat quelldatein/daten/aufgaben.dat.js erzeugnis/daten.js erzeugnis/vtm.js: \ quelldatein/basis/typen.ts \ @@ -19,21 +24,32 @@ erzeugnis/vtm.js: \ quelldatein/helfer/vektor.ts \ quelldatein/helfer/hashmap.ts \ quelldatein/helfer/xmlknoten.ts \ + quelldatein/daten.ts \ quelldatein/aufbau/richtung.ts \ quelldatein/aufbau/symbol.ts \ quelldatein/aufbau/stelle.ts \ quelldatein/aufbau/zustand.ts \ quelldatein/aufbau/figur.ts \ quelldatein/aufbau/aktor.ts \ + quelldatein/aufbau/erzeuger.ts \ quelldatein/aufbau/befoerderer.ts \ quelldatein/aufbau/schreiber.ts \ quelldatein/aufbau/leser.ts \ quelldatein/aufbau/verwerfer.ts \ quelldatein/aufbau/annehmer.ts \ quelldatein/aufbau/welt.ts \ - quelldatein/darstellung_steuerung/position.ts \ - quelldatein/darstellung_steuerung/svg.ts \ - quelldatein/darstellung_steuerung/welt.ts \ + quelldatein/aufbau/test.ts \ + quelldatein/aufbau/akzeptortest.ts \ + quelldatein/aufbau/transduktortest.ts \ + quelldatein/aufbau/aufgabe.ts \ + quelldatein/aufbau/akzeptoraufgabe.ts \ + quelldatein/aufbau/transduktoraufgabe.ts \ + quelldatein/aufbau/aufgabe_.ts \ + quelldatein/aufbau/partie.ts \ + quelldatein/manifestation/manifestation.ts \ + quelldatein/manifestation/position.ts \ + quelldatein/manifestation/svg.ts \ + quelldatein/manifestation/partie.ts \ quelldatein/haupt.ts @ echo "-- Logik …" @ mkdir -p erzeugnis @@ -46,21 +62,32 @@ erzeugnis/vtm.js: \ quelldatein/helfer/vektor.ts \ quelldatein/helfer/hashmap.ts \ quelldatein/helfer/xmlknoten.ts \ + quelldatein/daten.ts \ quelldatein/aufbau/richtung.ts \ quelldatein/aufbau/symbol.ts \ quelldatein/aufbau/stelle.ts \ quelldatein/aufbau/zustand.ts \ quelldatein/aufbau/figur.ts \ quelldatein/aufbau/aktor.ts \ + quelldatein/aufbau/erzeuger.ts \ quelldatein/aufbau/befoerderer.ts \ quelldatein/aufbau/schreiber.ts \ quelldatein/aufbau/leser.ts \ quelldatein/aufbau/verwerfer.ts \ quelldatein/aufbau/annehmer.ts \ quelldatein/aufbau/welt.ts \ - quelldatein/darstellung_steuerung/position.ts \ - quelldatein/darstellung_steuerung/svg.ts \ - quelldatein/darstellung_steuerung/welt.ts \ + quelldatein/aufbau/test.ts \ + quelldatein/aufbau/akzeptortest.ts \ + quelldatein/aufbau/transduktortest.ts \ + quelldatein/aufbau/aufgabe.ts \ + quelldatein/aufbau/akzeptoraufgabe.ts \ + quelldatein/aufbau/transduktoraufgabe.ts \ + quelldatein/aufbau/aufgabe_.ts \ + quelldatein/aufbau/partie.ts \ + quelldatein/manifestation/manifestation.ts \ + quelldatein/manifestation/position.ts \ + quelldatein/manifestation/svg.ts \ + quelldatein/manifestation/partie.ts \ quelldatein/haupt.ts \ --outFile erzeugnis/vtm.js diff --git a/quelldatein/aufbau/aktor.ts b/quelldatein/aufbau/aktor.ts index cc01c4d..2ffde16 100644 --- a/quelldatein/aufbau/aktor.ts +++ b/quelldatein/aufbau/aktor.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/akzeptoraufgabe.ts b/quelldatein/aufbau/akzeptoraufgabe.ts new file mode 100644 index 0000000..6edb708 --- /dev/null +++ b/quelldatein/aufbau/akzeptoraufgabe.ts @@ -0,0 +1,90 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export class klasse_akzeptoraufgabe + implements schnittstelle_aufgabe + { + + /** + * @author kcf + */ + private titel_ : string; + + + /** + * @author kcf + */ + private text_ : string; + + + /** + * @author kcf + */ + private tests_ : Array; + + + /** + * @author kcf + */ + public constructor(titel : string, text : string, tests : Array) + { + this.titel_ = titel; + this.text_ = text; + this.tests_ = tests; + } + + + /** + * @author kcf + * @implementation + */ + public titel() : string + { + return this.titel_; + } + + + /** + * @author kcf + * @implementation + */ + public text() : string + { + return this.text_; + } + + + /** + * @author kcf + * @implementation + */ + public tests() : Array + { + return this.tests_; + } + + } + + } + diff --git a/quelldatein/aufbau/akzeptortest.ts b/quelldatein/aufbau/akzeptortest.ts new file mode 100644 index 0000000..5078ac5 --- /dev/null +++ b/quelldatein/aufbau/akzeptortest.ts @@ -0,0 +1,73 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export class klasse_akzeptortest + implements schnittstelle_test + { + + /** + * @author kcf + */ + private eingabe_ : Array; + + + /** + * @author kcf + */ + private annehmen : boolean; + + + /** + * @author kcf + */ + public constructor(eingabe : Array, annehmen : boolean) + { + this.eingabe_ = eingabe; + this.annehmen = annehmen; + } + + + /** + * @author kcf + * @implementation + */ + public eingabe() : Array + { + return this.eingabe_; + } + + + /** + * @author kcf + * @implementation + */ + public pruefen(angenommen : boolean, ausgabe : Array) : boolean + { + return (this.annehmen === angenommen); + } + + } + + } + diff --git a/quelldatein/aufbau/annehmer.ts b/quelldatein/aufbau/annehmer.ts index 13e50f1..94947de 100644 --- a/quelldatein/aufbau/annehmer.ts +++ b/quelldatein/aufbau/annehmer.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/aufgabe.ts b/quelldatein/aufbau/aufgabe.ts new file mode 100644 index 0000000..1f6d59b --- /dev/null +++ b/quelldatein/aufbau/aufgabe.ts @@ -0,0 +1,48 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export interface schnittstelle_aufgabe + { + + /** + * @author kcf + */ + titel() : string; + + + /** + * @author kcf + */ + text() : string; + + + /** + * @author kcf + */ + tests() : Array; + + } + + } + diff --git a/quelldatein/aufbau/aufgabe_.ts b/quelldatein/aufbau/aufgabe_.ts new file mode 100644 index 0000000..93ba475 --- /dev/null +++ b/quelldatein/aufbau/aufgabe_.ts @@ -0,0 +1,69 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export function aufgabe_erstellen(aufgabe_roh : any) : schnittstelle_aufgabe + { + switch (aufgabe_roh["art"]) + { + case "akzeptor": + { + return ( + new klasse_akzeptoraufgabe + ( + aufgabe_roh["parameter"]["titel"], + aufgabe_roh["parameter"]["text"], + aufgabe_roh["parameter"]["tests"].map + ( + test_roh => (new klasse_akzeptortest(test_roh["eingabe"], test_roh["annehmen"])) + ) + ) + ); + break; + } + case "transduktor": + { + return ( + new klasse_transduktoraufgabe + ( + aufgabe_roh["parameter"]["titel"], + aufgabe_roh["parameter"]["text"], + aufgabe_roh["parameter"]["tests"].map + ( + test_roh => (new klasse_transduktortest(test_roh["eingabe"], test_roh["ausgabe"])) + ) + ) + ); + break; + } + default: + { + let meldung : string = "unbehandelte Art"; + throw (new Error(meldung)); + break; + } + } + } + + } + diff --git a/quelldatein/aufbau/befoerderer.ts b/quelldatein/aufbau/befoerderer.ts index 7cee02d..5781185 100644 --- a/quelldatein/aufbau/befoerderer.ts +++ b/quelldatein/aufbau/befoerderer.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/erzeuger.ts b/quelldatein/aufbau/erzeuger.ts new file mode 100644 index 0000000..da4f095 --- /dev/null +++ b/quelldatein/aufbau/erzeuger.ts @@ -0,0 +1,76 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export class klasse_erzeuger + implements schnittstelle_aktor + { + + /** + * @author kcf + */ + private richtung : typ_richtung; + + + /** + * @author kcf + */ + public constructor(richtung : typ_richtung = 0) + { + this.richtung = richtung; + } + + + /** + * @author kcf + */ + public richtung_lesen() : typ_richtung + { + return this.richtung; + } + + + /** + * @author kcf + * @implementation + */ + public drehen() : void + { + this.richtung = richtung_addieren(this.richtung, +1); + } + + + /** + * @author kcf + * @implementation + */ + public verwenden(figur : klasse_figur) : void + { + figur.bewegen(this.richtung); + } + + } + + } + + diff --git a/quelldatein/aufbau/figur.ts b/quelldatein/aufbau/figur.ts index 4fc3cdc..7961acb 100644 --- a/quelldatein/aufbau/figur.ts +++ b/quelldatein/aufbau/figur.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { @@ -31,7 +48,7 @@ module mod_vtm_aufbau */ public constructor(band : Array = [], stelle : typ_stelle = stelle_null()) { - this.zustand = zustand_normal; + this.zustand = zustand_laufend; this.band = band; this.stelle = stelle; } @@ -121,7 +138,7 @@ module mod_vtm_aufbau */ public annehmen() : void { - this.zustand = zustand_fertig; + this.zustand = zustand_angenommen; } @@ -130,7 +147,7 @@ module mod_vtm_aufbau */ public verwerfen() : void { - this.zustand = zustand_tot; + this.zustand = zustand_abgelehnt; } } diff --git a/quelldatein/aufbau/leser.ts b/quelldatein/aufbau/leser.ts index 07609ce..e380bf9 100644 --- a/quelldatein/aufbau/leser.ts +++ b/quelldatein/aufbau/leser.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/partie.ts b/quelldatein/aufbau/partie.ts new file mode 100644 index 0000000..5ee64e2 --- /dev/null +++ b/quelldatein/aufbau/partie.ts @@ -0,0 +1,211 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export type typ_modus = int; + + + /** + * @author kcf + */ + export const modus_initial = 0; + export const modus_ungewiss = 1; + export const modus_fehlerhaft = 2; + export const modus_korrekt = 3; + + + /** + * @author kcf + */ + export class klasse_partie + { + + /** + * @author kcf + */ + private welt : klasse_welt; + + + /** + * @author kcf + */ + private figur : schnittstelle_fehlermonade; + + + /** + * @author kcf + */ + private aufgabe : schnittstelle_aufgabe; + + + /** + * @author kcf + */ + private testindex : schnittstelle_fehlermonade; + + + /** + * @author kcf + */ + private modus : typ_modus; + + + /** + * @author kcf + */ + public constructor + ( + aufgabe : schnittstelle_aufgabe, + welt : klasse_welt = klasse_welt.blanko(), + figur : schnittstelle_fehlermonade = new klasse_nichts() + ) + { + this.aufgabe = aufgabe; + this.welt = welt; + this.figur = figur; + this.testindex = (new klasse_nichts()); + this.modus = modus_initial; + } + + + /** + * @author kcf + */ + public welt_lesen() : klasse_welt + { + return this.welt; + } + + + /** + * @author kcf + */ + public figur_lesen() : schnittstelle_fehlermonade + { + return this.figur; + } + + + /** + * @author kcf + */ + public modus_lesen() : typ_modus + { + return this.modus; + } + + + /** + * @author kcf + */ + public fortfahren() : void + { + switch (this.modus) + { + case modus_initial: + { + this.modus = modus_ungewiss; + this.testindex = (new klasse_schlicht(0)); + break; + } + case modus_ungewiss: + { + if (! this.figur.ist_schlicht()) + { + let tests : Array = this.aufgabe.tests(); + let testindex : int = this.testindex.lesen(); + let test : schnittstelle_test = tests[testindex]; + let stelle : typ_stelle = this.welt.erzeuger_finden(); + this.figur = (new klasse_schlicht(new klasse_figur(test.eingabe(), stelle))); + } + else + { + let figur : klasse_figur = this.figur.lesen(); + let stelle : typ_stelle = figur.stelle_lesen(); + let aktor_ : schnittstelle_fehlermonade = this.welt.feld_holen(stelle); + let aktor : schnittstelle_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : (new klasse_verwerfer())); + aktor.verwenden(figur); + let zustand : typ_zustand = figur.zustand_lesen(); + if (zustand === zustand_laufend) + { + // nichts tun + } + else if ((zustand === zustand_angenommen) || (zustand === zustand_abgelehnt)) + { + let angenommen : boolean = (zustand === zustand_angenommen); + let ausgabe : Array = figur.band_lesen(); + this.figur = (new klasse_nichts()); + let tests : Array = this.aufgabe.tests(); + let testindex : int = this.testindex.lesen(); + let test : schnittstelle_test = tests[testindex]; + if (! test.pruefen(angenommen, ausgabe)) + { + this.modus = modus_fehlerhaft; + } + else + { + testindex += 1; + if (testindex >= tests.length) + { + // auf Modus "korrekt" wechseln + this.testindex = (new klasse_nichts()); + this.modus = modus_korrekt; + } + else + { + // nächsten Test auswählen + this.testindex = (new klasse_schlicht(testindex)); + } + } + } + else + { + let meldung : string = "unbehandelter Zustand"; + throw (new Error(meldung)); + } + } + break; + } + case modus_fehlerhaft: + { + // nichts tun + break; + } + case modus_korrekt: + { + // nichts tun + break; + } + default: + { + let meldung : string = "unbehandelter Modus"; + throw (new Error(meldung)); + break; + } + } + } + + } + + } + diff --git a/quelldatein/aufbau/richtung.ts b/quelldatein/aufbau/richtung.ts index 3c00a42..52ac83f 100644 --- a/quelldatein/aufbau/richtung.ts +++ b/quelldatein/aufbau/richtung.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/schreiber.ts b/quelldatein/aufbau/schreiber.ts index 4f51a7d..545ee8a 100644 --- a/quelldatein/aufbau/schreiber.ts +++ b/quelldatein/aufbau/schreiber.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/stelle.ts b/quelldatein/aufbau/stelle.ts index 5924247..3a62a27 100644 --- a/quelldatein/aufbau/stelle.ts +++ b/quelldatein/aufbau/stelle.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/symbol.ts b/quelldatein/aufbau/symbol.ts index badcc53..3e69243 100644 --- a/quelldatein/aufbau/symbol.ts +++ b/quelldatein/aufbau/symbol.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/test.ts b/quelldatein/aufbau/test.ts new file mode 100644 index 0000000..e9764fc --- /dev/null +++ b/quelldatein/aufbau/test.ts @@ -0,0 +1,43 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export interface schnittstelle_test + { + + /** + * @author kcf + * @implementation + */ + eingabe() : Array; + + + /** + * @author kcf + */ + pruefen(angenommen : boolean, ausgabe : Array) : boolean; + + } + + } + diff --git a/quelldatein/aufbau/transduktor.ts b/quelldatein/aufbau/transduktor.ts deleted file mode 100644 index 9b252f4..0000000 --- a/quelldatein/aufbau/transduktor.ts +++ /dev/null @@ -1,16 +0,0 @@ - -module mod_vtm_aufbau - { - - /** - * @author kcf - */ - export class klasse_transduktor - { - } - - - - - } - diff --git a/quelldatein/aufbau/transduktoraufgabe.ts b/quelldatein/aufbau/transduktoraufgabe.ts new file mode 100644 index 0000000..4819662 --- /dev/null +++ b/quelldatein/aufbau/transduktoraufgabe.ts @@ -0,0 +1,90 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export class klasse_transduktoraufgabe + implements schnittstelle_aufgabe + { + + /** + * @author kcf + */ + private titel_ : string; + + + /** + * @author kcf + */ + private text_ : string; + + + /** + * @author kcf + */ + private tests_ : Array; + + + /** + * @author kcf + */ + public constructor(titel : string, text : string, tests : Array) + { + this.titel_ = titel; + this.text_ = text; + this.tests_ = tests; + } + + + /** + * @author kcf + * @implementation + */ + public titel() : string + { + return this.titel_; + } + + + /** + * @author kcf + * @implementation + */ + public text() : string + { + return this.text_; + } + + + /** + * @author kcf + * @implementation + */ + public tests() : Array + { + return this.tests_; + } + + } + + } + diff --git a/quelldatein/aufbau/transduktortest.ts b/quelldatein/aufbau/transduktortest.ts new file mode 100644 index 0000000..10a1f4c --- /dev/null +++ b/quelldatein/aufbau/transduktortest.ts @@ -0,0 +1,74 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_aufbau + { + + /** + * @author kcf + */ + export class klasse_transduktortest + implements schnittstelle_test + { + + /** + * @author kcf + */ + private eingabe_ : Array; + + + /** + * @author kcf + */ + private ausgabe : Array; + + + /** + * @author kcf + */ + public constructor(eingabe : Array, ausgabe : Array) + { + this.eingabe_ = eingabe; + this.ausgabe = ausgabe; + } + + + /** + * @author kcf + * @implementation + */ + public eingabe() : Array + { + return this.eingabe_; + } + + + /** + * @author kcf + * @implementation + */ + public pruefen(angenommen : boolean, ausgabe : Array) : boolean + { + console.warn("not implemented"); + return false; + } + + } + + } + diff --git a/quelldatein/aufbau/verwerfer.ts b/quelldatein/aufbau/verwerfer.ts index 5d212e2..ae2cdde 100644 --- a/quelldatein/aufbau/verwerfer.ts +++ b/quelldatein/aufbau/verwerfer.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { diff --git a/quelldatein/aufbau/welt.ts b/quelldatein/aufbau/welt.ts index 3a9e632..8ac22c0 100644 --- a/quelldatein/aufbau/welt.ts +++ b/quelldatein/aufbau/welt.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { @@ -14,23 +31,15 @@ module mod_vtm_aufbau private felder : mod_vtm_helfer.klasse_hashmap; - /** - * @author kcf - */ - private figur : klasse_figur; - - /** * @author kcf */ public constructor ( - felder : mod_vtm_helfer.klasse_hashmap = new mod_vtm_helfer.klasse_hashmap(stelle_hash), - figur : klasse_figur = new klasse_figur() + felder : mod_vtm_helfer.klasse_hashmap = new mod_vtm_helfer.klasse_hashmap(stelle_hash) ) { this.felder = felder; - this.figur = figur; } @@ -52,9 +61,9 @@ module mod_vtm_aufbau /** * @author kcf */ - public figur_lesen() : klasse_figur + public feld_holen(stelle : typ_stelle) : schnittstelle_fehlermonade { - return this.figur; + return this.felder.holen(stelle); } @@ -72,6 +81,7 @@ module mod_vtm_aufbau */ public feld_wechseln(stelle : typ_stelle) : void { + let erweitert : boolean = true; let liste : Array<{pruefer : (aktor : schnittstelle_aktor)=>boolean; ersteller : ()=>schnittstelle_aktor;}> = ( [] .concat @@ -85,7 +95,7 @@ module mod_vtm_aufbau ) .concat ( - mod_vtm_helfer.sequenz(4).map + mod_vtm_helfer.sequenz(erweitert ? 4 : 2).map ( symbol => ( { @@ -109,7 +119,7 @@ module mod_vtm_aufbau ) .concat ( - mod_vtm_helfer.sequenz(2).map + mod_vtm_helfer.sequenz(erweitert ? 2 : 1).map ( index => { @@ -143,10 +153,6 @@ module mod_vtm_aufbau .concat ( [ - { - "pruefer": (aktor) => (aktor instanceof klasse_annehmer), - "ersteller": () => new klasse_annehmer(), - }, { "pruefer": (aktor) => (aktor instanceof klasse_verwerfer), "ersteller": () => new klasse_verwerfer(), @@ -178,11 +184,12 @@ module mod_vtm_aufbau if (! gefunden) { let meldung : string = ("Aktor nicht gefunden"); - throw (new Error(meldung)); + // throw (new Error(meldung)); + console.warn(meldung); } else { - // alles prima + // nichts tun } } else @@ -212,46 +219,42 @@ module mod_vtm_aufbau } } - + /** * @author kcf + * @throws {Error} */ - public fortfahren() : boolean + public erzeuger_finden() : typ_stelle { - let stelle : typ_stelle = this.figur.stelle_lesen(); - let aktor_ : schnittstelle_fehlermonade = this.felder.holen(stelle); - let aktor : schnittstelle_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : (new klasse_verwerfer())); - aktor.verwenden(this.figur); - let zustand : typ_zustand = this.figur.zustand_lesen(); - let ergebnis : boolean; - switch (zustand) + let stelle : schnittstelle_fehlermonade = (new klasse_nichts()); + this.felder.iterieren + ( + (stelle_, aktor) => + { + if (aktor instanceof klasse_erzeuger) + { + if (stelle.ist_schlicht()) + { + let meldung : string = "mehrere Erzeuger gefunden"; + throw (new Error(meldung)); + } + else + { + stelle = (new klasse_schlicht(stelle_)); + } + } + } + ) + ; + if (stelle.ist_schlicht()) { - case zustand_tot: - { - console.info("-- tot"); - ergebnis = false; - break; - } - case zustand_normal: - { - // console.info("-- normal"); - ergebnis = true; - break; - } - case zustand_fertig: - { - console.info("-- fertig"); - ergebnis = false; - break; - } - default: - { - let meldung : string = "unbehandelter Zustand"; - throw (new Error(meldung)); - break; - } + return stelle.lesen(); + } + else + { + let meldung : string = "kein Erzeuger gefunden"; + throw (new Error(meldung)); } - return ergebnis; } @@ -268,7 +271,20 @@ module mod_vtm_aufbau if (Math.abs(u-v) <= groesse) { let stelle : typ_stelle = {"u": u, "v": v}; - welt.felder.setzen(stelle, new klasse_verwerfer()); + let aktor : schnittstelle_aktor; + if ((u === -groesse) && (v === 0)) + { + aktor = (new klasse_erzeuger(0)); + } + else if ((u === +groesse) && (v === 0)) + { + aktor = (new klasse_annehmer()); + } + else + { + aktor = (new klasse_verwerfer()); + } + welt.felder.setzen(stelle, aktor); } } } @@ -278,4 +294,3 @@ module mod_vtm_aufbau } - diff --git a/quelldatein/aufbau/zustand.ts b/quelldatein/aufbau/zustand.ts index d82c1ef..af9fc13 100644 --- a/quelldatein/aufbau/zustand.ts +++ b/quelldatein/aufbau/zustand.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_aufbau { @@ -11,9 +28,9 @@ module mod_vtm_aufbau /** * @author kcf */ - export var zustand_tot = -1; - export var zustand_normal = 0; - export var zustand_fertig = +1; + export var zustand_abgelehnt = -1; + export var zustand_laufend = 0; + export var zustand_angenommen = +1; } diff --git a/quelldatein/basis/fehlermonade.ts b/quelldatein/basis/fehlermonade.ts index fc2454e..61bc029 100644 --- a/quelldatein/basis/fehlermonade.ts +++ b/quelldatein/basis/fehlermonade.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ /** * @author kcf diff --git a/quelldatein/basis/typen.ts b/quelldatein/basis/typen.ts index fb68235..9f570c4 100644 --- a/quelldatein/basis/typen.ts +++ b/quelldatein/basis/typen.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ /** * @author kcf diff --git a/quelldatein/darstellung_steuerung/position.ts b/quelldatein/darstellung_steuerung/position.ts deleted file mode 100644 index 201ab66..0000000 --- a/quelldatein/darstellung_steuerung/position.ts +++ /dev/null @@ -1,33 +0,0 @@ - -module mod_vtm_darstellung_steuerung - { - - /** - * @author kcf - */ - export type typ_position = mod_vtm_helfer.typ_vektor; - - - /** - * @author kcf - */ - var position_basis1 : typ_position = mod_vtm_helfer.vektor_polar(0/6.0 * (2*Math.PI)); - var position_basis2 : typ_position = mod_vtm_helfer.vektor_polar(2/6.0 * (2*Math.PI)); - - - /** - * @author kcf - */ - export function position_von_stelle(stelle : mod_vtm_aufbau.typ_stelle) : typ_position - { - return ( - mod_vtm_helfer.vektor_addieren - ( - mod_vtm_helfer.vektor_skalieren(position_basis1, stelle.u), - mod_vtm_helfer.vektor_skalieren(position_basis2, stelle.v) - ) - ); - } - - } - diff --git a/quelldatein/darstellung_steuerung/vtm.css b/quelldatein/darstellung_steuerung/vtm.css deleted file mode 100644 index c4d5385..0000000 --- a/quelldatein/darstellung_steuerung/vtm.css +++ /dev/null @@ -1,17 +0,0 @@ -html - { - margin: 0; - - background-color: hsl(0, 0%, 0%); - color: hsl(0, 0%, 100%); - } - -body - { - margin: 0; - padding: 0; - - background-color: hsl(0, 0%, 25%); - color: hsl(0, 0%, 75%); - } - diff --git a/quelldatein/darstellung_steuerung/vtm.html b/quelldatein/darstellung_steuerung/vtm.html deleted file mode 100644 index e5cbb66..0000000 --- a/quelldatein/darstellung_steuerung/vtm.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - -
-
-
- -
- - - diff --git a/quelldatein/daten.ts b/quelldatein/daten.ts new file mode 100644 index 0000000..72b7160 --- /dev/null +++ b/quelldatein/daten.ts @@ -0,0 +1,62 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_daten + { + + /** + * @author kcf + */ + var _speicher = {}; + + + /** + * @author kcf + */ + export function schreiben(schluessel : string, wert : any) : void + { + _speicher[schluessel] = wert; + } + + + /** + * @author kcf + */ + export function lesen(schluessel : string) : schnittstelle_fehlermonade + { + if (schluessel in _speicher) + { + return (new klasse_schlicht(_speicher[schluessel])); + } + else + { + return (new klasse_nichts()); + } + } + + } + + +/** + * @author kcf + */ +function jsonp_behandlung(objekt : {schluessel : string; wert : any;}) : void + { + mod_vtm_daten.schreiben(objekt.schluessel, objekt.wert); + } + diff --git a/quelldatein/daten/aufgaben.dat.js b/quelldatein/daten/aufgaben.dat.js new file mode 100644 index 0000000..89061bb --- /dev/null +++ b/quelldatein/daten/aufgaben.dat.js @@ -0,0 +1,109 @@ +jsonp_behandlung( + { + "schluessel": "aufgaben", + "wert": [ + { + "art": "akzeptor", + "parameter": { + "titel": "Einführung", + "text": "Bewege die Figur vom Eingang (links) zum Ausgang (rechts)!", + "tests": [ + { + "eingabe": [], + "annehmen": true + } + ] + } + }, + { + "art": "akzeptor", + "parameter": { + "titel": "Start-Symbol", + "text": "Annehmen, wenn die Eingabe mit ${s1} beginnt; andernfalls ablehnen", + "tests": [ + { + "eingabe": [], + "annehmen": false + }, + { + "eingabe": [0], + "annehmen": false + }, + { + "eingabe": [1], + "annehmen": true + }, + { + "eingabe": [0,1], + "annehmen": false + }, + { + "eingabe": [1,0,1,1,0,0,0,1,0], + "annehmen": true + } + ] + } + }, + { + "art": "akzeptor", + "parameter": { + "titel": "Dreifaltigkeit", + "text": "Annehmen genau dann, wenn die Eingabe mindestens drei ${s1} enthält", + "tests": [ + { + "eingabe": [1], + "annehmen": false + }, + { + "eingabe": [0,0,1,1], + "annehmen": false + }, + { + "eingabe": [1,0,1,0,0,1,0], + "annehmen": true + } + ] + } + }, + { + "art": "transduktor", + "parameter": { + "titel": "Ans Ende", + "text": "die Eingabe, aber mit dem ersten Symbol am Ende", + "tests": [ + { + "eingabe": [0,0,1,1,1,0,1,0,1,1,1,0,1], + "ausgabe": [0,1,1,1,0,1,0,1,1,1,0,1,0], + } + ] + } + }, + { + "art": "transduktor", + "parameter": { + "titel": "Filter", + "text": "aus der Eingabe alle ${s0} beibehalten und alle ${s1} entfernen", + "tests": [ + { + "eingabe": [0,0,0,1,0], + "ausgabe": [0,0,0,0], + }, + { + "eingabe": [1,0,1,0,1], + "ausgabe": [0,0,0], + }, + { + "eingabe": [1,1,1,1,0], + "ausgabe": [0], + }, + { + "eingabe": [0,1,1,0,0,1,0,1,1,1,0,1,0,0,1,1,1,1,1,1,0,1,0,1], + "ausgabe": [0,0,0,0,0,0,0,0,0], + } + ] + } + } + ] + } +); + diff --git a/quelldatein/daten/aufgaben.json b/quelldatein/daten/aufgaben.json deleted file mode 100644 index 1244db4..0000000 --- a/quelldatein/daten/aufgaben.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "blau_filter": [ - { - "titel": "Blau-Filter", - "text": "aus der Eingabe alle roten Einträge beibehalten und alle blauen entfernen", - "tests": [ - { - "eingabe": [0,0,0,1,0], - "ausgabe": [0,0,0,0], - }, - { - "eingabe": [1,0,1,0,1], - "ausgabe": [0,0,0], - }, - { - "eingabe": [1,1,1,1,0], - "ausgabe": [0], - }, - { - "eingabe": [0,1,1,0,0,1,0,1,1,1,0,1,0,0,1,1,1,1,1,1,0,1,0,1], - "ausgabe": [0,0,0,0,0,0,0,0,0], - }, - ] - } - ] -} - diff --git a/quelldatein/haupt.ts b/quelldatein/haupt.ts index 587cab8..bd5a25b 100644 --- a/quelldatein/haupt.ts +++ b/quelldatein/haupt.ts @@ -1,83 +1,142 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +/** + * @author kcf + */ +function aufgaben_laden(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe)=>void) : void + { + let aufgaben_roh_ : schnittstelle_fehlermonade> = mod_vtm_daten.lesen("aufgaben"); + if (aufgaben_roh_.ist_schlicht()) + { + let aufgaben_roh : Array = aufgaben_roh_.lesen(); + let dom_auswahl : Element = document.querySelector("#aufgabe_auswahl"); + aufgaben_roh.forEach + ( + (aufgabe_roh, index) => + { + let titel : string = aufgabe_roh["parameter"]["titel"]; + let dom_option : Element = document.createElement("option"); + dom_option.setAttribute("value", index.toFixed(0)); + dom_option.textContent = titel; + dom_auswahl.appendChild(dom_option); + } + ) + ; + dom_auswahl.addEventListener + ( + "change", + event => + { + let index : int = dom_auswahl["value"]; + let aufgabe_roh : any = aufgaben_roh[index]; + let aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe = mod_vtm_aufbau.aufgabe_erstellen(aufgabe_roh); + behandler(aufgabe); + } + ) + ; + } + else + { + console.warn("Daten nicht auffindbar"); + } + } + /** * @author kcf */ function haupt() : void { - let darstellung_aktualisieren = function (aufbau : mod_vtm_aufbau.klasse_welt, dom_zeichenflaeche : Element) : void + let aufbau : mod_vtm_aufbau.klasse_partie; + let manifestationen : Array; + let aktualisieren = function () : void { - let darstellung_steuerung : mod_vtm_darstellung_steuerung.klasse_web_welt = new mod_vtm_darstellung_steuerung.klasse_web_welt(aufbau); - let xmlknoten : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_darstellung_steuerung.svg_wurzel + manifestationen.forEach ( - -4, -4, - +4, +4, - 800, 800, - [darstellung_steuerung.darstellen()] - ) - ; - dom_zeichenflaeche.innerHTML = xmlknoten.darstellen(); + manifestation => + { + manifestation.darstellen(); + } + ); } ; - - let aufbau : mod_vtm_aufbau.klasse_welt = mod_vtm_aufbau.klasse_welt.blanko(); - let dom_zeichenflaeche : Element = document.querySelector("#zeichenflaeche") - // initiale Darstellung - darstellung_aktualisieren(aufbau, dom_zeichenflaeche); - // Steuerung - { - dom_zeichenflaeche.addEventListener - ( - "click", - event => - { - event.preventDefault(); - let dom_feld : Element = event.target["closest"](".feld"); - if (dom_feld == null) - { - console.info("-- kein Feld"); - } - else - { - let rel : string = dom_feld.getAttribute("rel") - let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); - aufbau.feld_wechseln(stelle); - darstellung_aktualisieren(aufbau, dom_zeichenflaeche); - } - } - ) - ; - dom_zeichenflaeche.addEventListener - ( - "contextmenu", - event => - { - event.preventDefault(); - let dom_feld : Element = event.target["closest"](".feld"); - if (dom_feld == null) - { - console.info("-- kein Feld"); - } - else - { - let rel : string = dom_feld.getAttribute("rel") - let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); - aufbau.feld_drehen(stelle); - darstellung_aktualisieren(aufbau, dom_zeichenflaeche); - } - } - ) - ; - document.querySelector("#knopf_fortfahren").addEventListener - ( - "click", - event => - { - aufbau.fortfahren(); - darstellung_aktualisieren(aufbau, dom_zeichenflaeche); - } - ) - ; - } + let intervall : any = null; + aufgaben_laden + ( + aufgabe => + { + document.querySelector("#aufgabe_text").textContent = aufgabe.text(); + aufbau = (new mod_vtm_aufbau.klasse_partie(aufgabe)); + manifestationen = ( + [ + new mod_vtm_manifestation.klasse_web_partie(aufbau, document.querySelector("#bereich_mitte")), + ] + ); + manifestationen.forEach + ( + manifestation => + { + manifestation.einrichten(); + } + ); + aktualisieren(); + } + ) + ; + document.querySelector("#knopf_testen").addEventListener + ( + "click", + event => + { + intervall = setInterval + ( + () => + { +// console.log("-- tick"); + aufbau.fortfahren(); + let modus : mod_vtm_aufbau.typ_modus = aufbau.modus_lesen(); + if (modus <= 1) + { + // nichts tun + } + else + { + clearInterval(intervall); intervall = null; + } + aktualisieren(); + } + , + 500 + ) + ; + } + ) + ; + document.querySelector("#knopf_anhalten").addEventListener + ( + "click", + event => + { + clearInterval(intervall); intervall = null; + } + ) + ; } diff --git a/quelldatein/helfer/hashmap.ts b/quelldatein/helfer/hashmap.ts index 466d2db..8e920bb 100644 --- a/quelldatein/helfer/hashmap.ts +++ b/quelldatein/helfer/hashmap.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_helfer { diff --git a/quelldatein/helfer/mathematik.ts b/quelldatein/helfer/mathematik.ts index 386169c..fb688bb 100644 --- a/quelldatein/helfer/mathematik.ts +++ b/quelldatein/helfer/mathematik.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_helfer { diff --git a/quelldatein/helfer/vektor.ts b/quelldatein/helfer/vektor.ts index 78ca338..4e24a8f 100644 --- a/quelldatein/helfer/vektor.ts +++ b/quelldatein/helfer/vektor.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_helfer { diff --git a/quelldatein/helfer/verschiedenes.ts b/quelldatein/helfer/verschiedenes.ts index 26d7e16..b617960 100644 --- a/quelldatein/helfer/verschiedenes.ts +++ b/quelldatein/helfer/verschiedenes.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_helfer { diff --git a/quelldatein/helfer/xmlknoten.ts b/quelldatein/helfer/xmlknoten.ts index 4987bb7..769fe4a 100644 --- a/quelldatein/helfer/xmlknoten.ts +++ b/quelldatein/helfer/xmlknoten.ts @@ -1,3 +1,20 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ module mod_vtm_helfer { diff --git a/quelldatein/manifestation/manifestation.ts b/quelldatein/manifestation/manifestation.ts new file mode 100644 index 0000000..6d88c01 --- /dev/null +++ b/quelldatein/manifestation/manifestation.ts @@ -0,0 +1,67 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_manifestation + { + + /** + * @author kcf + */ + export abstract class klasse_manifestation + { + + /** + * @author kcf + */ + protected aufbau : typ_aufbau; + + + /** + * @author kcf + */ + public constructor(aufbau : typ_aufbau) + { + this.aufbau = aufbau; + } + + + /** + * @author kcf + */ + public abstract darstellen() : void; + + + /** + * @author kcf + */ + public abstract binden() : void; + + + /** + * @author kcf + */ + public einrichten() : void + { + this.darstellen(); + this.binden(); + } + + } + + } + diff --git a/quelldatein/darstellung_steuerung/welt.css b/quelldatein/manifestation/partie.css similarity index 89% rename from quelldatein/darstellung_steuerung/welt.css rename to quelldatein/manifestation/partie.css index a562a3b..01faa51 100644 --- a/quelldatein/darstellung_steuerung/welt.css +++ b/quelldatein/manifestation/partie.css @@ -1,7 +1,7 @@ .rahmen { stroke: none; - fill: hsl( 0, 0%, 12.5%); + fill: hsl( 0, 0%, 25%); } .figur @@ -15,6 +15,11 @@ stroke: none; } +.erzeuger + { + fill: hsl( 0, 0%, 100%); + } + .neutral { fill: hsl( 0, 0%, 50%); diff --git a/quelldatein/darstellung_steuerung/welt.ts b/quelldatein/manifestation/partie.ts similarity index 54% rename from quelldatein/darstellung_steuerung/welt.ts rename to quelldatein/manifestation/partie.ts index 8697018..1c848dc 100644 --- a/quelldatein/darstellung_steuerung/welt.ts +++ b/quelldatein/manifestation/partie.ts @@ -1,32 +1,52 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ -module mod_vtm_darstellung_steuerung +module mod_vtm_manifestation { /** * @author kcf */ - export class klasse_web_welt + export class klasse_web_partie + extends klasse_manifestation { - + /** * @author kcf */ - protected aufbau : mod_vtm_aufbau.klasse_welt; + private bereich : Element; /** * @author kcf */ - public constructor(aufbau : mod_vtm_aufbau.klasse_welt) + public constructor(aufbau : mod_vtm_aufbau.klasse_partie, bereich : Element) { - this.aufbau = aufbau; + super(aufbau); + this.bereich = bereich; } /** * @author kcf + * @implementation */ - public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten + public darstellen() : void { let knoten_rahmen = function () : mod_vtm_helfer.schnittstelle_xmlknoten { @@ -46,12 +66,41 @@ module mod_vtm_darstellung_steuerung // felder { let kinder_felder : Array = []; - this.aufbau.felder_lesen().forEach + this.aufbau.welt_lesen().felder_lesen().forEach ( ({"stelle": stelle, "aktor": aktor}) => { let kinder_feld : Array = []; - if (aktor instanceof mod_vtm_aufbau.klasse_befoerderer) + if (aktor instanceof mod_vtm_aufbau.klasse_erzeuger) + { + kinder_feld.push(knoten_rahmen()); + let erzeuger : mod_vtm_aufbau.klasse_erzeuger = (aktor); + let richtung : mod_vtm_aufbau.typ_richtung = erzeuger.richtung_lesen(); + let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( + new mod_vtm_helfer.klasse_xmlknoten_normal + ( + "path", + { + "d": svg_form_pfeil, + "class": ( + [ + "pfeil", + "erzeuger", + ].join(" ") + ), + "transform": ( + [ + "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", + "translate(-0.2, 0)", + "scale(0.12)", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_pfeil); + } + else if (aktor instanceof mod_vtm_aufbau.klasse_befoerderer) { kinder_feld.push(knoten_rahmen()); let befoerderer : mod_vtm_aufbau.klasse_befoerderer = (aktor); @@ -72,7 +121,7 @@ module mod_vtm_darstellung_steuerung [ "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", "translate(-0.2, 0)", - "scale(0.15)", + "scale(0.12)", ].join(" ") ), } @@ -102,7 +151,7 @@ module mod_vtm_darstellung_steuerung [ "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", "translate(-0.2, 0)", - "scale(0.15)", + "scale(0.12)", ].join(" ") ), } @@ -251,90 +300,98 @@ module mod_vtm_darstellung_steuerung } // Figur { - let figur : mod_vtm_aufbau.klasse_figur = this.aufbau.figur_lesen(); - let kinder_figur : Array = []; - // Stein - { - let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "circle", - { - "cx": (0.0).toFixed(svg_float_praezission), - "cy": (0.0).toFixed(svg_float_praezission), - "r": (0.125).toFixed(svg_float_praezission), - "class": "stein", - } - ) - ); - kinder_figur.push(knoten_stein); - } - // Band - { - let band : Array = figur.band_lesen(); - let kinder_band : Array = []; - band.reduceRight - ( - (dummy, symbol, index) => - { - let r : float = 0.06125; - let x : float = (+0.1+(2*r*1.25)*index); - let y : float = (-0.1); - let knoten_eintrag : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "circle", - { - "cx": x.toFixed(svg_float_praezission), - "cy": y.toFixed(svg_float_praezission), - "r": r.toFixed(svg_float_praezission), - /* - "x": (x-r).toFixed(svg_float_praezission), - "y": (y-r).toFixed(svg_float_praezission), - "width": (2*r).toFixed(svg_float_praezission), - "height": (2*r).toFixed(svg_float_praezission), - */ - "class": ( - [ - "eintrag", - "symbol_" + symbol.toFixed(0), - ].join(" ") - ), - } - ) - ); - kinder_band.push(knoten_eintrag); - return null; - } - , - null - ) - ; - let knoten_band = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "g", - { - "class": "band", - }, - kinder_band - ) - ); - kinder_figur.push(knoten_band); - } - let position : typ_position = position_von_stelle(figur.stelle_lesen()); - let knoten_figur = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "g", - { - "class": "figur", - "transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"), - }, - kinder_figur - ) - ); - kinder_welt.push(knoten_figur); + let figur_ : schnittstelle_fehlermonade = this.aufbau.figur_lesen(); + if (figur_.ist_schlicht()) + { + let figur : mod_vtm_aufbau.klasse_figur = figur_.lesen(); + let kinder_figur : Array = []; + // Stein + { + let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = ( + new mod_vtm_helfer.klasse_xmlknoten_normal + ( + "circle", + { + "cx": (0.0).toFixed(svg_float_praezission), + "cy": (0.0).toFixed(svg_float_praezission), + "r": (0.125).toFixed(svg_float_praezission), + "class": "stein", + } + ) + ); + kinder_figur.push(knoten_stein); + } + // Band + { + let band : Array = figur.band_lesen(); + let kinder_band : Array = []; + band.reduceRight + ( + (dummy, symbol, index) => + { + let r : float = 0.06125; + let x : float = (+0.1+(2*r*1.25)*index); + let y : float = (-0.1); + let knoten_eintrag : mod_vtm_helfer.schnittstelle_xmlknoten = ( + new mod_vtm_helfer.klasse_xmlknoten_normal + ( + "circle", + { + "cx": x.toFixed(svg_float_praezission), + "cy": y.toFixed(svg_float_praezission), + "r": r.toFixed(svg_float_praezission), + /* + "x": (x-r).toFixed(svg_float_praezission), + "y": (y-r).toFixed(svg_float_praezission), + "width": (2*r).toFixed(svg_float_praezission), + "height": (2*r).toFixed(svg_float_praezission), + */ + "class": ( + [ + "eintrag", + "symbol_" + symbol.toFixed(0), + ].join(" ") + ), + } + ) + ); + kinder_band.push(knoten_eintrag); + return null; + } + , + null + ) + ; + let knoten_band = ( + new mod_vtm_helfer.klasse_xmlknoten_normal + ( + "g", + { + "class": "band", + }, + kinder_band + ) + ); + kinder_figur.push(knoten_band); + } + let position : typ_position = position_von_stelle(figur.stelle_lesen()); + let knoten_figur = ( + new mod_vtm_helfer.klasse_xmlknoten_normal + ( + "g", + { + "class": "figur", + "transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"), + }, + kinder_figur + ) + ); + kinder_welt.push(knoten_figur); + } + else + { + // nichts tun + } } let knoten_welt : mod_vtm_helfer.schnittstelle_xmlknoten = ( new mod_vtm_helfer.klasse_xmlknoten_normal @@ -346,7 +403,68 @@ module mod_vtm_darstellung_steuerung kinder_welt ) ); - return knoten_welt; + let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel + ( + -4, -4, + +4, +4, + 800, 800, + [knoten_welt] + ) + ; + this.bereich.innerHTML = knoten_svg.darstellen(); + } + + + /** + * @author kcf + * @implementation + */ + public binden() : void + { + // Links-Klick + this.bereich.addEventListener + ( + "click", + event => + { + event.preventDefault(); + let dom_feld : Element = event.target["closest"](".feld"); + if (dom_feld == null) + { + console.info("-- kein Feld"); + } + else + { + let rel : string = dom_feld.getAttribute("rel") + let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); + this.aufbau.welt_lesen().feld_wechseln(stelle); + this.darstellen(); + } + } + ) + ; + // Rechts-Klick + this.bereich.addEventListener + ( + "contextmenu", + event => + { + event.preventDefault(); + let dom_feld : Element = event.target["closest"](".feld"); + if (dom_feld == null) + { + console.info("-- kein Feld"); + } + else + { + let rel : string = dom_feld.getAttribute("rel") + let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); + this.aufbau.welt_lesen().feld_drehen(stelle); + this.darstellen(); + } + } + ) + ; } } diff --git a/quelldatein/manifestation/position.ts b/quelldatein/manifestation/position.ts new file mode 100644 index 0000000..cb4b3f0 --- /dev/null +++ b/quelldatein/manifestation/position.ts @@ -0,0 +1,50 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ + +module mod_vtm_manifestation + { + + /** + * @author kcf + */ + export type typ_position = mod_vtm_helfer.typ_vektor; + + + /** + * @author kcf + */ + var position_basis1 : typ_position = mod_vtm_helfer.vektor_polar(0/6.0 * (2*Math.PI)); + var position_basis2 : typ_position = mod_vtm_helfer.vektor_polar(2/6.0 * (2*Math.PI)); + + + /** + * @author kcf + */ + export function position_von_stelle(stelle : mod_vtm_aufbau.typ_stelle) : typ_position + { + return ( + mod_vtm_helfer.vektor_addieren + ( + mod_vtm_helfer.vektor_skalieren(position_basis1, stelle.u), + mod_vtm_helfer.vektor_skalieren(position_basis2, stelle.v) + ) + ); + } + + } + diff --git a/quelldatein/darstellung_steuerung/svg.ts b/quelldatein/manifestation/svg.ts similarity index 68% rename from quelldatein/darstellung_steuerung/svg.ts rename to quelldatein/manifestation/svg.ts index b33dea9..1895a56 100644 --- a/quelldatein/darstellung_steuerung/svg.ts +++ b/quelldatein/manifestation/svg.ts @@ -1,5 +1,22 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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 . + */ -module mod_vtm_darstellung_steuerung +module mod_vtm_manifestation { /** diff --git a/quelldatein/manifestation/vtm.css b/quelldatein/manifestation/vtm.css new file mode 100644 index 0000000..f406dfb --- /dev/null +++ b/quelldatein/manifestation/vtm.css @@ -0,0 +1,79 @@ +html + { + margin: 0; + height: 100%; + + background-color: hsl(120, 0%, 0%); + color: hsl(120, 0%, 100%); + + font-family: monospace; + } + +body + { + margin: 0; + padding: 0; + height: 100%; + + background-color: hsl(120, 0%, 6.125%); + color: hsl(120, 0%, 93.75%); + } + +a + { + color: hsl(120, 50%, 50%); + text-decoration: none; + } + +body > header + { + font-size: 200%; + margin: 8px; + } + +#inhalt + { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + } + +.bereich + { + margin: 8px; + padding: 8px; + + background-color: hsl(120, 0%, 12.5%); + color: hsl(120, 0%, 87.5%); + } + +#bereich_links + { + flex-basis: 19%; + flex-grow: 0; + flex-shrink: 1; + } + +#bereich_mitte + { + flex-basis: 62%; + flex-grow: 1; + flex-shrink: 1; + + min-width: 800px; + + text-align: center; + } + +#bereich_rechts + { + flex-basis: 19%; + flex-grow: 0; + flex-shrink: 1; + } + +#hilfe section > header + { + font-size: 150%; + } + diff --git a/quelldatein/manifestation/vtm.html b/quelldatein/manifestation/vtm.html new file mode 100644 index 0000000..4464112 --- /dev/null +++ b/quelldatein/manifestation/vtm.html @@ -0,0 +1,92 @@ + + + + + + + + + + +
Verrückte Turing-Maschinen
+
+ +
+
+
+
+ + + +
+
+
+
+
Erklärung
+

Dieses Spiel ist inspiriert von Manufacturia und Crazy Machines.

+
+
Steuerung
+
    +
  • Links-Klick: Feldtyp wechseln
  • +
  • Rechts-Klick: Feld drehen
  • +
+
+
+
Figur
+

Die Figur kann durch Aktoren auf dem Spielplan umher bewegt werden und wird als schwarzer Kreis dargestellt.

+

Zudem verfügt die Figur über ein Liste von gesetzen Symbolen (Band), dargestellt durch farbige Punkte neben der Figur. Gelesen wird das Band immer an der vordersten Stelle und geschrieben wird an die hinterste Stelle (FIFO-Prinzip).

+
+
+
Aktoren
+

Jedes Feld des Spielplans kann mit einem Aktor bestückt werden, der je nach Typ unterschiedliche Einflüsse auf die Figur ausübt. Folgende Typen stehen zur Verfügung:

+
    +
  • +
    Erzeuger
    +

    Der Erzeuger ist fest platziert auf dem ganz linken Feld des Spielplans. An ihm wird die Spielfigur auf den Plan gesetzt und bewegt sich anschließend in die angezeigte Richtung.

    +
  • +
  • +
    Ausgang
    +

    Ebenfalls fest platziert aber auf dem ganz rechten Feld des Spielplans wird der Ausgang. Steuert man die Figur zu diesem Feld, so wird der aktuelle Band-Inhalt ausgelesen und akzeptiert.

    +
  • +
  • +
    Verwerfer
    +

    Jedes leere Feld beendet den Lauf der Figur mit einer Abweisung des aktuellen Band-Inhalts.

    +
  • +
  • +
    Beförderer
    +

    Dieser Aktor dient dazu die Figur von einem Feld zu einem benachbarten zu befördern ohne dabei den Band-Inhalt zu ändern.

    +
  • +
  • +
    Schreiber
    +

    Um ein Symbol auf dem Band zu schreiben, wird dieser Aktor benötigt. Die jeweilige Farbe gibt an, welches Symbol geschrieben wird und die Richtung zeigt, wohin die Figur anschließend befördert wird.

    +
  • +
  • +
    Leser
    +

    Beim Leser wird das erste Symbol auf dem Band der Figur betrachtet und die übereinstimmende Richtung gewählt, zu welcher die Figur bewegt im Anschluss wird. Gibt es einen passenden Ausgang, so wird das gelesene Symbol vom Band entfernt. Falls kein Ausgang gefunden wird oder das Band leer ist, wird der Ersatz-Ausgang (grau) gewählt.

    +
  • +
+
+
+
Aufgaben
+

Ziel ist das Lösen von bestimmten Aufgaben. Dabei wird zwischen zwei Arten von Aufgaben unterschieden:

+
    +
  • +
    Akzeptor
    +

    Hierbei geht es darum den Band-Inhalt der Figur zu untersuchen und zu entscheiden, ob er eine bestimmte Bedingung erfüllt oder nicht. Fall ja, so steuert man die Figur in den Ausgang; andernfalls auf ein beliebiges leeres Feld.

    +

    Beispiel: Genau dann akzeptieren, wenn das Band mindestens zwei mal rot enthält.

    +
  • +
  • +
    Transduktor
    +

    Bei einer Transdukor-Aufgabe soll eine Ausgabe erzeugt werden, die in einer bestimmten Beziehung zur vorgefundenen Eingabe steht, also sozusagen eine Funktion angewendet werden.

    +

    Beispiel: Die Eingabe zwei mal wiederholt.

    +
  • +
+
+
+ + + diff --git a/quelldatein/test.ts b/quelldatein/test.ts deleted file mode 100644 index 9735a51..0000000 --- a/quelldatein/test.ts +++ /dev/null @@ -1,54 +0,0 @@ - -module mod_vtm_test - { - - /** - * @author kcf - */ - function haupt() : void - { - let aufbau : mod_vtm_aufbau.klasse_welt = new mod_vtm_aufbau.klasse_welt(); - aufbau.feld_setzen({"u": 0, "v": 0}, new mod_vtm_aufbau.klasse_befoerderer(0)); - aufbau.feld_setzen({"u": +1, "v": 0}, new mod_vtm_aufbau.klasse_schreiber(0, 1)); - aufbau.feld_setzen({"u": +2, "v": 0}, new mod_vtm_aufbau.klasse_leser(0)); - aufbau.feld_setzen({"u": +2, "v": -1}, new mod_vtm_aufbau.klasse_annehmer()); - { - let darstellung_steuerung : mod_vtm_darstellung_steuerung.klasse_web_welt = new mod_vtm_darstellung_steuerung.klasse_web_welt(aufbau); - let xmlknoten : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_darstellung_steuerung.svg_wurzel - ( - -4, -4, - +4, +4, - 800, 800, - [ - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "style", - {}, - [ - new mod_vtm_helfer.klasse_xmlknoten_text(".feld {stroke: none; fill: black;}\n"), - new mod_vtm_helfer.klasse_xmlknoten_text(".figur {stroke: none; fill: white;}\n"), - // new mod_vtm_helfer.klasse_xmlknoten_text(".pfeil {stroke: none; fill: gray;}\n"), - ] - ) - , - darstellung_steuerung.darstellen() - ] - ) - ; - console.info(xmlknoten.darstellen()); - } - /* - while (true) - { - let weiter : boolean = aufbau.fortfahren(); - if (! weiter) - break; - } - */ - } - - - haupt(); - - } - diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..2b4ba02 --- /dev/null +++ b/readme.md @@ -0,0 +1,10 @@ +# Verrückte Turing-Maschinen + +## Bauen + +Zum Bauen wird ein Typscript-Compiler benötigt, den man beispielweise über **npm** beziehen kann: `npm install typescript`. Dadurch sollte das Kommando `tsc` verfügbar sein. Hat man das, kann man anschließend `make` ausführen, wodurch der Ordner `erzeugnis` erstellt wird. + +## Starten + +Zum Starten/Testen einfach einen Webserver im Verzeichnis `erzeugnis` starten (zum Beispiel per `cd erzeugnis && python3 -m http.server 8888 ; cd -`) und im Browser aufrufen. +