sicherung

This commit is contained in:
Christian Fraß 2017-11-09 14:06:35 +01:00
parent cb28201e41
commit 13e34a6f42
46 changed files with 2030 additions and 404 deletions

View file

@ -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 .PHONY: alles
erzeugnis/vtm.html: quelldatein/darstellung_steuerung/vtm.html erzeugnis/vtm.html: quelldatein/manifestation/vtm.html
@ echo "-- Struktur …" @ echo "-- Struktur …"
@ mkdir -p erzeugnis @ 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 …" @ echo "-- Gestaltung …"
@ mkdir -p erzeugnis @ 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: \ erzeugnis/vtm.js: \
quelldatein/basis/typen.ts \ quelldatein/basis/typen.ts \
@ -19,21 +24,32 @@ erzeugnis/vtm.js: \
quelldatein/helfer/vektor.ts \ quelldatein/helfer/vektor.ts \
quelldatein/helfer/hashmap.ts \ quelldatein/helfer/hashmap.ts \
quelldatein/helfer/xmlknoten.ts \ quelldatein/helfer/xmlknoten.ts \
quelldatein/daten.ts \
quelldatein/aufbau/richtung.ts \ quelldatein/aufbau/richtung.ts \
quelldatein/aufbau/symbol.ts \ quelldatein/aufbau/symbol.ts \
quelldatein/aufbau/stelle.ts \ quelldatein/aufbau/stelle.ts \
quelldatein/aufbau/zustand.ts \ quelldatein/aufbau/zustand.ts \
quelldatein/aufbau/figur.ts \ quelldatein/aufbau/figur.ts \
quelldatein/aufbau/aktor.ts \ quelldatein/aufbau/aktor.ts \
quelldatein/aufbau/erzeuger.ts \
quelldatein/aufbau/befoerderer.ts \ quelldatein/aufbau/befoerderer.ts \
quelldatein/aufbau/schreiber.ts \ quelldatein/aufbau/schreiber.ts \
quelldatein/aufbau/leser.ts \ quelldatein/aufbau/leser.ts \
quelldatein/aufbau/verwerfer.ts \ quelldatein/aufbau/verwerfer.ts \
quelldatein/aufbau/annehmer.ts \ quelldatein/aufbau/annehmer.ts \
quelldatein/aufbau/welt.ts \ quelldatein/aufbau/welt.ts \
quelldatein/darstellung_steuerung/position.ts \ quelldatein/aufbau/test.ts \
quelldatein/darstellung_steuerung/svg.ts \ quelldatein/aufbau/akzeptortest.ts \
quelldatein/darstellung_steuerung/welt.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 quelldatein/haupt.ts
@ echo "-- Logik …" @ echo "-- Logik …"
@ mkdir -p erzeugnis @ mkdir -p erzeugnis
@ -46,21 +62,32 @@ erzeugnis/vtm.js: \
quelldatein/helfer/vektor.ts \ quelldatein/helfer/vektor.ts \
quelldatein/helfer/hashmap.ts \ quelldatein/helfer/hashmap.ts \
quelldatein/helfer/xmlknoten.ts \ quelldatein/helfer/xmlknoten.ts \
quelldatein/daten.ts \
quelldatein/aufbau/richtung.ts \ quelldatein/aufbau/richtung.ts \
quelldatein/aufbau/symbol.ts \ quelldatein/aufbau/symbol.ts \
quelldatein/aufbau/stelle.ts \ quelldatein/aufbau/stelle.ts \
quelldatein/aufbau/zustand.ts \ quelldatein/aufbau/zustand.ts \
quelldatein/aufbau/figur.ts \ quelldatein/aufbau/figur.ts \
quelldatein/aufbau/aktor.ts \ quelldatein/aufbau/aktor.ts \
quelldatein/aufbau/erzeuger.ts \
quelldatein/aufbau/befoerderer.ts \ quelldatein/aufbau/befoerderer.ts \
quelldatein/aufbau/schreiber.ts \ quelldatein/aufbau/schreiber.ts \
quelldatein/aufbau/leser.ts \ quelldatein/aufbau/leser.ts \
quelldatein/aufbau/verwerfer.ts \ quelldatein/aufbau/verwerfer.ts \
quelldatein/aufbau/annehmer.ts \ quelldatein/aufbau/annehmer.ts \
quelldatein/aufbau/welt.ts \ quelldatein/aufbau/welt.ts \
quelldatein/darstellung_steuerung/position.ts \ quelldatein/aufbau/test.ts \
quelldatein/darstellung_steuerung/svg.ts \ quelldatein/aufbau/akzeptortest.ts \
quelldatein/darstellung_steuerung/welt.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 \ quelldatein/haupt.ts \
--outFile erzeugnis/vtm.js --outFile erzeugnis/vtm.js

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -0,0 +1,90 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_akzeptoraufgabe
implements schnittstelle_aufgabe
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private titel_ : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private text_ : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private tests_ : Array<schnittstelle_test>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(titel : string, text : string, tests : Array<klasse_akzeptortest>)
{
this.titel_ = titel;
this.text_ = text;
this.tests_ = tests;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public titel() : string
{
return this.titel_;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public text() : string
{
return this.text_;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public tests() : Array<schnittstelle_test>
{
return this.tests_;
}
}
}

View file

@ -0,0 +1,73 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_akzeptortest
implements schnittstelle_test
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private eingabe_ : Array<typ_symbol>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private annehmen : boolean;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(eingabe : Array<typ_symbol>, annehmen : boolean)
{
this.eingabe_ = eingabe;
this.annehmen = annehmen;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public eingabe() : Array<typ_symbol>
{
return this.eingabe_;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public pruefen(angenommen : boolean, ausgabe : Array<typ_symbol>) : boolean
{
return (this.annehmen === angenommen);
}
}
}

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -0,0 +1,48 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export interface schnittstelle_aufgabe
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
titel() : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
text() : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
tests() : Array<schnittstelle_test>;
}
}

View file

@ -0,0 +1,69 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
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;
}
}
}
}

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -0,0 +1,76 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_erzeuger
implements schnittstelle_aktor
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private richtung : typ_richtung;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(richtung : typ_richtung = 0)
{
this.richtung = richtung;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
public richtung_lesen() : typ_richtung
{
return this.richtung;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public drehen() : void
{
this.richtung = richtung_addieren(this.richtung, +1);
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public verwenden(figur : klasse_figur) : void
{
figur.bewegen(this.richtung);
}
}
}

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {
@ -31,7 +48,7 @@ module mod_vtm_aufbau
*/ */
public constructor(band : Array<typ_symbol> = [], stelle : typ_stelle = stelle_null()) public constructor(band : Array<typ_symbol> = [], stelle : typ_stelle = stelle_null())
{ {
this.zustand = zustand_normal; this.zustand = zustand_laufend;
this.band = band; this.band = band;
this.stelle = stelle; this.stelle = stelle;
} }
@ -121,7 +138,7 @@ module mod_vtm_aufbau
*/ */
public annehmen() : void public annehmen() : void
{ {
this.zustand = zustand_fertig; this.zustand = zustand_angenommen;
} }
@ -130,7 +147,7 @@ module mod_vtm_aufbau
*/ */
public verwerfen() : void public verwerfen() : void
{ {
this.zustand = zustand_tot; this.zustand = zustand_abgelehnt;
} }
} }

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -0,0 +1,211 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_modus = int;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const modus_initial = 0;
export const modus_ungewiss = 1;
export const modus_fehlerhaft = 2;
export const modus_korrekt = 3;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_partie
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private welt : klasse_welt;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private figur : schnittstelle_fehlermonade<klasse_figur>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private aufgabe : schnittstelle_aufgabe;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private testindex : schnittstelle_fehlermonade<int>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private modus : typ_modus;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor
(
aufgabe : schnittstelle_aufgabe,
welt : klasse_welt = klasse_welt.blanko(),
figur : schnittstelle_fehlermonade<klasse_figur> = new klasse_nichts<klasse_figur>()
)
{
this.aufgabe = aufgabe;
this.welt = welt;
this.figur = figur;
this.testindex = (new klasse_nichts<int>());
this.modus = modus_initial;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
public welt_lesen() : klasse_welt
{
return this.welt;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
public figur_lesen() : schnittstelle_fehlermonade<klasse_figur>
{
return this.figur;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
public modus_lesen() : typ_modus
{
return this.modus;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
public fortfahren() : void
{
switch (this.modus)
{
case modus_initial:
{
this.modus = modus_ungewiss;
this.testindex = (new klasse_schlicht<int>(0));
break;
}
case modus_ungewiss:
{
if (! this.figur.ist_schlicht())
{
let tests : Array<schnittstelle_test> = 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<klasse_figur>(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<schnittstelle_aktor> = 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<typ_symbol> = figur.band_lesen();
this.figur = (new klasse_nichts<klasse_figur>());
let tests : Array<schnittstelle_test> = 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<int>());
this.modus = modus_korrekt;
}
else
{
// nächsten Test auswählen
this.testindex = (new klasse_schlicht<int>(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;
}
}
}
}
}

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -0,0 +1,43 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export interface schnittstelle_test
{
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
eingabe() : Array<typ_symbol>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
pruefen(angenommen : boolean, ausgabe : Array<typ_symbol>) : boolean;
}
}

View file

@ -1,16 +0,0 @@
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_transduktor
{
}
}

View file

@ -0,0 +1,90 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_transduktoraufgabe
implements schnittstelle_aufgabe
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private titel_ : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private text_ : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private tests_ : Array<schnittstelle_test>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(titel : string, text : string, tests : Array<klasse_transduktortest>)
{
this.titel_ = titel;
this.text_ = text;
this.tests_ = tests;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public titel() : string
{
return this.titel_;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public text() : string
{
return this.text_;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public tests() : Array<schnittstelle_test>
{
return this.tests_;
}
}
}

View file

@ -0,0 +1,74 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_transduktortest
implements schnittstelle_test
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private eingabe_ : Array<typ_symbol>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private ausgabe : Array<typ_symbol>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(eingabe : Array<typ_symbol>, ausgabe : Array<typ_symbol>)
{
this.eingabe_ = eingabe;
this.ausgabe = ausgabe;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public eingabe() : Array<typ_symbol>
{
return this.eingabe_;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public pruefen(angenommen : boolean, ausgabe : Array<typ_symbol>) : boolean
{
console.warn("not implemented");
return false;
}
}
}

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {
@ -14,23 +31,15 @@ module mod_vtm_aufbau
private felder : mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor>; private felder : mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private figur : klasse_figur;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public constructor public constructor
( (
felder : mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor> = new mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor>(stelle_hash), felder : mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor> = new mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor>(stelle_hash)
figur : klasse_figur = new klasse_figur()
) )
{ {
this.felder = felder; this.felder = felder;
this.figur = figur;
} }
@ -52,9 +61,9 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public figur_lesen() : klasse_figur public feld_holen(stelle : typ_stelle) : schnittstelle_fehlermonade<schnittstelle_aktor>
{ {
return this.figur; return this.felder.holen(stelle);
} }
@ -72,6 +81,7 @@ module mod_vtm_aufbau
*/ */
public feld_wechseln(stelle : typ_stelle) : void public feld_wechseln(stelle : typ_stelle) : void
{ {
let erweitert : boolean = true;
let liste : Array<{pruefer : (aktor : schnittstelle_aktor)=>boolean; ersteller : ()=>schnittstelle_aktor;}> = ( let liste : Array<{pruefer : (aktor : schnittstelle_aktor)=>boolean; ersteller : ()=>schnittstelle_aktor;}> = (
[] []
.concat .concat
@ -85,7 +95,7 @@ module mod_vtm_aufbau
) )
.concat .concat
( (
mod_vtm_helfer.sequenz(4).map mod_vtm_helfer.sequenz(erweitert ? 4 : 2).map
( (
symbol => ( symbol => (
{ {
@ -109,7 +119,7 @@ module mod_vtm_aufbau
) )
.concat .concat
( (
mod_vtm_helfer.sequenz(2).map mod_vtm_helfer.sequenz(erweitert ? 2 : 1).map
( (
index => index =>
{ {
@ -143,10 +153,6 @@ module mod_vtm_aufbau
.concat .concat
( (
[ [
{
"pruefer": (aktor) => (aktor instanceof klasse_annehmer),
"ersteller": () => new klasse_annehmer(),
},
{ {
"pruefer": (aktor) => (aktor instanceof klasse_verwerfer), "pruefer": (aktor) => (aktor instanceof klasse_verwerfer),
"ersteller": () => new klasse_verwerfer(), "ersteller": () => new klasse_verwerfer(),
@ -178,11 +184,12 @@ module mod_vtm_aufbau
if (! gefunden) if (! gefunden)
{ {
let meldung : string = ("Aktor nicht gefunden"); let meldung : string = ("Aktor nicht gefunden");
throw (new Error(meldung)); // throw (new Error(meldung));
console.warn(meldung);
} }
else else
{ {
// alles prima // nichts tun
} }
} }
else else
@ -212,46 +219,42 @@ module mod_vtm_aufbau
} }
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @throws {Error}
*/ */
public fortfahren() : boolean public erzeuger_finden() : typ_stelle
{ {
let stelle : typ_stelle = this.figur.stelle_lesen(); let stelle : schnittstelle_fehlermonade<typ_stelle> = (new klasse_nichts<typ_stelle>());
let aktor_ : schnittstelle_fehlermonade<schnittstelle_aktor> = this.felder.holen(stelle); this.felder.iterieren
let aktor : schnittstelle_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : (new klasse_verwerfer())); (
aktor.verwenden(this.figur); (stelle_, aktor) =>
let zustand : typ_zustand = this.figur.zustand_lesen(); {
let ergebnis : boolean; if (aktor instanceof klasse_erzeuger)
switch (zustand) {
if (stelle.ist_schlicht())
{
let meldung : string = "mehrere Erzeuger gefunden";
throw (new Error(meldung));
}
else
{
stelle = (new klasse_schlicht<typ_stelle>(stelle_));
}
}
}
)
;
if (stelle.ist_schlicht())
{ {
case zustand_tot: return stelle.lesen();
{ }
console.info("-- tot"); else
ergebnis = false; {
break; let meldung : string = "kein Erzeuger gefunden";
} throw (new Error(meldung));
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 ergebnis;
} }
@ -268,7 +271,20 @@ module mod_vtm_aufbau
if (Math.abs(u-v) <= groesse) if (Math.abs(u-v) <= groesse)
{ {
let stelle : typ_stelle = {"u": u, "v": v}; 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
} }

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_aufbau module mod_vtm_aufbau
{ {
@ -11,9 +28,9 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export var zustand_tot = -1; export var zustand_abgelehnt = -1;
export var zustand_normal = 0; export var zustand_laufend = 0;
export var zustand_fertig = +1; export var zustand_angenommen = +1;
} }

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>

View file

@ -1,33 +0,0 @@
module mod_vtm_darstellung_steuerung
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_position = mod_vtm_helfer.typ_vektor;
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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)
)
);
}
}

View file

@ -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%);
}

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="vtm.js"></script>
<script type="text/javascript">eingang_web();</script>
<link rel="stylesheet" type="text/css" href="vtm.css"/>
</head>
<body>
<div id="zeichenflaeche">
</div>
<div id="knoepfe">
<button id="knopf_fortfahren">Nächster Schritt</button>
</div>
</body>
</html>

62
quelldatein/daten.ts Normal file
View file

@ -0,0 +1,62 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_daten
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _speicher = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function schreiben(schluessel : string, wert : any) : void
{
_speicher[schluessel] = wert;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function lesen(schluessel : string) : schnittstelle_fehlermonade<any>
{
if (schluessel in _speicher)
{
return (new klasse_schlicht<any>(_speicher[schluessel]));
}
else
{
return (new klasse_nichts<any>());
}
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function jsonp_behandlung(objekt : {schluessel : string; wert : any;}) : void
{
mod_vtm_daten.schreiben(objekt.schluessel, objekt.wert);
}

View file

@ -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],
}
]
}
}
]
}
);

View file

@ -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],
},
]
}
]
}

View file

@ -1,83 +1,142 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
/**
* @author kcf <vidofnir@folksprak.org>
*/
function aufgaben_laden(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe)=>void) : void
{
let aufgaben_roh_ : schnittstelle_fehlermonade<Array<any>> = mod_vtm_daten.lesen("aufgaben");
if (aufgaben_roh_.ist_schlicht())
{
let aufgaben_roh : Array<any> = 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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function haupt() : void 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<any>;
let aktualisieren = function () : void
{ {
let darstellung_steuerung : mod_vtm_darstellung_steuerung.klasse_web_welt = new mod_vtm_darstellung_steuerung.klasse_web_welt(aufbau); manifestationen.forEach
let xmlknoten : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_darstellung_steuerung.svg_wurzel
( (
-4, -4, manifestation =>
+4, +4, {
800, 800, manifestation.darstellen();
[darstellung_steuerung.darstellen()] }
) );
;
dom_zeichenflaeche.innerHTML = xmlknoten.darstellen();
} }
; ;
let intervall : any = null;
let aufbau : mod_vtm_aufbau.klasse_welt = mod_vtm_aufbau.klasse_welt.blanko(); aufgaben_laden
let dom_zeichenflaeche : Element = document.querySelector("#zeichenflaeche") (
// initiale Darstellung aufgabe =>
darstellung_aktualisieren(aufbau, dom_zeichenflaeche); {
// Steuerung document.querySelector("#aufgabe_text").textContent = aufgabe.text();
{ aufbau = (new mod_vtm_aufbau.klasse_partie(aufgabe));
dom_zeichenflaeche.addEventListener manifestationen = (
( [
"click", new mod_vtm_manifestation.klasse_web_partie(aufbau, document.querySelector("#bereich_mitte")),
event => ]
{ );
event.preventDefault(); manifestationen.forEach
let dom_feld : Element = event.target["closest"](".feld"); (
if (dom_feld == null) manifestation =>
{ {
console.info("-- kein Feld"); manifestation.einrichten();
} }
else );
{ aktualisieren();
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); document.querySelector("#knopf_testen").addEventListener
} (
} "click",
) event =>
; {
dom_zeichenflaeche.addEventListener intervall = setInterval
( (
"contextmenu", () =>
event => {
{ // console.log("-- tick");
event.preventDefault(); aufbau.fortfahren();
let dom_feld : Element = event.target["closest"](".feld"); let modus : mod_vtm_aufbau.typ_modus = aufbau.modus_lesen();
if (dom_feld == null) if (modus <= 1)
{ {
console.info("-- kein Feld"); // nichts tun
} }
else else
{ {
let rel : string = dom_feld.getAttribute("rel") clearInterval(intervall); intervall = null;
let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); }
aufbau.feld_drehen(stelle); aktualisieren();
darstellung_aktualisieren(aufbau, dom_zeichenflaeche); }
} ,
} 500
) )
; ;
document.querySelector("#knopf_fortfahren").addEventListener }
( )
"click", ;
event => document.querySelector("#knopf_anhalten").addEventListener
{ (
aufbau.fortfahren(); "click",
darstellung_aktualisieren(aufbau, dom_zeichenflaeche); event =>
} {
) clearInterval(intervall); intervall = null;
; }
} )
;
} }

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_helfer module mod_vtm_helfer
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_helfer module mod_vtm_helfer
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_helfer module mod_vtm_helfer
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_helfer module mod_vtm_helfer
{ {

View file

@ -1,3 +1,20 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_helfer module mod_vtm_helfer
{ {

View file

@ -0,0 +1,67 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_manifestation
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export abstract class klasse_manifestation<typ_aufbau>
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
protected aufbau : typ_aufbau;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(aufbau : typ_aufbau)
{
this.aufbau = aufbau;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
public abstract darstellen() : void;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public abstract binden() : void;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public einrichten() : void
{
this.darstellen();
this.binden();
}
}
}

View file

@ -1,7 +1,7 @@
.rahmen .rahmen
{ {
stroke: none; stroke: none;
fill: hsl( 0, 0%, 12.5%); fill: hsl( 0, 0%, 25%);
} }
.figur .figur
@ -15,6 +15,11 @@
stroke: none; stroke: none;
} }
.erzeuger
{
fill: hsl( 0, 0%, 100%);
}
.neutral .neutral
{ {
fill: hsl( 0, 0%, 50%); fill: hsl( 0, 0%, 50%);

View file

@ -1,32 +1,52 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_darstellung_steuerung module mod_vtm_manifestation
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_web_welt export class klasse_web_partie
extends klasse_manifestation<mod_vtm_aufbau.klasse_partie>
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
protected aufbau : mod_vtm_aufbau.klasse_welt; private bereich : Element;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten public darstellen() : void
{ {
let knoten_rahmen = function () : mod_vtm_helfer.schnittstelle_xmlknoten let knoten_rahmen = function () : mod_vtm_helfer.schnittstelle_xmlknoten
{ {
@ -46,12 +66,41 @@ module mod_vtm_darstellung_steuerung
// felder // felder
{ {
let kinder_felder : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; let kinder_felder : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
this.aufbau.felder_lesen().forEach this.aufbau.welt_lesen().felder_lesen().forEach
( (
({"stelle": stelle, "aktor": aktor}) => ({"stelle": stelle, "aktor": aktor}) =>
{ {
let kinder_feld : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; let kinder_feld : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
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 = <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()); kinder_feld.push(knoten_rahmen());
let befoerderer : mod_vtm_aufbau.klasse_befoerderer = <mod_vtm_aufbau.klasse_befoerderer>(aktor); let befoerderer : mod_vtm_aufbau.klasse_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) + ")", "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")",
"translate(-0.2, 0)", "translate(-0.2, 0)",
"scale(0.15)", "scale(0.12)",
].join(" ") ].join(" ")
), ),
} }
@ -102,7 +151,7 @@ module mod_vtm_darstellung_steuerung
[ [
"rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")",
"translate(-0.2, 0)", "translate(-0.2, 0)",
"scale(0.15)", "scale(0.12)",
].join(" ") ].join(" ")
), ),
} }
@ -251,90 +300,98 @@ module mod_vtm_darstellung_steuerung
} }
// Figur // Figur
{ {
let figur : mod_vtm_aufbau.klasse_figur = this.aufbau.figur_lesen(); let figur_ : schnittstelle_fehlermonade<mod_vtm_aufbau.klasse_figur> = this.aufbau.figur_lesen();
let kinder_figur : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; if (figur_.ist_schlicht())
// Stein {
{ let figur : mod_vtm_aufbau.klasse_figur = figur_.lesen();
let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = ( let kinder_figur : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
new mod_vtm_helfer.klasse_xmlknoten_normal // Stein
( {
"circle", let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = (
{ new mod_vtm_helfer.klasse_xmlknoten_normal
"cx": (0.0).toFixed(svg_float_praezission), (
"cy": (0.0).toFixed(svg_float_praezission), "circle",
"r": (0.125).toFixed(svg_float_praezission), {
"class": "stein", "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 );
{ kinder_figur.push(knoten_stein);
let band : Array<mod_vtm_aufbau.typ_symbol> = figur.band_lesen(); }
let kinder_band : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; // Band
band.reduceRight {
( let band : Array<mod_vtm_aufbau.typ_symbol> = figur.band_lesen();
(dummy, symbol, index) => let kinder_band : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
{ band.reduceRight
let r : float = 0.06125; (
let x : float = (+0.1+(2*r*1.25)*index); (dummy, symbol, index) =>
let y : float = (-0.1); {
let knoten_eintrag : mod_vtm_helfer.schnittstelle_xmlknoten = ( let r : float = 0.06125;
new mod_vtm_helfer.klasse_xmlknoten_normal let x : float = (+0.1+(2*r*1.25)*index);
( let y : float = (-0.1);
"circle", let knoten_eintrag : mod_vtm_helfer.schnittstelle_xmlknoten = (
{ new mod_vtm_helfer.klasse_xmlknoten_normal
"cx": x.toFixed(svg_float_praezission), (
"cy": y.toFixed(svg_float_praezission), "circle",
"r": r.toFixed(svg_float_praezission), {
/* "cx": x.toFixed(svg_float_praezission),
"x": (x-r).toFixed(svg_float_praezission), "cy": y.toFixed(svg_float_praezission),
"y": (y-r).toFixed(svg_float_praezission), "r": r.toFixed(svg_float_praezission),
"width": (2*r).toFixed(svg_float_praezission), /*
"height": (2*r).toFixed(svg_float_praezission), "x": (x-r).toFixed(svg_float_praezission),
*/ "y": (y-r).toFixed(svg_float_praezission),
"class": ( "width": (2*r).toFixed(svg_float_praezission),
[ "height": (2*r).toFixed(svg_float_praezission),
"eintrag", */
"symbol_" + symbol.toFixed(0), "class": (
].join(" ") [
), "eintrag",
} "symbol_" + symbol.toFixed(0),
) ].join(" ")
); ),
kinder_band.push(knoten_eintrag); }
return null; )
} );
, kinder_band.push(knoten_eintrag);
null return null;
) }
; ,
let knoten_band = ( null
new mod_vtm_helfer.klasse_xmlknoten_normal )
( ;
"g", let knoten_band = (
{ new mod_vtm_helfer.klasse_xmlknoten_normal
"class": "band", (
}, "g",
kinder_band {
) "class": "band",
); },
kinder_figur.push(knoten_band); kinder_band
} )
let position : typ_position = position_von_stelle(figur.stelle_lesen()); );
let knoten_figur = ( kinder_figur.push(knoten_band);
new mod_vtm_helfer.klasse_xmlknoten_normal }
( let position : typ_position = position_von_stelle(figur.stelle_lesen());
"g", let knoten_figur = (
{ new mod_vtm_helfer.klasse_xmlknoten_normal
"class": "figur", (
"transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"), "g",
}, {
kinder_figur "class": "figur",
) "transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"),
); },
kinder_welt.push(knoten_figur); kinder_figur
)
);
kinder_welt.push(knoten_figur);
}
else
{
// nichts tun
}
} }
let knoten_welt : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_welt : mod_vtm_helfer.schnittstelle_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal new mod_vtm_helfer.klasse_xmlknoten_normal
@ -346,7 +403,68 @@ module mod_vtm_darstellung_steuerung
kinder_welt 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 <vidofnir@folksprak.org>
* @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();
}
}
)
;
} }
} }

View file

@ -0,0 +1,50 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_manifestation
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_position = mod_vtm_helfer.typ_vektor;
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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)
)
);
}
}

View file

@ -1,5 +1,22 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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/>.
*/
module mod_vtm_darstellung_steuerung module mod_vtm_manifestation
{ {
/** /**

View file

@ -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%;
}

View file

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="vtm.js"></script>
<script type="text/javascript" src="aufgaben.dat.js"></script>
<script type="text/javascript">eingang_web();</script>
<link rel="stylesheet" type="text/css" href="vtm.css"/>
</head>
<body>
<header>Verrückte Turing-Maschinen</header>
<div id="inhalt">
<div class="bereich" id="bereich_links">
<label for="aufgabe_auswahl">Aufgabe auswählen</label>
<select id="aufgabe_auswahl"></select>
<p id="aufgabe_text"></p>
</div>
<div class="bereich" id="bereich_mitte">
</div>
<div class="bereich" id="bereich_rechts">
<div id="knoepfe">
<button id="knopf_bearbeiten">Bearbeiten</button>
<button id="knopf_testen">Testen</button>
<button id="knopf_anhalten">Anhalten</button>
</div>
</div>
</div>
<div id="hilfe">
<header>Erklärung</header>
<p>Dieses Spiel ist inspiriert von <a href="http://www.kongregate.com/games/PleasingFungus/manufactoria">Manufacturia</a> und <a href="http://www.crazy-machines.com/">Crazy Machines</a>.</p>
<section>
<header>Steuerung</header>
<ul>
<li>Links-Klick: Feldtyp wechseln</li>
<li>Rechts-Klick: Feld drehen</li>
</ul>
</section>
<section>
<header>Figur</header>
<p>Die Figur kann durch Aktoren auf dem Spielplan umher bewegt werden und wird als schwarzer Kreis dargestellt.</p>
<p>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).</p>
</section>
<section>
<header>Aktoren</header>
<p>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:</p>
<ul>
<li>
<header>Erzeuger</header>
<p>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.</p>
</li>
<li>
<header>Ausgang</header>
<p>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.</p>
</li>
<li>
<header>Verwerfer</header>
<p>Jedes leere Feld beendet den Lauf der Figur mit einer Abweisung des aktuellen Band-Inhalts.</p>
</li>
<li>
<header>Beförderer</header>
<p>Dieser Aktor dient dazu die Figur von einem Feld zu einem benachbarten zu befördern ohne dabei den Band-Inhalt zu ändern.</p>
</li>
<li>
<header>Schreiber</header>
<p>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.</p>
</li>
<li>
<header>Leser</header>
<p>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.</p>
</li>
</ul>
</section>
<section>
<header>Aufgaben</header>
<p>Ziel ist das Lösen von bestimmten Aufgaben. Dabei wird zwischen zwei Arten von Aufgaben unterschieden:</p>
<ul>
<li>
<header>Akzeptor</header>
<p>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.</p>
<p>Beispiel: Genau dann akzeptieren, wenn das Band mindestens zwei mal rot enthält.</p>
</li>
<li>
<header>Transduktor</header>
<p>Bei einer Transdukor-Aufgabe soll eine Ausgabe erzeugt werden, die in einer bestimmten Beziehung zur vorgefundenen Eingabe steht, also sozusagen eine Funktion angewendet werden.</p>
<p>Beispiel: Die Eingabe zwei mal wiederholt.</p>
</li>
</ul>
</section>
</div>
</body>
</html>

View file

@ -1,54 +0,0 @@
module mod_vtm_test
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
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();
}

10
readme.md Normal file
View file

@ -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.