restructuring

This commit is contained in:
Christian Fraß 2018-03-29 01:13:39 +02:00
parent 3193117543
commit 95ff0c95b3
66 changed files with 1055 additions and 1031 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
erzeugnis
build/

BIN
documents/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

View file

@ -1,55 +0,0 @@
Dieses Spiel ist inspiriert von [http://www.kongregate.com/games/PleasingFungus/manufactoria"](Manufacturia), [http://www.crazy-machines.com/](Crazy Machines), [http://worldofgoo.com/](World of Goo) … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P
## Steuerung
- Links-Klick/Rechts-Klick: Feldtyp wechseln
- Mausrad-Drehen: 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:
### Eingang
Der Eingang ist fest platziert auf dem ganz linken Feld des Spielplans und wird durch ein weißes Dreieck dargestellt. An ihm wird die Spielfigur auf den Plan gesetzt und bewegt sich anschließend in die angezeigte Richtung.
### Ausgang
Auf dem ganz rechten Feld des Spielplans fest platziert befindet sich der Ausgang, der durch einen weißen Kreis dargestellt wird. Steuert man die Figur zu diesem Feld, so wird der aktuelle Band-Inhalt ausgelesen und akzeptiert.
### Abweiser
Jedes leere Feld beendet den Lauf der Figur mit einer Abweisung des aktuellen Band-Inhalts.
### Schieber
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.
### Weiche
An einer Weiche wird das erste Symbol auf dem Band der Figur gelesen und die übereinstimmende Richtung gewählt, zu welcher die Figur im Anschluss bewegt 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 Transduktor-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.

147
makefile
View file

@ -6,91 +6,92 @@ cmd_cat := cat
cmd_tsc := tsc --allowUnreachableCode
cmd_sass := sass
dir_quelldatein := quelldatein
dir_erzeugnis := erzeugnis
dir_source := source
dir_build := build
all: \
${dir_erzeugnis}/vtm.html \
${dir_erzeugnis}/vtm.css \
${dir_erzeugnis}/vtm.dat.js \
${dir_erzeugnis}/vtm.js
${dir_build}/vtm.html \
${dir_build}/vtm.css \
${dir_build}/vtm.dat.js \
${dir_build}/vtm.js
.PHONY: all
clear:
@ ${cmd_echo} "-- zurücksetzen …"
@ ${cmd_rm} ${dir_erzeugnis}
@ ${cmd_echo} "-- clearing …"
@ ${cmd_rm} ${dir_build}
.PHONY: clear
${dir_erzeugnis}/vtm.html: \
${dir_quelldatein}/manifestation/web/vtm.html
@ ${cmd_echo} "-- Struktur …"
@ ${cmd_md} ${dir_erzeugnis}
${dir_build}/vtm.html: \
${dir_source}/main.html
@ ${cmd_echo} "-- structure …"
@ ${cmd_md} ${dir_build}
@ ${cmd_cp} $^ $@
${dir_erzeugnis}/vtm.css: \
${dir_quelldatein}/manifestation/web/vtm.scss \
${dir_quelldatein}/manifestation/web/partie.scss
@ ${cmd_echo} "-- Gestaltung …"
@ ${cmd_md} ${dir_erzeugnis}
${dir_build}/vtm.css: \
${dir_source}/manifestation/web/game.scss \
${dir_source}/main.scss
@ ${cmd_echo} "-- style …"
@ ${cmd_md} ${dir_build}
@ ${cmd_cat} $^ | ${cmd_sass} --stdin > $@
${dir_erzeugnis}/vtm.dat.js: \
${dir_quelldatein}/daten/aufgaben.dat.js \
${dir_quelldatein}/daten/zeichenketten/de.dat.js \
${dir_quelldatein}/daten/zeichenketten/en.dat.js
@ ${cmd_echo} "-- Daten …"
@ ${cmd_md} ${dir_erzeugnis}
${dir_build}/vtm.dat.js: \
${dir_source}/data/strings/de.dat.js \
${dir_source}/data/strings/en.dat.js \
${dir_source}/data/tasks.dat.js
@ ${cmd_echo} "-- data …"
@ ${cmd_md} ${dir_build}
@ ${cmd_cat} $^ > $@
${dir_erzeugnis}/vtm.js: \
${dir_quelldatein}/helfer/typen.ts \
${dir_quelldatein}/helfer/aufruf.ts \
${dir_quelldatein}/helfer/brauch.ts \
${dir_quelldatein}/helfer/fehlermonade.ts \
${dir_quelldatein}/helfer/xml.ts \
${dir_quelldatein}/helfer/verschiedenes.ts \
${dir_quelldatein}/helfer/mathematik.ts \
${dir_quelldatein}/helfer/vektor.ts \
${dir_quelldatein}/helfer/hashmap.ts \
${dir_quelldatein}/helfer/uebersetzung.ts \
${dir_quelldatein}/daten.ts \
${dir_quelldatein}/aufbau/richtung.ts \
${dir_quelldatein}/aufbau/symbol.ts \
${dir_quelldatein}/aufbau/stelle.ts \
${dir_quelldatein}/aufbau/zustand.ts \
${dir_quelldatein}/aufbau/figur.ts \
${dir_quelldatein}/aufbau/aktoren/_aktor.ts \
${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \
${dir_quelldatein}/aufbau/aktoren/annehmer.ts \
${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \
${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \
${dir_quelldatein}/aufbau/aktoren/schreiber.ts \
${dir_quelldatein}/aufbau/aktoren/leser.ts \
${dir_quelldatein}/aufbau/welt.ts \
${dir_quelldatein}/aufbau/aufgaben/test.ts \
${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \
${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \
${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \
${dir_quelldatein}/aufbau/aufgaben/transduktoraufgabe.ts \
${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \
${dir_quelldatein}/aufbau/modus.ts \
${dir_quelldatein}/aufbau/partie.ts \
${dir_quelldatein}/manifestation/manifestation.ts \
${dir_quelldatein}/manifestation/position.ts \
${dir_quelldatein}/manifestation/svg/_svg.ts \
${dir_quelldatein}/manifestation/svg/figur.ts \
${dir_quelldatein}/manifestation/svg/aktor/_aktor.ts \
${dir_quelldatein}/manifestation/svg/aktor/verwerfer.ts \
${dir_quelldatein}/manifestation/svg/aktor/annehmer.ts \
${dir_quelldatein}/manifestation/svg/aktor/erzeuger.ts \
${dir_quelldatein}/manifestation/svg/aktor/befoerderer.ts \
${dir_quelldatein}/manifestation/svg/aktor/schreiber.ts \
${dir_quelldatein}/manifestation/svg/aktor/leser.ts \
${dir_quelldatein}/manifestation/svg/partie.ts \
${dir_quelldatein}/manifestation/web/partie.ts \
${dir_quelldatein}/manifestation/speicher/partie.ts \
${dir_quelldatein}/haupt.ts
@ ${cmd_echo} "-- Logik …"
@ ${cmd_md} ${dir_erzeugnis}
${dir_build}/vtm.js: \
${dir_source}/helpers/types.ts \
${dir_source}/helpers/call.ts \
${dir_source}/helpers/trait.ts \
${dir_source}/helpers/errormonade.ts \
${dir_source}/helpers/string.ts \
${dir_source}/helpers/xml.ts \
${dir_source}/helpers/misc.ts \
${dir_source}/helpers/math.ts \
${dir_source}/helpers/vector.ts \
${dir_source}/helpers/hashmap.ts \
${dir_source}/helpers/translate.ts \
${dir_source}/helpers/svg.ts \
${dir_source}/data/_data.ts \
${dir_source}/model/direction.ts \
${dir_source}/model/symbol.ts \
${dir_source}/model/spot.ts \
${dir_source}/model/state.ts \
${dir_source}/model/token.ts \
${dir_source}/model/actuators/_actuator.ts \
${dir_source}/model/actuators/rejector.ts \
${dir_source}/model/actuators/acceptor.ts \
${dir_source}/model/actuators/generator.ts \
${dir_source}/model/actuators/conveyer.ts \
${dir_source}/model/actuators/writer.ts \
${dir_source}/model/actuators/reader.ts \
${dir_source}/model/world.ts \
${dir_source}/model/tasks/acceptortest.ts \
${dir_source}/model/tasks/transducertest.ts \
${dir_source}/model/tasks/test.ts \
${dir_source}/model/tasks/acceptortask.ts \
${dir_source}/model/tasks/transducertask.ts \
${dir_source}/model/tasks/task.ts \
${dir_source}/model/mode.ts \
${dir_source}/model/game.ts \
${dir_source}/manifestation/manifestation.ts \
${dir_source}/manifestation/position.ts \
${dir_source}/manifestation/svg/token.ts \
${dir_source}/manifestation/svg/actuators/_actuator.ts \
${dir_source}/manifestation/svg/actuators/rejector.ts \
${dir_source}/manifestation/svg/actuators/acceptor.ts \
${dir_source}/manifestation/svg/actuators/generator.ts \
${dir_source}/manifestation/svg/actuators/conveyer.ts \
${dir_source}/manifestation/svg/actuators/writer.ts \
${dir_source}/manifestation/svg/actuators/reader.ts \
${dir_source}/manifestation/svg/game.ts \
${dir_source}/manifestation/web/game.ts \
${dir_source}/manifestation/store/game.ts \
${dir_source}/main.ts
@ ${cmd_echo} "-- logic …"
@ ${cmd_md} ${dir_build}
@ ${cmd_tsc} $^ --outFile $@

View file

@ -1,55 +0,0 @@
jsonp_handle(
{
"key": "strings-de",
"value": {
"common.title": "Verrückte Turing-Maschinen",
"common.help": "Hilfe",
"common.game": "Spiel",
"model.token.terms.singular": "Figur",
"model.token.terms.plural": "Figuren",
"model.modes.initial": "Maschine bearbeiten",
"model.modes.uncertain": "wird geprüft …",
"model.modes.wrong": "fehlerhaft :/",
"model.modes.correct": "anscheinend korrekt :)",
"model.actuators.terms.singular": "Aktor",
"model.actuators.terms.plural": "Aktoren",
"model.actuators.kinds.erzeuger.name": "Eingang",
"model.actuators.kinds.annehmer.name": "Ausgang",
"model.actuators.kinds.verwerfer.name": "Abweiser",
"model.actuators.kinds.befoerderer.name": "Schieber",
"model.actuators.kinds.schreiber.name": "Schreiber",
"model.actuators.kinds.leser.name": "Weiche",
"model.tasks.terms.singular": "Aufgabe",
"model.tasks.terms.plural": "tasks",
"model.tasks.kinds.acceptor.name": "Akzeptor",
"model.tasks.kinds.acceptor.shortcut": "AKZ",
"model.tasks.kinds.transductor.name": "Transduktor",
"model.tasks.kinds.transductor.shortcut": "TRA",
"controls.choose": "Aufgabe auswählen",
"controls.step": "Nächster Schritt",
"controls.run": "Ablaufen",
"controls.stop": "Anhalten",
"controls.edit": "Bearbeiten",
"controls.clear": "Leeren",
"help.introduction": "Dieses Spiel ist inspiriert von !var:manufacturia, !var:crazy_machines, !var:world_of_goo … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P",
"help.controls.title": "Steuerung",
"help.controls.eintrag1": "Links-Klick/Rechts-Klick: Feldtyp wechseln",
"help.controls.eintrag2": "Mausrad-Drehen: Feld drehen",
"help.token.satz1": "Die Figur kann durch Aktoren auf dem Spielplan umher bewegt werden und wird als schwarzer Kreis dargestellt.",
"help.token.satz2": "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).",
"help.actuators.introduction": "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:",
"help.actuators.erzeuger": "Der Eingang ist fest platziert auf dem ganz linken Feld des Spielplans und wird durch ein weißes Dreieck dargestellt. An ihm wird die Spieltoken auf den Plan gesetzt und bewegt sich anschließend in die angezeigte Richtung.",
"help.actuators.annehmer": "Auf dem ganz rechten Feld des Spielplans fest platziert befindet sich der Ausgang, der durch einen weißen Kreis dargestellt wird. Steuert man die Figur zu diesem Feld, so wird der aktuelle Band-Inhalt ausgelesen und akzeptiert.",
"help.actuators.verwerfer": "Jedes leere Feld beendet den Lauf der Figur mit einer Abweisung des aktuellen Band-Inhalts.",
"help.actuators.befoerderer": "Dieser Aktor dient dazu die Figur von einem Feld zu einem benachbkinds zu befördern ohne dabei den Band-Inhalt zu ändern.",
"help.actuators.schreiber": "Um ein Symbol auf das 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.",
"help.actuators.leser": "An einer Weiche wird das erste Symbol auf dem Band der Figur gelesen und die übereinstimmende Richtung gewählt, zu welcher die Figur im Anschluss bewegt 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.",
"help.tasks.introduction": "Ziel ist das Lösen von bestimmten Aufgaben. Dabei wird zwischen zwei Arten von tasks unterschieden:",
"help.tasks.acceptor.description": "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.",
"help.tasks.acceptor.example": "Beispiel: Genau dann akzeptieren, wenn das Band mindestens zwei mal rot enthält.",
"help.tasks.transductor.description": "Bei einer Transduktor-Aufgabe soll eine Ausgabe erzeugt werden, die in einer bestimmten Beziehung zur vorgefundenen Eingabe steht, also sozusagen eine Funktion angewendet werden.",
"help.tasks.transductor.example": "Beispiel: Die Eingabe zwei mal wiederholt."
}
}
);

View file

@ -1,55 +0,0 @@
jsonp_handle(
{
"key": "strings-en",
"value": {
"common.title": "Crazy Turing Machines",
"common.help": "Help",
"common.game": "Game",
"model.token.terms.singular": "token",
"model.token.terms.plural": "tokens",
"model.modes.initial": "edit machine",
"model.modes.uncertain": "testing …",
"model.modes.wrong": "flawed :/",
"model.modes.correct": "seemingly correct :)",
"model.actuators.terms.singular": "actor",
"model.actuators.terms.plural": "actors",
"model.actuators.kinds.erzeuger.name": "entrance",
"model.actuators.kinds.annehmer.name": "exit",
"model.actuators.kinds.verwerfer.name": "dropper",
"model.actuators.kinds.befoerderer.name": "conveyer",
"model.actuators.kinds.schreiber.name": "writer",
"model.actuators.kinds.leser.name": "switch",
"model.tasks.terms.singular": "task",
"model.tasks.terms.plural": "tasks",
"model.tasks.kinds.acceptor.name": "acceptor",
"model.tasks.kinds.acceptor.shortcut": "ACC",
"model.tasks.kinds.transductor.name": "transductor",
"model.tasks.kinds.transductor.shortcut": "TRA",
"controls.choose": "choose task",
"controls.step": "next step",
"controls.run": "run",
"controls.stop": "stop",
"controls.edit": "edit",
"controls.clear": "clear",
"help.introduction": "This game is inspired by !var:manufacturia, !var:crazy_machines, !var:world_of_goo … and also by memorable hours of the practical hardware course during computer science study :P",
"help.controls.title": "controls",
"help.controls.eintrag1": "left click/right click: change tile type",
"help.controls.eintrag2": "rotate mousewheel: rotate tile",
"help.token.satz1": "The token can be moved around the board by actors and it is displayed as a black circle.",
"help.token.satz2": "Additionally the token has a list of set symbols (its tape), which is shown as coloured points next to the token. The tape is always read at the front and written at its back (FIFO principle).",
"help.actuators.introduction": "Every tile on the board can be equipped with an actor, which will cause a certain effect on the token depending on the type. The following types are available:",
"help.actuators.erzeuger": "The entrance is statically placed on the most left tile of the board and is displayed as a white triangle. It is the spot at which the token is inserted into the board and moved to the indicated direction afterwards.",
"help.actuators.annehmer": "On the most right tile of the board the exit is statically placed; it is displayed as a white circle. If the token is moved to this tile, its tape content will be read and accepted.",
"help.actuators.verwerfer": "Every empty tile will cancel the tokens run with a rejection of the current tape content.",
"help.actuators.befoerderer": "This actor is used for moving the token to neighbour tile without changing the tape content.",
"help.actuators.schreiber": "In order to write a symbol to the tape, this actor is utilized. The colour indicates which symbol will be written and the direction shows to which tile the token will be moved afterwards.",
"help.actuators.leser": "At a switch the first symbol of the tape will be read and the the token will be moved the the corresponding direction. If a matching way out exists, the symbol will be removed from the tape. If no way out matches or if the tape is empty the fallback exit (grey) will be chosen.",
"help.tasks.introduction": "The goal is to solve certain tasks. Two kind of tasks are distinguished:",
"help.tasks.acceptor.description": "Here the goal is to investigate the content of the tokens tape and to decide whether it fulfils a certain condition or not. IF so, the token shall be moved to the exit; otherwise to an arbitrary empty tile.",
"help.tasks.acceptor.example": "Example: Accept then and only then, if the tape contains at least two red symbols.",
"help.tasks.transductor.description": "In a transductor task an output shall be generated, which has a certain relationship to to the input; in other words: to apply a function.",
"help.tasks.transductor.example": "Example: The input repeated two times."
}
}
);

View file

@ -1,163 +0,0 @@
/*
* 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
{
export module mod_manifestation
{
export module mod_svg
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const float_precision : int = 4;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow : string = "M +4 0 L 0 +1 L 0 -1 Z";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function rotation
(
staerke : float
)
: string
{
return (
"rotate"
+ "("
+ (staerke * 360).toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function translation
(
x : float,
y : float
)
: string
{
return (
"translate"
+ "("
+ x.toFixed(float_precision)
+ ", "
+ y.toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function skalierung
(
staerke : float
)
: string
{
return (
"scale"
+ "("
+ staerke.toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function path
(
vertices : Array<lib_vector.type_vector>,
close : boolean = true,
attributes : {[schlussel : string] : string} = {},
)
: lib_xml.type_node
{
let d : string = "";
vertices.forEach
(
(vertex, index) =>
{
let c : string = ((index <= 0) ? "M" : "L");
let x : string = vertex.x.toFixed(float_precision);
let y : string = vertex.y.toFixed(float_precision);
d += [c, x, y].join(" ");
}
)
;
if (close)
d += "Z";
attributes["d"] = d;
return (lib_xml.create_normal("path", attributes));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function root
(
von_x : float,
von_y : float,
bis_x : float,
bis_y : float,
hoehe : int = 500,
breite : int = 500,
children : Array<lib_xml.type_node> = []
)
: lib_xml.type_node
{
return (
lib_xml.create_normal
(
"svg",
{
"xmlns": "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"width": breite.toFixed(0),
"height": hoehe.toFixed(0),
"viewBox": [von_x.toFixed(4), von_y.toFixed(4), (bis_x-von_x).toFixed(4), (bis_y-von_y).toFixed(4)].join(" "),
},
children,
)
);
}
}
}
}

View file

@ -1,10 +1,19 @@
# Verrückte Turing-Maschinen
Dieses Spiel ist inspiriert von [http://www.kongregate.com/games/PleasingFungus/manufactoria"](Manufacturia), [http://www.crazy-machines.com/](Crazy Machines), [http://worldofgoo.com/](World of Goo) … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P
## 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.
Zum Bauen wird ein Typscript- und ein SASS-Compiler benötigt, die man beispielweise über **npm** beziehen kann: `npm install typescript && npm install sass`. Dadurch sollten die Kommandos `tsc` und `sass` verfügbar sein. Hat man das, kann man anschließend `make` ausführen, wodurch der Ordner `build` 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.
Zum Starten/Testen einfach einen Webserver im Verzeichnis `build` starten (zum Beispiel per `cd build && python3 -m http.server 8888 ; cd -`) und im Browser `http://localhost:8888/vtm.html` aufrufen.
## Anmerkungen
Das Programm folgt konsequent den Paradigmen der prozeduralen und funktionalen Programmierung und ist nach der Grundidee des Architektur-Musters [https://de.wikipedia.org/wiki/Model_View_Controller](MVC) aufgebaut.

View file

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

View file

@ -0,0 +1,78 @@
jsonp_handle(
{
"key": "strings-de",
"value": {
"common.title": "Verrückte Turing-Maschinen",
"common.help": "Hilfe",
"common.game": "Spiel",
"model.token.terms.singular": "Figur",
"model.token.terms.plural": "Figuren",
"model.modes.initial": "Maschine bearbeiten",
"model.modes.uncertain": "wird geprüft …",
"model.modes.wrong": "fehlerhaft :/",
"model.modes.correct": "anscheinend korrekt :)",
"model.actuators.terms.singular": "Aktor",
"model.actuators.terms.plural": "Aktoren",
"model.actuators.kinds.generator.name": "Eingang",
"model.actuators.kinds.acceptor.name": "Ausgang",
"model.actuators.kinds.rejector.name": "Abweiser",
"model.actuators.kinds.conveyer.name": "Schieber",
"model.actuators.kinds.writer.name": "Schreiber",
"model.actuators.kinds.reader.name": "Weiche",
"model.tasks.terms.singular": "Aufgabe",
"model.tasks.terms.plural": "Aufgaben",
"model.tasks.kinds.acceptor.name": "Akzeptor",
"model.tasks.kinds.acceptor.shortcut": "AKZ",
"model.tasks.kinds.transducer.name": "Transduktor",
"model.tasks.kinds.transducer.shortcut": "TRA",
"controls.choose": "Aufgabe auswählen",
"controls.step": "Nächster Schritt",
"controls.run": "Ablaufen",
"controls.stop": "Anhalten",
"controls.edit": "Bearbeiten",
"controls.clear": "Leeren",
"help.introduction": "Dieses Spiel ist inspiriert von !var:manufacturia, !var:crazy_machines, !var:world_of_goo … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P",
"help.controls.title": "Steuerung",
"help.controls.eintrag1": "Links-Klick/Rechts-Klick: Feldtyp wechseln",
"help.controls.eintrag2": "Mausrad-Drehen: Feld drehen",
"help.token.satz1": "Die Figur kann durch Aktoren auf dem Spielplan umher bewegt werden und wird als schwarzer Kreis dargestellt.",
"help.token.satz2": "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).",
"help.actuators.introduction": "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:",
"help.actuators.generator": "Der Eingang ist fest platziert auf dem ganz linken Feld des Spielplans und wird durch ein weißes Dreieck dargestellt. An ihm wird die Spieltoken auf den Plan gesetzt und bewegt sich anschließend in die angezeigte Richtung.",
"help.actuators.acceptor": "Auf dem ganz rechten Feld des Spielplans fest platziert befindet sich der Ausgang, der durch einen weißen Kreis dargestellt wird. Steuert man die Figur zu diesem Feld, so wird der aktuelle Band-Inhalt ausgelesen und akzeptiert.",
"help.actuators.rejector": "Jedes leere Feld beendet den Lauf der Figur mit einer Abweisung des aktuellen Band-Inhalts.",
"help.actuators.conveyer": "Dieser Aktor dient dazu die Figur von einem Feld zu einem benachbkinds zu befördern ohne dabei den Band-Inhalt zu ändern.",
"help.actuators.writer": "Um ein Symbol auf das 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.",
"help.actuators.reader": "An einer Weiche wird das erste Symbol auf dem Band der Figur gelesen und die übereinstimmende Richtung gewählt, zu welcher die Figur im Anschluss bewegt 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.",
"help.tasks.introduction": "Ziel ist das Lösen von bestimmten Aufgaben. Dabei wird zwischen zwei Arten von Aufgaben unterschieden:",
"help.tasks.acceptor.description": "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.",
"help.tasks.acceptor.example": "Beispiel: Genau dann akzeptieren, wenn das Band mindestens zwei mal rot enthält.",
"help.tasks.transducer.description": "Bei einer Transduktor-Aufgabe soll eine Ausgabe erzeugt werden, die in einer bestimmten Beziehung zur vorgefundenen Eingabe steht, also sozusagen eine Funktion angewendet werden.",
"help.tasks.transducer.example": "Beispiel: Die Eingabe zwei mal wiederholt.",
"tasks.einfuehrung.title": "Einf\u00fchrung",
"tasks.einfuehrung.text": "Bewege die Figur vom Eingang (links) zum Ausgang (rechts)!",
"tasks.start_symbol.title": "Start-Symbol",
"tasks.start_symbol.text": "Annehmen, wenn die Eingabe mit ${s1} beginnt; andernfalls ablehnen",
"tasks.dreifaltigkeit.title": "Dreifaltigkeit",
"tasks.dreifaltigkeit.text": "Annehmen genau dann, wenn die Eingabe mindestens drei ${s1} enth\u00e4lt",
"tasks.abwechslung_erfreuet.title": "Abwechslung erfreuet",
"tasks.abwechslung_erfreuet.text": "annehmen genau dann wenn: Die Farben der Eingabe (${s0} / ${s1}) sich immer abwechseln",
"tasks.ans_ende.title": "Ans Ende",
"tasks.ans_ende.text": "die Eingabe (${s0} / ${s1}), aber mit dem ersten Symbol am Ende",
"tasks.tauschen.title": "Tauschen",
"tasks.tauschen.text": "aus der Eingabe (${s0} / ${s1}) alle ${s0} durch ${s2} ersetzen und alle ${s1} durch ${s3}",
"tasks.waehlerisch.title": "W\u00e4hlerisch",
"tasks.waehlerisch.text": "aus der Eingabe alle ${s0} entfernen und alle ${s1} beibehalten",
"tasks.dekorator.title": "Dekorator",
"tasks.dekorator.text": "Alles wird h\u00fcbscher mit Schn\u00f6rkeln, Schleifchen und Kinkerlitzchen aller Art! Zumindest glauben das die Leute \u2026 Shopping-Sender im Fernsehen sind der Beweis! Ob das auch f\u00fcr das Band der Figur gilt, wenn es nur ${s0} und ${s1} enth\u00e4lt? Finden wir's raus: Setz ein ${s2} an den Anfang und ein ${s3} an das Ende!",
"tasks.alpha_und_omega.title": "Alpha und Omega",
"tasks.alpha_und_omega.text": "Eingaben (${s0} / ${s1}), die mit den gleichen Symbolen anfangen und enden",
"tasks.an_den_anfang.title": "An den Anfang",
"tasks.an_den_anfang.text": "die Eingabe (${s0} / ${s1}), aber mit dem letzten Symbol am Anfang",
"tasks.a_n_b_n.title": "a^n b^n",
"tasks.a_n_b_n.text": "Jaja, die ber\u00fchmt ber\u00fcchtige Sprache, die sich mit einem endlichen Automaten nicht erkennen l\u00e4sst \u2026 Das ist deine Chance zu zeigen, dass dieses Ding hier mehr ist als so ein k\u00fcmmerlicher DEA \u2026 und das ganz ohne Kellerspeicher! Also: Eine beliebige Anzahl an ${s0}, dann die gleiche Anzahl an ${s1}!",
"tasks.a_n_b_n.hinweise.hinweis1": "Ein Wort ist genau dann Element der Sprache ${s0}^n ${s1}^n, wenn sie entweder 1) leer ist (also n = 0 gilt) oder 2) sie mit ${s0} beginnt, mit ${s1} endet und dazwischen ein Wort der Form ${s0}^(n-1) ${s1}^(n-1) steht \u2026 Stichwort: Rekursion"
}
}
);

View file

@ -0,0 +1,59 @@
jsonp_handle(
{
"key": "strings-en",
"value": {
"common.title": "Crazy Turing Machines",
"common.help": "Help",
"common.game": "Game",
"model.token.terms.singular": "token",
"model.token.terms.plural": "tokens",
"model.modes.initial": "edit machine",
"model.modes.uncertain": "testing …",
"model.modes.wrong": "flawed :/",
"model.modes.correct": "seemingly correct :)",
"model.actuators.terms.singular": "actor",
"model.actuators.terms.plural": "actors",
"model.actuators.kinds.generator.name": "entrance",
"model.actuators.kinds.acceptor.name": "exit",
"model.actuators.kinds.rejector.name": "dropper",
"model.actuators.kinds.conveyer.name": "conveyer",
"model.actuators.kinds.writer.name": "writer",
"model.actuators.kinds.reader.name": "switch",
"model.tasks.terms.singular": "task",
"model.tasks.terms.plural": "tasks",
"model.tasks.kinds.acceptor.name": "acceptor",
"model.tasks.kinds.acceptor.shortcut": "ACC",
"model.tasks.kinds.transducer.name": "transducer",
"model.tasks.kinds.transducer.shortcut": "TRA",
"controls.choose": "choose task",
"controls.step": "next step",
"controls.run": "run",
"controls.stop": "stop",
"controls.edit": "edit",
"controls.clear": "clear",
"help.introduction": "This game is inspired by !var:manufacturia, !var:crazy_machines, !var:world_of_goo … and also by memorable hours of the practical hardware course during computer science study :P",
"help.controls.title": "controls",
"help.controls.eintrag1": "left click/right click: change tile type",
"help.controls.eintrag2": "rotate mousewheel: rotate tile",
"help.token.satz1": "The token can be moved agame the board by actors and it is displayed as a black circle.",
"help.token.satz2": "Additionally the token has a list of set symbols (its tape), which is shown as coloured points next to the token. The tape is always read at the front and written at its back (FIFO principle).",
"help.actuators.introduction": "Every tile on the board can be equipped with an actor, which will cause a certain effect on the token depending on the type. The following types are available:",
"help.actuators.generator": "The entrance is statically placed on the most left tile of the board and is displayed as a white triangle. It is the spot at which the token is inserted into the board and moved to the indicated direction afterwards.",
"help.actuators.acceptor": "On the most right tile of the board the exit is statically placed; it is displayed as a white circle. If the token is moved to this tile, its tape content will be read and accepted.",
"help.actuators.rejector": "Every empty tile will cancel the tokens run with a rejection of the current tape content.",
"help.actuators.conveyer": "This actor is used for moving the token to neighbour tile without changing the tape content.",
"help.actuators.writer": "In order to write a symbol to the tape, this actor is utilized. The colour indicates which symbol will be written and the direction shows to which tile the token will be moved afterwards.",
"help.actuators.reader": "At a switch the first symbol of the tape will be read and the the token will be moved the the corresponding direction. If a matching way out exists, the symbol will be removed from the tape. If no way out matches or if the tape is empty the fallback exit (grey) will be chosen.",
"help.tasks.introduction": "The goal is to solve certain tasks. Two kind of tasks are distinguished:",
"help.tasks.acceptor.description": "Here the goal is to investigate the content of the tokens tape and to decide whether it fulfils a certain condition or not. IF so, the token shall be moved to the exit; otherwise to an arbitrary empty tile.",
"help.tasks.acceptor.example": "Example: Accept then and only then, if the tape contains at least two red symbols.",
"help.tasks.transducer.description": "In a transducer task an output shall be generated, which has a certain relationship to to the input; in other words: to apply a function.",
"help.tasks.transducer.example": "Example: The input repeated two times.",
"tasks.einfuehrung.title": "Introduction",
"tasks.einfuehrung.text": "Move the token from the entrance (left) to the exit (rights)!",
"tasks.a_n_b_n.title": "a^n b^n",
"tasks.a_n_b_n.text": "Yeah, yeah, yeah … The far famed language, which can't be recognized by a finite automaton … This is your chance to prove that this gizmo here is mightier than any wimpy DFA; even without any stack! So: An arbitrary number of ${s0}, then the same number of ${s1}!"
}
}
);

View file

@ -6,8 +6,6 @@ jsonp_handle(
"id": "einfuehrung",
"kind": "acceptor",
"parameter": {
"titel": "Einführung",
"text": "Bewege die Figur vom Eingang (links) zum Ausgang (rechts)!",
"tests": [
{
"input": [],
@ -20,8 +18,6 @@ jsonp_handle(
"id": "start_symbol",
"kind": "acceptor",
"parameter": {
"titel": "Start-Symbol",
"text": "Annehmen, wenn die input mit ${s1} beginnt; andernfalls ablehnen",
"tests": [
{
"input": [],
@ -50,8 +46,6 @@ jsonp_handle(
"id": "dreifaltigkeit",
"kind": "acceptor",
"parameter": {
"titel": "Dreifaltigkeit",
"text": "Annehmen genau dann, wenn die input mindestens drei ${s1} enthält",
"tests": [
{
"input": [1],
@ -72,8 +66,6 @@ jsonp_handle(
"id": "abwechslung_erfreuet",
"kind": "acceptor",
"parameter": {
"titel": "Abwechslung erfreuet",
"text": "annehmen genau dann wenn: Die Farben der input (${s0} / ${s1}) sich immer abwechseln",
"tests": [
{
"input": [],
@ -100,10 +92,8 @@ jsonp_handle(
},
{
"id": "ans_ende",
"kind": "transductor",
"kind": "transducer",
"parameter": {
"titel": "Ans Ende",
"text": "die input (${s0} / ${s1}), aber mit dem ersten Symbol am Ende",
"tests": [
{
"input": [0,0,1,1,1,0,1,0,1,1,1,0,1],
@ -114,10 +104,8 @@ jsonp_handle(
},
{
"id": "tauschen",
"kind": "transductor",
"kind": "transducer",
"parameter": {
"titel": "Tauschen",
"text": "aus der input (${s0} / ${s1}) alle ${s0} durch ${s2} ersetzen und alle ${s1} durch ${s3}",
"tests": [
{
"input": [0,1,1,0],
@ -132,10 +120,8 @@ jsonp_handle(
},
{
"id": "waehlerisch",
"kind": "transductor",
"kind": "transducer",
"parameter": {
"titel": "Wählerisch",
"text": "aus der input alle ${s0} entfernen und alle ${s1} beibehalten",
"tests": [
{
"input": [0,0,0,1,0],
@ -158,10 +144,8 @@ jsonp_handle(
},
{
"id": "dekorator",
"kind": "transductor",
"kind": "transducer",
"parameter": {
"titel": "Dekorator",
"text": "Alles wird hübscher mit Schnörkeln, Schleifchen und Kinkerlitzchen aller Art! Zumindest glauben das die Leute … Shopping-Sender im Fernsehen sind der Beweis! Ob das auch für das Band der Figur gilt, wenn es nur ${s0} und ${s1} enthält? Finden wir's raus: Setz ein ${s2} an den Anfang und ein ${s3} an das Ende!",
"tests": [
{
"input": [1,1,0],
@ -178,8 +162,6 @@ jsonp_handle(
"id": "alpha_und_omega",
"kind": "acceptor",
"parameter": {
"titel": "Alpha und Omega",
"text": "inputn (${s0} / ${s1}), die mit den gleichen Symbolen anfangen und enden",
"tests": [
{
"input": [],
@ -210,10 +192,8 @@ jsonp_handle(
},
{
"id": "an_den_anfang",
"kind": "transductor",
"kind": "transducer",
"parameter": {
"titel": "An den Anfang",
"text": "die input (${s0} / ${s1}), aber mit dem letzten Symbol am Anfang",
"tests": [
{
"input": [0,0,1,1,1,0,1,0,1,1,1,0,1],
@ -226,8 +206,6 @@ jsonp_handle(
"id": "a_n_b_n",
"kind": "acceptor",
"parameter": {
"titel": "a^n b^n",
"text": "Jaja, die berühmt berüchtige Sprache, die sich mit einem endlichen Automaten nicht erkennen lässt … Das ist deine Chance zu zeigen, dass dieses Ding hier mehr ist als so ein kümmerlicher DEA … und das ganz ohne Kellerspeicher! Also: Eine beliebige Anzahl an ${s0}, dann die gleiche Anzahl an ${s1}!",
"tests": [
{
"input": [],
@ -249,9 +227,6 @@ jsonp_handle(
"input": [0,0,0,0,0,0,0,1,1,1,1,1,1,1],
"accept": true
}
],
"hinweise": [
"Ein Wort ist genau dann Element der Sprache ${s0}^n ${s1}^n, wenn sie entweder 1) leer ist (also n = 0 gilt) oder 2) sie mit ${s0} beginnt, mit ${s1} endet und dazwischen ein Wort der Form ${s0}^(n-1) ${s1}^(n-1) steht … Stichwort: Rekursion"
]
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

54
source/helpers/string.ts Normal file
View file

@ -0,0 +1,54 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 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 lib_string
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function indent
(
depth : int,
symbol : string = "\t"
)
: string
{
return (
(depth === 0)
? ""
: (symbol + indent(depth-1))
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function stance(str : string, vars : {[name : string] : string}) : string
{
for (let name in vars)
{
let regexp : RegExp = (new RegExp("\\$\{" + name + "\}", "g"));
str = str.replace(regexp, vars[name]);
}
return str;
}
}

153
source/helpers/svg.ts Normal file
View file

@ -0,0 +1,153 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 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 lib_svg
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const float_precision : int = 4;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow : string = "M +4 0 L 0 +1 L 0 -1 Z";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function rotation
(
staerke : float
)
: string
{
return (
"rotate"
+ "("
+ (staerke * 360).toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function translation
(
x : float,
y : float
)
: string
{
return (
"translate"
+ "("
+ x.toFixed(float_precision)
+ ", "
+ y.toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function skalierung
(
staerke : float
)
: string
{
return (
"scale"
+ "("
+ staerke.toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function path
(
vertices : Array<lib_vector.type_vector>,
close : boolean = true,
attributes : {[name : string] : string} = {},
)
: lib_xml.type_node
{
let d : string = "";
vertices.forEach
(
(vertex, index) =>
{
let c : string = ((index <= 0) ? "M" : "L");
let x : string = vertex.x.toFixed(float_precision);
let y : string = vertex.y.toFixed(float_precision);
d += [c, x, y].join(" ");
}
)
;
if (close)
d += "Z";
attributes["d"] = d;
return (lib_xml.create_normal("path", attributes));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function root
(
from_x : float,
from_y : float,
to_x : float,
to_y : float,
height : int = 500,
width : int = 500,
children : Array<lib_xml.type_node> = []
)
: lib_xml.type_node
{
return (
lib_xml.create_normal
(
"svg",
{
"xmlns": "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"width": width.toFixed(0),
"height": height.toFixed(0),
"viewBox": [from_x.toFixed(4), from_y.toFixed(4), (to_x-from_x).toFixed(4), (to_y-from_y).toFixed(4)].join(" "),
},
children,
)
);
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -19,24 +19,6 @@
module lib_xml
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function indent
(
depth : int,
zeichen : string = "\t"
)
: string
{
return (
(depth === 0)
? ""
: (zeichen + indent(depth-1))
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
@ -130,7 +112,7 @@ module lib_xml
;
str_begin += str_attributes;
}
str_begin = (indent(depth) + "<" + str_begin + ">" + "\n");
str_begin = (lib_string.indent(depth) + "<" + str_begin + ">" + "\n");
str += str_begin;
}
// children
@ -141,7 +123,7 @@ module lib_xml
{
let str_end : string = "";
str_end += name;
str_end = (indent(depth) + "<" + "/" + str_end + ">" + "\n");
str_end = (lib_string.indent(depth) + "<" + "/" + str_end + ">" + "\n");
str += str_end;
}
return str;

View file

@ -52,35 +52,35 @@
<header id="help_actuators_title">!translate:model.actuators.terms.plural</header>
<p id="help_actuators_introduction">!translate:help.actuators.introduction</p>
<ul>
<li class="help_actuators_actuator" id="help_actuators_actuator_erzeuger">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.erzeuger.name</header>
<li class="help_actuators_actuator" id="help_actuators_actuator_generator">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.generator.name</header>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.erzeuger</div>
<div class="help_actuators_actuator_text">!translate:help.actuators.generator</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_annehmer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.annehmer.name</header>
<li class="help_actuators_actuator" id="help_actuators_actuator_acceptor">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.acceptor.name</header>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.annehmer</div>
<div class="help_actuators_actuator_text">!translate:help.actuators.acceptor</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_verwerfer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.verwerfer.name</header>
<li class="help_actuators_actuator" id="help_actuators_actuator_rejector">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.rejector.name</header>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.verwerfer</div>
<div class="help_actuators_actuator_text">!translate:help.actuators.rejector</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_befoerderer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.befoerderer.name</header>
<li class="help_actuators_actuator" id="help_actuators_actuator_conveyer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.conveyer.name</header>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.befoerderer</div>
<div class="help_actuators_actuator_text">!translate:help.actuators.conveyer</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_schreiber">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.schreiber.name</header>
<li class="help_actuators_actuator" id="help_actuators_actuator_writer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.writer.name</header>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.schreiber</div>
<div class="help_actuators_actuator_text">!translate:help.actuators.writer</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_leser">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.leser.name</header>
<li class="help_actuators_actuator" id="help_actuators_actuator_reader">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.reader.name</header>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.leser</div>
<div class="help_actuators_actuator_text">!translate:help.actuators.reader</div>
</li>
</ul>
</section>
@ -93,10 +93,10 @@
<p id="help_tasks_acceptor_description">!translate:help.tasks.acceptor.description</p>
<p id="help_tasks_acceptor_example">!translate:help.tasks.acceptor.example</p>
</li>
<li id="help_tasks_transductor">
<header id="help_tasks_acceptor_name">!translate:model.tasks.kinds.transductor.name</header>
<p id="help_tasks_transductor_description">!translate:help.tasks.transductor.description</p>
<p id="help_tasks_transductor_example">!translate:help.tasks.transductor.example</p>
<li id="help_tasks_transducer">
<header id="help_tasks_acceptor_name">!translate:model.tasks.kinds.transducer.name</header>
<p id="help_tasks_transducer_description">!translate:help.tasks.transducer.description</p>
<p id="help_tasks_transducer_example">!translate:help.tasks.transducer.example</p>
</li>
</ul>
</section>

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -42,14 +42,18 @@ body
a
{
color: hsl(120, 50%, 50%);
text-decoration: none;
cursor: pointer;
}
a:hover
{
color: hsl(120, 50%, 75%);
&:not(:hover)
{
color: hsl(120, 50%, 50%);
}
&:hover
{
color: hsl(120, 50%, 75%);
}
}
li
@ -57,6 +61,35 @@ li
list-style-type: "» ";
}
input,select,textarea,button
{
margin: 4px;
border: none;
padding: 8px;
// border-radius: 2px;
// box-shadow: 1px 1px 1px black;
cursor: pointer;
font-family: monospace;
// font-weight: bold;
&:not(:hover)
{
background-color: hsl(120, 0%, 25%);
color: hsl(120, 0%, 100%);
}
&:hover
{
background-color: hsl(120, 50%, 25%);
color: hsl(120, 0%, 100%);
transition: 0.25s ease;
}
}
body > header
{
font-size: 200%;
@ -72,12 +105,12 @@ body > header
#radio_help:checked
{
& ~ #help {}
& ~ #game {display: none;}
& ~ #game {display: none !important;}
}
#radio_game:checked
{
& ~ #help {display: none;}
& ~ #help {display: none !important;}
& ~ #game {}
}
@ -131,43 +164,45 @@ body > header
{
& > *
{
margin: 2px;
margin: 4px;
display: block;
text-transform: capitalize;
}
&.initial
{
& > #button_step {}
& > #button_run {}
& > #button_stop {display: none;}
& > #button_edit {display: none;}
& > #button_stop {display: none !important;}
& > #button_edit {display: none !important;}
& > #button_clear {}
}
&.uncertain_running
{
& > #button_step {display: none;}
& > #button_run {display: none;}
& > #button_step {display: none !important;}
& > #button_run {display: none !important;}
& > #button_stop {}
& > #button_edit {display: none;}
& > #button_clear {display: none;}
& > #button_edit {display: none !important;}
& > #button_clear {display: none !important;}
}
&.uncertain_standing
{
& > #button_step {}
& > #button_run {}
& > #button_stop {display: none;}
& > #button_stop {display: none !important;}
& > #button_edit {}
& > #button_clear {display: none;}
& > #button_clear {display: none !important;}
}
&.done
{
& > #button_step {display: none;}
& > #button_run {display: none;}
& > #button_stop {display: none;}
& > #button_step {display: none !important;}
& > #button_run {display: none !important;}
& > #button_stop {display: none !important;}
& > #button_edit {}
& > #button_clear {display: none;}
& > #button_clear {display: none !important;}
}
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -22,7 +22,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function tasks_insert(behandler : (task : mod_model.mod_task.type_task)=>void) : void
function tasks_insert(handler : (task : mod_model.mod_task.type_task)=>void) : void
{
let tasks_raw_ : lib_errormonade.type_errormonade<Array<any>> = mod_vtm.mod_data.read("tasks");
if (lib_errormonade.filled(tasks_raw_))
@ -33,24 +33,24 @@ module mod_vtm
(
(task_raw, index) =>
{
let task : mod_model.mod_task.type_task = mod_model.mod_task.import_(task_raw);
// Aufgabe registrieren
{
let task : mod_model.mod_task.type_task = mod_model.mod_task.import_(task_raw);
mod_model.mod_task.registrieren(task);
}
// Option insert
// Option eintragen
{
let praefix : string = (
let prefix : string = (
{
"acceptor": lib_translate.get("model.tasks.kinds.acceptor.shortcut"),
"transductor": lib_translate.get("model.tasks.kinds.transductor.shortcut"),
"transducer": lib_translate.get("model.tasks.kinds.transducer.shortcut"),
}[task_raw["kind"]]
);
let titel : string = ("[" + praefix + "]" + " " + task_raw["parameter"]["titel"]);
let title : string = ("[" + prefix + "]" + " " + mod_model.mod_task.title(task));
let value : string = index.toFixed(0);
let dom_option : Element = document.createElement("option");
dom_option.setAttribute("value", value);
dom_option.textContent = titel;
dom_option.textContent = title;
dom_selection.appendChild(dom_option);
}
}
@ -64,7 +64,7 @@ module mod_vtm
let value : string = dom_selection["value"];
let index : int = parseInt(value);
let task : mod_model.mod_task.type_task = mod_model.mod_task.get(index);
behandler(task);
handler(task);
}
)
;
@ -110,59 +110,59 @@ module mod_vtm
{
// Arten
{
let von_x : float = -0.5;
let von_y : float = -0.5;
let bis_x : float = +0.5;
let bis_y : float = +0.5;
let breite : float = 80;
let hoehe : float = 80;
let from_x : float = -0.5;
let from_y : float = -0.5;
let to_x : float = +0.5;
let to_y : float = +0.5;
let width : float = 80;
let height : float = 80;
[
{
"model": mod_model.mod_actuator.example("erzeuger"),
"bereich": document.querySelector("#help_actuators_actuator_erzeuger"),
"model": mod_model.mod_actuator.example("generator"),
"area": document.querySelector("#help_actuators_actuator_generator"),
},
{
"model": mod_model.mod_actuator.example("annehmer"),
"bereich": document.querySelector("#help_actuators_actuator_annehmer"),
"model": mod_model.mod_actuator.example("acceptor"),
"area": document.querySelector("#help_actuators_actuator_acceptor"),
},
{
"model": mod_model.mod_actuator.example("verwerfer"),
"bereich": document.querySelector("#help_actuators_actuator_verwerfer"),
"model": mod_model.mod_actuator.example("rejector"),
"area": document.querySelector("#help_actuators_actuator_rejector"),
},
{
"model": mod_model.mod_actuator.example("befoerderer"),
"bereich": document.querySelector("#help_actuators_actuator_befoerderer"),
"model": mod_model.mod_actuator.example("conveyer"),
"area": document.querySelector("#help_actuators_actuator_conveyer"),
},
{
"model": mod_model.mod_actuator.example("schreiber"),
"bereich": document.querySelector("#help_actuators_actuator_schreiber"),
"model": mod_model.mod_actuator.example("writer"),
"area": document.querySelector("#help_actuators_actuator_writer"),
},
{
"model": mod_model.mod_actuator.example("leser"),
"bereich": document.querySelector("#help_actuators_actuator_leser"),
"model": mod_model.mod_actuator.example("reader"),
"area": document.querySelector("#help_actuators_actuator_reader"),
},
]
.forEach
(
eintrag =>
entry =>
{
let manifestation = (
mod_manifestation.mod_svg.mod_actuator.create_manifestation
mod_manifestation.mod_svg.mod_actuator.create_extended
(
eintrag.model,
entry.model,
mod_model.mod_spot.null_()
)
);
let xmlnode : lib_xml.type_node = (
mod_manifestation.mod_svg.root
lib_svg.root
(
von_x, von_y,
bis_x, bis_y,
breite, hoehe,
from_x, from_y,
to_x, to_y,
width, height,
[mod_manifestation.view(manifestation)]
)
);
eintrag.bereich.querySelector(".help_actuators_actuator_image").innerHTML = lib_xml.view(xmlnode);
entry.area.querySelector(".help_actuators_actuator_image").innerHTML = lib_xml.view(xmlnode);
}
)
;
@ -171,31 +171,31 @@ module mod_vtm
}
// Spiel
{
let round : mod_model.mod_round.type_round;
let game : mod_model.mod_game.type_game;
// Aufgaben
{
tasks_insert
(
function (task : mod_model.mod_task.type_task) : void {mod_model.mod_round.task_set(round, task);}
function (task : mod_model.mod_task.type_task) : void {mod_model.mod_game.task_set(game, task);}
)
;
}
// Aufbau
{
round = mod_model.mod_round.create(mod_model.mod_task.get(0));
game = mod_model.mod_game.create(mod_model.mod_task.get(0));
}
// Manifestationen
{
[
mod_manifestation.mod_web.mod_round.create_erweitert
mod_manifestation.mod_web.mod_game.create_extended
(
round,
game,
document.querySelector("#section_mid")
)
,
mod_manifestation.mod_store.mod_round.create_erweitert
mod_manifestation.mod_store.mod_game.create_extended
(
round
game
)
,
]

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -41,7 +41,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function von_spot(spot : mod_vtm.mod_model.mod_spot.type_spot) : type_position
export function from_spot(spot : mod_vtm.mod_model.mod_spot.type_spot) : type_position
{
return (
lib_vector.add

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,15 +25,15 @@ module mod_vtm
export module mod_store
{
export module mod_round
export module mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_round =
export type type_game =
{
model : mod_vtm.mod_model.mod_round.type_round;
model : mod_vtm.mod_model.mod_game.type_game;
}
;
@ -43,9 +43,9 @@ module mod_vtm
*/
export function create
(
model : mod_vtm.mod_model.mod_round.type_round
model : mod_vtm.mod_model.mod_game.type_game
)
: type_round
: type_game
{
return {
"model": model
@ -56,14 +56,14 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_erweitert
export function create_extended
(
model : mod_vtm.mod_model.mod_round.type_round
model : mod_vtm.mod_model.mod_game.type_game
)
: type_manifestation<mod_vtm.mod_model.mod_round.type_round>
: type_manifestation<mod_vtm.mod_model.mod_game.type_game>
{
return {
"kind": "store_round",
"kind": "store_game",
"data": create(model)
};
}
@ -72,7 +72,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(round : type_round) : void
function view(game : type_game) : void
{
}
@ -80,16 +80,16 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(round : type_round) : void
function bind(game : type_game) : void
{
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_task",
game.model,
"change_task",
(data) =>
{
// console.info("aendrung_task", data);
let task : mod_vtm.mod_model.mod_task.type_task = mod_vtm.mod_model.mod_round.task_read(round.model);
// console.info("change_task", data);
let task : mod_vtm.mod_model.mod_task.type_task = mod_vtm.mod_model.mod_game.task_read(game.model);
let id : string = mod_vtm.mod_model.mod_task.id(task);
let key : string = ("vtm_" + id);
//
@ -98,50 +98,50 @@ module mod_vtm
let item : string = localStorage.getItem(key);
let world_ : any = JSON.parse(item);
let world : mod_vtm.mod_model.mod_world.type_world = mod_vtm.mod_model.mod_world.import_(world_);
mod_vtm.mod_model.mod_round.world_set(round.model, world, false);
mod_vtm.mod_model.mod_game.world_set(game.model, world, false);
}
else
{
mod_vtm.mod_model.mod_round.world_clear(round.model);
mod_vtm.mod_model.mod_game.world_clear(game.model);
// nothing tun
}
}
)
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_world",
game.model,
"change_world",
(data) =>
{
let task : mod_vtm.mod_model.mod_task.type_task = mod_vtm.mod_model.mod_round.task_read(round.model);
let task : mod_vtm.mod_model.mod_task.type_task = mod_vtm.mod_model.mod_game.task_read(game.model);
let id : string = mod_vtm.mod_model.mod_task.id(task);
let key : string = ("vtm_" + id);
//
let world : mod_vtm.mod_model.mod_world.type_world = mod_vtm.mod_model.mod_round.world_read(round.model);
let world : mod_vtm.mod_model.mod_world.type_world = mod_vtm.mod_model.mod_game.world_read(game.model);
let world_ : any = mod_vtm.mod_model.mod_world.export_(world);
let item : string = JSON.stringify(world_);
localStorage.setItem(key, item);
}
)
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_token",
game.model,
"change_token",
(data) =>
{
// console.info("aendrung_token", data);
// console.info("change_token", data);
}
)
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_mode",
game.model,
"change_mode",
(data) =>
{
// console.info("aendrung_mode", data);
// console.info("change_mode", data);
}
)
;
@ -151,10 +151,10 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_round.type_round, void>>
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, void>>
(
trait_manifestation,
"store_round",
"store_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -75,7 +75,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_manifestation
export function create_extended
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
@ -98,7 +98,7 @@ module mod_vtm
let node_rahmen = function () : lib_xml.type_node
{
return (
path
lib_svg.path
(
mod_vtm.mod_helfer.sequence(6).map(i => lib_vector.polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true,
@ -109,7 +109,7 @@ module mod_vtm
);
}
;
let position : mod_position.type_position = mod_position.von_spot(actuator_.spot);
let position : mod_position.type_position = mod_position.from_spot(actuator_.spot);
let node_tile : lib_xml.type_node = (
lib_xml.create_normal
(
@ -117,7 +117,7 @@ module mod_vtm
{
"class": "tile",
"rel": mod_vtm.mod_model.mod_spot.hash(actuator_.spot),
"transform": translation(position.x, position.y),
"transform": lib_svg.translation(position.x, position.y),
},
(
[node_rahmen()]

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -34,7 +34,7 @@ module mod_vtm
lib_trait.attend
(
trait_actuator,
"annehmer",
"acceptor",
{
"view": (actuator) =>
{
@ -44,9 +44,9 @@ module mod_vtm
(
"circle",
{
"cx": (0.0).toFixed(float_precision),
"cy": (0.0).toFixed(float_precision),
"r": (0.25).toFixed(float_precision),
"cx": (0.0).toFixed(lib_svg.float_precision),
"cy": (0.0).toFixed(lib_svg.float_precision),
"r": (0.25).toFixed(lib_svg.float_precision),
"class": (
[
"kreis",

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -34,7 +34,7 @@ module mod_vtm
lib_trait.attend
(
trait_actuator,
"befoerderer",
"conveyer",
{
"view": ({"data": {"direction": direction}}) =>
{
@ -44,7 +44,7 @@ module mod_vtm
(
"path",
{
"d": shape_arrow,
"d": lib_svg.shape_arrow,
"class": (
[
"pfeil",
@ -53,9 +53,9 @@ module mod_vtm
),
"transform": (
[
rotation(direction/6),
translation(-0.2, 0),
skalierung(0.12),
lib_svg.rotation(direction/6),
lib_svg.translation(-0.2, 0),
lib_svg.skalierung(0.12),
].join(" ")
),
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -34,7 +34,7 @@ module mod_vtm
lib_trait.attend
(
trait_actuator,
"erzeuger",
"generator",
{
"view": ({"data": {"direction": direction}}) =>
{
@ -44,18 +44,18 @@ module mod_vtm
(
"path",
{
"d": shape_arrow,
"d": lib_svg.shape_arrow,
"class": (
[
"pfeil",
"erzeuger",
"generator",
].join(" ")
),
"transform": (
[
rotation(direction/6),
translation(-0.2, 0),
skalierung(0.12),
lib_svg.rotation(direction/6),
lib_svg.translation(-0.2, 0),
lib_svg.skalierung(0.12),
].join(" ")
),
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -34,7 +34,7 @@ module mod_vtm
lib_trait.attend
(
trait_actuator,
"leser",
"reader",
{
"view": ({"data": {"direction": direction, "symbol_links": symbol_links, "symbol_rechts": symbol_rechts}}) =>
{
@ -71,7 +71,7 @@ module mod_vtm
(
"path",
{
"d": shape_arrow,
"d": lib_svg.shape_arrow,
"class": (
[
"pfeil",
@ -84,9 +84,9 @@ module mod_vtm
),
"transform": (
[
rotation(anglestaerke),
translation(+0.1, 0),
skalierung(0.075),
lib_svg.rotation(anglestaerke),
lib_svg.translation(+0.1, 0),
lib_svg.skalierung(0.075),
].join(" ")
),
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -34,7 +34,7 @@ module mod_vtm
lib_trait.attend
(
trait_actuator,
"verwerfer",
"rejector",
{
"view": (actuator) =>
{
@ -44,9 +44,9 @@ module mod_vtm
(
"circle",
{
"cx": (0.0).toFixed(float_precision),
"cy": (0.0).toFixed(float_precision),
"r": (0.25).toFixed(float_precision),
"cx": (0.0).toFixed(lib_svg.float_precision),
"cy": (0.0).toFixed(lib_svg.float_precision),
"r": (0.25).toFixed(lib_svg.float_precision),
"class": (
[
"kreis",

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -34,7 +34,7 @@ module mod_vtm
lib_trait.attend
(
trait_actuator,
"schreiber",
"writer",
{
"view": ({"data": {"direction": direction, "symbol": symbol}}) =>
{
@ -44,7 +44,7 @@ module mod_vtm
(
"path",
{
"d": shape_arrow,
"d": lib_svg.shape_arrow,
"class": (
[
"pfeil",
@ -53,9 +53,9 @@ module mod_vtm
),
"transform": (
[
rotation(direction/6),
translation(-0.2, 0),
skalierung(0.12),
lib_svg.rotation(direction/6),
lib_svg.translation(-0.2, 0),
lib_svg.skalierung(0.12),
].join(" ")
),
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,15 +25,15 @@ module mod_vtm
export module mod_svg
{
export module mod_round
export module mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_round =
export type type_game =
{
model : mod_vtm.mod_model.mod_round.type_round;
model : mod_vtm.mod_model.mod_game.type_game;
}
;
@ -41,7 +41,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create(model : mod_vtm.mod_model.mod_round.type_round) : type_round
function create(model : mod_vtm.mod_model.mod_game.type_game) : type_game
{
return {
"model": model
@ -52,10 +52,10 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_manifestation(model : mod_vtm.mod_model.mod_round.type_round) : type_manifestation<mod_vtm.mod_model.mod_round.type_round>
export function create_extended(model : mod_vtm.mod_model.mod_game.type_game) : type_manifestation<mod_vtm.mod_model.mod_game.type_game>
{
return {
"kind": "svg_round",
"kind": "svg_game",
"data": create(model)
};
}
@ -64,20 +64,20 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(round : type_round) : lib_xml.type_node
function view(game : type_game) : lib_xml.type_node
{
let children_round : Array<lib_xml.type_node> = [];
let children_game : Array<lib_xml.type_node> = [];
// Welt
{
let children_world : Array<lib_xml.type_node> = [];
// Felder
{
let children_tiles : Array<lib_xml.type_node> = [];
mod_vtm.mod_model.mod_world.tiles_read(mod_vtm.mod_model.mod_round.world_read(round.model)).forEach
mod_vtm.mod_model.mod_world.tiles_read(mod_vtm.mod_model.mod_game.world_read(game.model)).forEach
(
({"spot": spot, "actuator": actuator}) =>
{
let manifestation_tile : type_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator> = mod_actuator.create_manifestation(actuator, spot);
let manifestation_tile : type_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator> = mod_actuator.create_extended(actuator, spot);
let node_tile : lib_xml.type_node = mod_manifestation.view(manifestation_tile);
children_tiles.push(node_tile);
}
@ -106,41 +106,41 @@ module mod_vtm
children_world
)
);
children_round.push(node_world);
children_game.push(node_world);
}
// Figur
{
let token_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_token.type_token> = mod_vtm.mod_model.mod_round.token_read(round.model);
let token_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_token.type_token> = mod_vtm.mod_model.mod_game.token_read(game.model);
if (lib_errormonade.filled(token_))
{
let token : mod_vtm.mod_model.mod_token.type_token = lib_errormonade.read(token_);
let manifestation_token : type_manifestation<mod_vtm.mod_model.mod_token.type_token> = mod_token.create_manifestation(token);
let manifestation_token : type_manifestation<mod_vtm.mod_model.mod_token.type_token> = mod_token.create_extended(token);
let node_token : lib_xml.type_node = mod_manifestation.view(manifestation_token);
children_round.push(node_token);
children_game.push(node_token);
}
else
{
// nothing tun
}
}
let node_round : lib_xml.type_node = (
let node_game : lib_xml.type_node = (
lib_xml.create_normal
(
"g",
{
"class": "round",
"class": "game",
},
children_round
children_game
)
);
return node_round;
return node_game;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(round : type_round) : void
function bind(game : type_game) : void
{
}
@ -148,10 +148,10 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_round.type_round, lib_xml.type_node>>
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, lib_xml.type_node>>
(
trait_manifestation,
"svg_round",
"svg_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -56,7 +56,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_manifestation
export function create_extended
(
model : mod_vtm.mod_model.mod_token.type_token
)
@ -87,9 +87,9 @@ module mod_vtm
(
"circle",
{
"cx": (0.0).toFixed(float_precision),
"cy": (0.0).toFixed(float_precision),
"r": (0.125).toFixed(float_precision),
"cx": (0.0).toFixed(lib_svg.float_precision),
"cy": (0.0).toFixed(lib_svg.float_precision),
"r": (0.125).toFixed(lib_svg.float_precision),
"class": "stein",
}
)
@ -112,14 +112,14 @@ module mod_vtm
(
"circle",
{
"cx": x.toFixed(float_precision),
"cy": y.toFixed(float_precision),
"r": r.toFixed(float_precision),
"cx": x.toFixed(lib_svg.float_precision),
"cy": y.toFixed(lib_svg.float_precision),
"r": r.toFixed(lib_svg.float_precision),
/*
"x": (x-r).toFixed(float_precision),
"y": (y-r).toFixed(float_precision),
"width": (2*r).toFixed(float_precision),
"height": (2*r).toFixed(float_precision),
"x": (x-r).toFixed(lib_svg.float_precision),
"y": (y-r).toFixed(lib_svg.float_precision),
"width": (2*r).toFixed(lib_svg.float_precision),
"height": (2*r).toFixed(lib_svg.float_precision),
*/
"class": (
[
@ -146,14 +146,14 @@ module mod_vtm
);
children_token.push(node_tape);
}
let position : mod_position.type_position = mod_position.von_spot(mod_vtm.mod_model.mod_token.spot_read(token));
let position : mod_position.type_position = mod_position.from_spot(mod_vtm.mod_model.mod_token.spot_read(token));
let node_token = (
lib_xml.create_normal
(
"g",
{
"class": "token",
"transform": translation(position.x, position.y),
"transform": lib_svg.translation(position.x, position.y),
},
children_token
)

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -59,7 +59,7 @@ $helligkeit_symbol: 50%;
stroke: none;
}
.erzeuger
.generator
{
fill: hsl( 0, 0%, 100%);
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,25 +25,27 @@ module mod_vtm
export module mod_web
{
export module mod_round
export module mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function text_nachedit(text : string) : string
function text_postprocess(text : string) : string
{
let regexp : RegExp = (new RegExp("\\$\{s(\\d*)\}", "g"));
return text.replace(regexp, "<span class=\"symbol_$1\">&nbsp;&nbsp;</span>");
let vars : {[name : string] : string} = {};
for (let i : int = 0; i <= 3; i += 1)
vars["s" + i.toFixed(0)] = ("<span class=\"symbol_" + i.toFixed(0) + "\">&nbsp;&nbsp;</span>");
return lib_string.stance(text, vars);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_round =
export type type_game =
{
model : mod_model.mod_round.type_round;
model : mod_model.mod_game.type_game;
area : Element;
intervall : lib_errormonade.type_errormonade<any>;
}
@ -55,10 +57,10 @@ module mod_vtm
*/
function create
(
model : mod_model.mod_round.type_round,
model : mod_model.mod_game.type_game,
area : Element
)
: type_round
: type_game
{
return {
"model": model,
@ -71,31 +73,34 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_erweitert
export function create_extended
(
model : mod_model.mod_round.type_round,
model : mod_model.mod_game.type_game,
area : Element
)
: type_manifestation<mod_model.mod_round.type_round>
: type_manifestation<mod_model.mod_game.type_game>
{
return {
"kind": "web_round",
"data": create(model, area)
};
return (
lib_call.wrap
(
"web_game",
create(model, area)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_task(round : type_round) : void
function update_task(game : type_game) : void
{
document.querySelector("#task_text").innerHTML = (
text_nachedit
text_postprocess
(
mod_vtm.mod_model.mod_task.text
(
mod_vtm.mod_model.mod_round.task_read(round.model)
mod_vtm.mod_model.mod_game.task_read(game.model)
)
)
);
@ -105,44 +110,44 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_world(round : type_round) : void
function update_world(game : type_game) : void
{
let node_svg : lib_xml.type_node = mod_svg.root
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_round.create_manifestation(round.model))]
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
round.area.innerHTML = lib_xml.view(node_svg);
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_token(round : type_round) : void
function update_token(game : type_game) : void
{
let node_svg : lib_xml.type_node = mod_svg.root
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_round.create_manifestation(round.model))]
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
round.area.innerHTML = lib_xml.view(node_svg);
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_mode(round : type_round) : void
function update_mode(game : type_game) : void
{
let status : string;
switch (mod_vtm.mod_model.mod_round.mode_read(round.model))
switch (mod_vtm.mod_model.mod_game.mode_read(game.model))
{
case mod_vtm.mod_model.mod_mode.initial:
{
@ -178,21 +183,21 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_buttons(round : type_round) : void
function update_buttons(game : type_game) : void
{
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_round.mode_read(round.model);
let klasse : string;
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_game.mode_read(game.model);
let class_ : string;
switch (mode)
{
case mod_vtm.mod_model.mod_mode.initial:
{
klasse = "initial";
class_ = "initial";
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
klasse = (
lib_errormonade.filled<any>(round.intervall)
class_ = (
lib_errormonade.filled<any>(game.intervall)
? "uncertain_running"
: "uncertain_standing"
);
@ -201,7 +206,7 @@ module mod_vtm
case mod_vtm.mod_model.mod_mode.wrong:
case mod_vtm.mod_model.mod_mode.correct:
{
klasse = "done";
class_ = "done";
break;
}
default:
@ -210,97 +215,97 @@ module mod_vtm
break;
}
}
document.querySelector("#buttons").setAttribute("class", klasse);
document.querySelector("#buttons").setAttribute("class", class_);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(round : type_round) : void
function view(game : type_game) : void
{
update_task(round);
update_world(round);
update_token(round);
update_mode(round);
update_buttons(round);
update_task(game);
update_world(game);
update_token(game);
update_mode(game);
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function stop(round : type_round) : void
function stop(game : type_game) : void
{
if (lib_errormonade.filled(round.intervall))
if (lib_errormonade.filled(game.intervall))
{
clearInterval(lib_errormonade.read(round.intervall));
round.intervall = (lib_errormonade.create_nothing<any>());
clearInterval(lib_errormonade.read(game.intervall));
game.intervall = (lib_errormonade.create_nothing<any>());
}
else
{
let message : string = "kein Intervall gesetzt";
console.warn(message);
}
update_buttons(round);
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function resume(round : type_round) : void
function resume(game : type_game) : void
{
mod_vtm.mod_model.mod_round.resume(round.model);
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_round.mode_read(round.model);
mod_vtm.mod_model.mod_game.resume(game.model);
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_game.mode_read(game.model);
if (mode <= 1)
{
// nothing tun
}
else
{
stop(round);
stop(game);
}
update_buttons(round);
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function testen(round : type_round) : void
function testen(game : type_game) : void
{
let handle : any = setInterval(() => resume(round), 500);
round.intervall = (lib_errormonade.create_just<any>(handle));
let handle : any = setInterval(() => resume(game), 500);
game.intervall = (lib_errormonade.create_just<any>(handle));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function edit(round : type_round) : void
function edit(game : type_game) : void
{
stop(round);
mod_vtm.mod_model.mod_round.reset(round.model);
stop(game);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function clear(round : type_round) : void
function clear(game : type_game) : void
{
mod_vtm.mod_model.mod_round.world_clear(round.model);
mod_vtm.mod_model.mod_round.reset(round.model);
mod_vtm.mod_model.mod_game.world_clear(game.model);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(round : type_round) : void
function bind(game : type_game) : void
{
let spot_ermitteln = (target : EventTarget) =>
let spot_determine = (target : EventTarget) =>
{
let spot : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot>;
let dom_tile : Element = target["closest"](".tile");
@ -311,63 +316,63 @@ module mod_vtm
else
{
let rel : string = dom_tile.getAttribute("rel")
spot = (lib_errormonade.create_just<mod_vtm.mod_model.mod_spot.type_spot>(mod_vtm.mod_model.mod_spot.von_hash(rel)));
spot = (lib_errormonade.create_just<mod_vtm.mod_model.mod_spot.type_spot>(mod_vtm.mod_model.mod_spot.from_hash(rel)));
}
return spot;
}
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_task",
game.model,
"change_task",
(data) =>
{
update_task(round);
update_task(game);
}
)
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_world",
game.model,
"change_world",
(data) =>
{
update_world(round);
update_world(game);
}
)
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_token",
game.model,
"change_token",
(data) =>
{
update_token(round);
update_token(game);
}
)
;
mod_vtm.mod_model.mod_round.lauschen
mod_vtm.mod_model.mod_game.lauschen
(
round.model,
"aendrung_mode",
game.model,
"change_mode",
(data) =>
{
update_mode(round);
update_buttons(round);
update_mode(game);
update_buttons(game);
}
)
;
// Links-Klick
round.area.addEventListener
game.area.addEventListener
(
"click",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_ermitteln(event.target);
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
mod_vtm.mod_model.mod_round.world_tile_wechseln(round.model, lib_errormonade.read(spot_), false);
mod_vtm.mod_model.mod_game.world_tile_wechseln(game.model, lib_errormonade.read(spot_), false);
}
else
{
@ -377,16 +382,16 @@ module mod_vtm
)
;
// Rechts-Klick
round.area.addEventListener
game.area.addEventListener
(
"contextmenu",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_ermitteln(event.target);
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
mod_vtm.mod_model.mod_round.world_tile_wechseln(round.model, lib_errormonade.read(spot_), true);
mod_vtm.mod_model.mod_game.world_tile_wechseln(game.model, lib_errormonade.read(spot_), true);
}
else
{
@ -396,17 +401,17 @@ module mod_vtm
)
;
// Mausrad
round.area.addEventListener
game.area.addEventListener
(
"wheel",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_ermitteln(event.target);
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1);
mod_vtm.mod_model.mod_round.world_tile_rotate(round.model, lib_errormonade.read(spot_), inkrement);
mod_vtm.mod_model.mod_game.world_tile_rotate(game.model, lib_errormonade.read(spot_), inkrement);
}
else
{
@ -421,8 +426,8 @@ module mod_vtm
"click",
event =>
{
stop(round);
resume(round);
stop(game);
resume(game);
}
)
;
@ -432,7 +437,7 @@ module mod_vtm
"click",
event =>
{
testen(round);
testen(game);
}
)
;
@ -442,7 +447,7 @@ module mod_vtm
"click",
event =>
{
stop(round);
stop(game);
}
)
;
@ -452,7 +457,7 @@ module mod_vtm
"click",
event =>
{
edit(round);
edit(game);
}
)
;
@ -462,7 +467,7 @@ module mod_vtm
"click",
event =>
{
clear(round);
clear(game);
}
)
;
@ -472,10 +477,10 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_round.type_round, void>>
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, void>>
(
trait_manifestation,
"web_round",
"web_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,19 +25,19 @@ module mod_vtm
export module mod_actuator
{
export module mod_annehmer
export module mod_acceptor
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let kind : string = "annehmer";
let kind : string = "acceptor";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_annehmer =
export type type_acceptor =
{
}
;
@ -49,7 +49,7 @@ module mod_vtm
function create
(
)
: type_annehmer
: type_acceptor
{
return {
};
@ -59,7 +59,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_actuator
export function create_extended
(
)
: mod_actuator.type_actuator
@ -74,7 +74,7 @@ module mod_vtm
function example
(
)
: type_annehmer
: type_acceptor
{
return create();
}
@ -85,7 +85,7 @@ module mod_vtm
*/
function rotate
(
annehmer : type_annehmer,
acceptor : type_acceptor,
inkrement ?: int
)
: void
@ -98,7 +98,7 @@ module mod_vtm
*/
function use
(
annehmer : type_annehmer,
acceptor : type_acceptor,
token : mod_token.type_token
)
: void
@ -112,7 +112,7 @@ module mod_vtm
*/
function export_
(
annehmer : type_annehmer
acceptor : type_acceptor
)
: any
{
@ -128,7 +128,7 @@ module mod_vtm
(
raw : any
)
: type_annehmer
: type_acceptor
{
return (
create

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,19 +25,19 @@ module mod_vtm
export module mod_actuator
{
export module mod_befoerderer
export module mod_conveyer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let kind : string = "befoerderer";
let kind : string = "conveyer";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_befoerderer =
export type type_conveyer =
{
direction : mod_direction.type_direction;
}
@ -51,7 +51,7 @@ module mod_vtm
(
direction : mod_direction.type_direction
)
: type_befoerderer
: type_conveyer
{
return {
"direction": direction,
@ -62,7 +62,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_actuator
export function create_extended
(
direction : mod_direction.type_direction
)
@ -78,7 +78,7 @@ module mod_vtm
function example
(
)
: type_befoerderer
: type_conveyer
{
return create(0);
}
@ -89,11 +89,11 @@ module mod_vtm
*/
export function direction_read
(
befoerderer : type_befoerderer
conveyer : type_conveyer
)
: mod_direction.type_direction
{
return befoerderer.direction;
return conveyer.direction;
}
@ -102,12 +102,12 @@ module mod_vtm
*/
function rotate
(
befoerderer : type_befoerderer,
conveyer : type_conveyer,
inkrement : int = +1
)
: void
{
befoerderer.direction = mod_direction.add(befoerderer.direction, inkrement);
conveyer.direction = mod_direction.add(conveyer.direction, inkrement);
}
@ -116,12 +116,12 @@ module mod_vtm
*/
function use
(
befoerderer : type_befoerderer,
conveyer : type_conveyer,
token : mod_token.type_token
)
: void
{
mod_token.move(token, befoerderer.direction);
mod_token.move(token, conveyer.direction);
}
@ -130,12 +130,12 @@ module mod_vtm
*/
function export_
(
befoerderer : type_befoerderer
conveyer : type_conveyer
)
: any
{
return {
"direction": mod_direction.export_(befoerderer.direction),
"direction": mod_direction.export_(conveyer.direction),
};
}
@ -145,14 +145,14 @@ module mod_vtm
*/
function import_
(
befoerderer_ : any
conveyer_ : any
)
: type_befoerderer
: type_conveyer
{
return (
create
(
mod_direction.import_(befoerderer_["direction"])
mod_direction.import_(conveyer_["direction"])
)
);
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,19 +25,19 @@ module mod_vtm
export module mod_actuator
{
export module mod_erzeuger
export module mod_generator
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let kind : string = "erzeuger";
let kind : string = "generator";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_erzeuger =
export type type_generator =
{
direction : mod_direction.type_direction;
}
@ -51,7 +51,7 @@ module mod_vtm
(
direction : mod_direction.type_direction
)
: type_erzeuger
: type_generator
{
return {
"direction": direction,
@ -62,7 +62,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_actuator
export function create_extended
(
direction : mod_direction.type_direction
)
@ -78,7 +78,7 @@ module mod_vtm
function example
(
)
: type_erzeuger
: type_generator
{
return create(0);
}
@ -89,11 +89,11 @@ module mod_vtm
*/
export function direction_read
(
erzeuger : type_erzeuger
generator : type_generator
)
: mod_direction.type_direction
{
return erzeuger.direction;
return generator.direction;
}
@ -102,12 +102,12 @@ module mod_vtm
*/
function rotate
(
erzeuger : type_erzeuger,
generator : type_generator,
inkrement : int = +1
)
: void
{
erzeuger.direction = mod_direction.add(erzeuger.direction, inkrement);
generator.direction = mod_direction.add(generator.direction, inkrement);
}
@ -116,12 +116,12 @@ module mod_vtm
*/
function use
(
erzeuger : type_erzeuger,
generator : type_generator,
token : mod_token.type_token
)
: void
{
mod_token.move(token, erzeuger.direction);
mod_token.move(token, generator.direction);
}
@ -130,12 +130,12 @@ module mod_vtm
*/
function export_
(
erzeuger : type_erzeuger
generator : type_generator
)
: any
{
return {
"direction": mod_direction.export_(erzeuger.direction),
"direction": mod_direction.export_(generator.direction),
};
}
@ -147,7 +147,7 @@ module mod_vtm
(
raw : any
)
: type_erzeuger
: type_generator
{
return (
create

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,19 +25,19 @@ module mod_vtm
export module mod_actuator
{
export module mod_leser
export module mod_reader
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let kind : string = "leser";
let kind : string = "reader";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_leser =
export type type_reader =
{
"direction": mod_direction.type_direction,
"symbol_links": mod_symbol.type_symbol,
@ -55,7 +55,7 @@ module mod_vtm
symbol_links : mod_symbol.type_symbol,
symbol_rechts : mod_symbol.type_symbol
)
: type_leser
: type_reader
{
return {
"direction": direction,
@ -68,7 +68,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_actuator
export function create_extended
(
direction : mod_direction.type_direction,
symbol_links : mod_symbol.type_symbol,
@ -86,7 +86,7 @@ module mod_vtm
function example
(
)
: type_leser
: type_reader
{
return create(0, 0, 1);
}
@ -97,11 +97,11 @@ module mod_vtm
*/
export function direction_read
(
leser : type_leser
reader : type_reader
)
: mod_direction.type_direction
{
return leser.direction;
return reader.direction;
}
@ -110,11 +110,11 @@ module mod_vtm
*/
export function symbol_links_read
(
leser : type_leser
reader : type_reader
)
: mod_symbol.type_symbol
{
return leser.symbol_links;
return reader.symbol_links;
}
@ -123,11 +123,11 @@ module mod_vtm
*/
export function symbol_rechts_read
(
leser : type_leser
reader : type_reader
)
: mod_symbol.type_symbol
{
return leser.symbol_rechts;
return reader.symbol_rechts;
}
@ -136,12 +136,12 @@ module mod_vtm
*/
function rotate
(
leser : type_leser,
reader : type_reader,
inkrement : int = +1
)
: void
{
leser.direction = mod_direction.add(leser.direction, inkrement);
reader.direction = mod_direction.add(reader.direction, inkrement);
}
@ -150,7 +150,7 @@ module mod_vtm
*/
function use
(
leser : type_leser,
reader : type_reader,
token : mod_token.type_token
)
: void
@ -160,12 +160,12 @@ module mod_vtm
if (lib_errormonade.filled(symbol_))
{
let symbol : mod_symbol.type_symbol = lib_errormonade.read(symbol_);
if (symbol === leser.symbol_links)
if (symbol === reader.symbol_links)
{
mod_token.shift(token);
summand = +2;
}
else if (symbol === leser.symbol_rechts)
else if (symbol === reader.symbol_rechts)
{
mod_token.shift(token);
summand = -2;
@ -179,7 +179,7 @@ module mod_vtm
{
summand = 0;
}
let direction : mod_direction.type_direction = mod_direction.add(leser.direction, summand);
let direction : mod_direction.type_direction = mod_direction.add(reader.direction, summand);
mod_token.move(token, direction);
}
@ -189,14 +189,14 @@ module mod_vtm
*/
function export_
(
leser : type_leser
reader : type_reader
)
: any
{
return {
"direction": mod_direction.export_(leser.direction),
"symbol_links": mod_symbol.export_(leser.symbol_links),
"symbol_rechts": mod_symbol.export_(leser.symbol_rechts),
"direction": mod_direction.export_(reader.direction),
"symbol_links": mod_symbol.export_(reader.symbol_links),
"symbol_rechts": mod_symbol.export_(reader.symbol_rechts),
};
}
@ -208,7 +208,7 @@ module mod_vtm
(
raw : any
)
: type_leser
: type_reader
{
return (
create

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,19 +25,19 @@ module mod_vtm
export module mod_actuator
{
export module mod_verwerfer
export module mod_rejector
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let kind : string = "verwerfer";
let kind : string = "rejector";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_verwerfer =
export type type_rejector =
{
}
;
@ -49,7 +49,7 @@ module mod_vtm
function create
(
)
: type_verwerfer
: type_rejector
{
return {
};
@ -59,7 +59,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_actuator
export function create_extended
(
)
: mod_actuator.type_actuator
@ -74,7 +74,7 @@ module mod_vtm
function example
(
)
: type_verwerfer
: type_rejector
{
return create();
}
@ -85,7 +85,7 @@ module mod_vtm
*/
function rotate
(
verwerfer : type_verwerfer,
rejector : type_rejector,
inkrement ?: int
)
: void
@ -98,7 +98,7 @@ module mod_vtm
*/
function use
(
verwerfer : type_verwerfer,
rejector : type_rejector,
token : mod_token.type_token
)
: void
@ -112,7 +112,7 @@ module mod_vtm
*/
function export_
(
verwerfer : type_verwerfer
rejector : type_rejector
)
: any
{
@ -128,7 +128,7 @@ module mod_vtm
(
raw : any
)
: type_verwerfer
: type_rejector
{
return (
create

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -25,19 +25,19 @@ module mod_vtm
export module mod_actuator
{
export module mod_schreiber
export module mod_writer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let kind : string = "schreiber";
let kind : string = "writer";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_schreiber =
export type type_writer =
{
direction : mod_direction.type_direction;
symbol : mod_symbol.type_symbol;
@ -53,7 +53,7 @@ module mod_vtm
direction : mod_direction.type_direction,
symbol : mod_symbol.type_symbol
)
: type_schreiber
: type_writer
{
return {
"direction": direction,
@ -65,7 +65,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_actuator
export function create_extended
(
direction : mod_direction.type_direction,
symbol : mod_symbol.type_symbol
@ -82,7 +82,7 @@ module mod_vtm
function example
(
)
: type_schreiber
: type_writer
{
return create(0, 0);
}
@ -93,11 +93,11 @@ module mod_vtm
*/
export function direction_read
(
schreiber : type_schreiber
writer : type_writer
)
: mod_direction.type_direction
{
return schreiber.direction;
return writer.direction;
}
@ -106,11 +106,11 @@ module mod_vtm
*/
export function symbol_read
(
schreiber : type_schreiber
writer : type_writer
)
: mod_symbol.type_symbol
{
return schreiber.symbol;
return writer.symbol;
}
@ -119,12 +119,12 @@ module mod_vtm
*/
function rotate
(
schreiber : type_schreiber,
writer : type_writer,
inkrement : int = +1
)
: void
{
schreiber.direction = mod_direction.add(schreiber.direction, inkrement);
writer.direction = mod_direction.add(writer.direction, inkrement);
}
@ -133,13 +133,13 @@ module mod_vtm
*/
function use
(
schreiber : type_schreiber,
writer : type_writer,
token : mod_token.type_token
)
: void
{
mod_token.write(token, schreiber.symbol);
mod_token.move(token, schreiber.direction);
mod_token.write(token, writer.symbol);
mod_token.move(token, writer.direction);
}
@ -148,13 +148,13 @@ module mod_vtm
*/
function export_
(
schreiber : type_schreiber
writer : type_writer
)
: any
{
return {
"direction": mod_direction.export_(schreiber.direction),
"symbol": mod_symbol.export_(schreiber.symbol),
"direction": mod_direction.export_(writer.direction),
"symbol": mod_symbol.export_(writer.symbol),
};
}
@ -166,7 +166,7 @@ module mod_vtm
(
raw : any
)
: type_schreiber
: type_writer
{
return (
create

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -22,13 +22,13 @@ module mod_vtm
export module mod_model
{
export module mod_round
export module mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_round =
export type type_game =
{
world : mod_world.type_world;
token : lib_errormonade.type_errormonade<mod_token.type_token>;
@ -47,9 +47,9 @@ module mod_vtm
(
task : mod_task.type_task
)
: type_round
: type_game
{
let round : type_round =
let game : type_game =
{
"world": undefined,
"token": undefined,
@ -59,17 +59,17 @@ module mod_vtm
"listeners": undefined,
}
;
round.listeners =
game.listeners =
{
"aendrung_task": [],
"aendrung_world": [],
"aendrung_token": [],
"aendrung_mode": [],
"change_task": [],
"change_world": [],
"change_token": [],
"change_mode": [],
}
;
world_clear(round, false);
reset(round, false);
return round;
world_clear(game, false);
reset(game, false);
return game;
}
@ -78,15 +78,15 @@ module mod_vtm
*/
export function lauschen
(
round : type_round,
game : type_game,
event : string,
procedure : (data ?: any)=>void
)
: void
{
if (event in round.listeners)
if (event in game.listeners)
{
round.listeners[event].push(procedure);
game.listeners[event].push(procedure);
}
else
{
@ -101,14 +101,14 @@ module mod_vtm
*/
function notify
(
round : type_round,
game : type_game,
event : string,
data : any = {}
) : void
{
if (event in round.listeners)
if (event in game.listeners)
{
round.listeners[event].forEach
game.listeners[event].forEach
(
procedure =>
{
@ -130,18 +130,18 @@ module mod_vtm
*/
export function reset
(
round : type_round,
game : type_game,
inform : boolean = true
)
: void
{
round.token = (lib_errormonade.create_nothing<mod_token.type_token>());
round.testindex = (lib_errormonade.create_nothing<int>());
round.mode = mod_mode.initial;
game.token = (lib_errormonade.create_nothing<mod_token.type_token>());
game.testindex = (lib_errormonade.create_nothing<int>());
game.mode = mod_mode.initial;
if (inform)
{
notify(round, "aendrung_token", {});
notify(round, "aendrung_mode", {});
notify(game, "change_token", {});
notify(game, "change_mode", {});
}
else
{
@ -155,11 +155,11 @@ module mod_vtm
*/
export function task_read
(
round : type_round
game : type_game
)
: mod_task.type_task
{
return round.task;
return game.task;
}
@ -168,14 +168,14 @@ module mod_vtm
*/
export function task_set
(
round : type_round,
game : type_game,
task : mod_task.type_task
) : void
{
round.task = task;
// round.world_clear();
notify(round, "aendrung_task", {});
reset(round);
game.task = task;
// game.world_clear();
notify(game, "change_task", {});
reset(game);
}
@ -184,11 +184,11 @@ module mod_vtm
*/
export function world_read
(
round : type_round
game : type_game
)
: mod_world.type_world
{
return round.world;
return game.world;
}
@ -197,16 +197,16 @@ module mod_vtm
*/
export function world_set
(
round : type_round,
game : type_game,
world : mod_world.type_world,
inform : boolean = true
)
: void
{
round.world = world;
game.world = world;
if (inform)
{
notify(round, "aendrung_world", {});
notify(game, "change_world", {});
}
else
{
@ -220,15 +220,15 @@ module mod_vtm
*/
export function world_clear
(
round : type_round,
game : type_game,
inform : boolean = true
)
: void
{
round.world = mod_world.blanko();
game.world = mod_world.blanko();
if (inform)
{
notify(round, "aendrung_world", {});
notify(game, "change_world", {});
}
else
{
@ -242,11 +242,11 @@ module mod_vtm
*/
export function token_read
(
round : type_round
game : type_game
)
: lib_errormonade.type_errormonade<mod_token.type_token>
{
return round.token;
return game.token;
}
@ -255,11 +255,11 @@ module mod_vtm
*/
export function mode_read
(
round : type_round
game : type_game
)
: mod_mode.type_mode
{
return round.mode;
return game.mode;
}
@ -268,30 +268,30 @@ module mod_vtm
*/
export function world_tile_wechseln
(
round : type_round,
game : type_game,
spot : mod_spot.type_spot,
umgekehrt : boolean = false
)
: void
{
if (! (round.mode === mod_mode.initial))
if (! (game.mode === mod_mode.initial))
{
let message : string = "gesperrt";
}
else
{
mod_world.tile_wechseln(round.world, spot, umgekehrt);
mod_world.tile_wechseln(game.world, spot, umgekehrt);
notify
(
round,
"aendrung_world",
game,
"change_world",
{
"kind": "tile_wechseln",
"data":
{
"spot": spot,
"umgekehrt": umgekehrt,
"tile": mod_world.tile_get(round.world, spot),
"tile": mod_world.tile_get(game.world, spot),
}
}
)
@ -305,20 +305,20 @@ module mod_vtm
*/
export function world_tile_rotate
(
round : type_round,
game : type_game,
spot : mod_spot.type_spot,
inkrement : int = +1
)
: void
{
if (! (round.mode === mod_mode.initial))
if (! (game.mode === mod_mode.initial))
{
let message : string = "gesperrt";
}
else
{
mod_world.tile_rotate(round.world, spot, inkrement);
notify(round, "aendrung_world", {});
mod_world.tile_rotate(game.world, spot, inkrement);
notify(game, "change_world", {});
}
}
@ -328,27 +328,27 @@ module mod_vtm
*/
export function resume
(
round : type_round
game : type_game
)
: void
{
switch (round.mode)
switch (game.mode)
{
case mod_mode.initial:
{
round.mode = mod_mode.uncertain;
round.testindex = (lib_errormonade.create_just<int>(0));
notify(round, "aendrung_mode", {});
game.mode = mod_mode.uncertain;
game.testindex = (lib_errormonade.create_just<int>(0));
notify(game, "change_mode", {});
break;
}
case mod_mode.uncertain:
{
if (! lib_errormonade.filled<mod_token.type_token>(round.token))
if (! lib_errormonade.filled<mod_token.type_token>(game.token))
{
let test : mod_test.type_test = mod_task.tests(round.task)[lib_errormonade.read<int>(round.testindex)];
let test : mod_test.type_test = mod_task.tests(game.task)[lib_errormonade.read<int>(game.testindex)];
let tape : Array<mod_symbol.type_symbol> = mod_vtm.mod_helfer.list_copy<mod_symbol.type_symbol>(mod_test.input(test));
let spot : mod_spot.type_spot = mod_world.erzeuger_finden(round.world);
round.token = (
let spot : mod_spot.type_spot = mod_world.generator_finden(game.world);
game.token = (
lib_errormonade.create_just<mod_token.type_token>
(
mod_token.create
@ -361,13 +361,13 @@ module mod_vtm
}
else
{
let token : mod_token.type_token = lib_errormonade.read<mod_token.type_token>(round.token);
let token : mod_token.type_token = lib_errormonade.read<mod_token.type_token>(game.token);
let spot : mod_spot.type_spot = mod_token.spot_read(token);
let actuator_ : lib_errormonade.type_errormonade<mod_actuator.type_actuator> = mod_world.tile_get(round.world, spot);
let actuator_ : lib_errormonade.type_errormonade<mod_actuator.type_actuator> = mod_world.tile_get(game.world, spot);
let actuator : mod_actuator.type_actuator = (
lib_errormonade.filled<mod_actuator.type_actuator>(actuator_)
? lib_errormonade.read<mod_actuator.type_actuator>(actuator_)
: mod_actuator.mod_verwerfer.create_actuator()
: mod_actuator.mod_rejector.create_extended()
);
mod_actuator.use(actuator, token);
let state : mod_state.type_state = mod_token.state_read(token);
@ -379,14 +379,14 @@ module mod_vtm
{
let accepted : boolean = (state === mod_state.accepted);
let ausgabe : Array<mod_symbol.type_symbol> = mod_token.tape_read(token);
round.token = (lib_errormonade.create_nothing<mod_token.type_token>());
let testindex : int = lib_errormonade.read<int>(round.testindex);
let tests : Array<mod_test.type_test> = mod_task.tests(round.task);
game.token = (lib_errormonade.create_nothing<mod_token.type_token>());
let testindex : int = lib_errormonade.read<int>(game.testindex);
let tests : Array<mod_test.type_test> = mod_task.tests(game.task);
let test : mod_test.type_test = tests[testindex];
if (! mod_test.pruefen(test, accepted, ausgabe))
{
round.mode = mod_mode.wrong;
notify(round, "aendrung_mode", {});
game.mode = mod_mode.wrong;
notify(game, "change_mode", {});
}
else
{
@ -394,14 +394,14 @@ module mod_vtm
if (testindex < tests.length)
{
// nächsten Test auswählen
round.testindex = (lib_errormonade.create_just<int>(testindex));
game.testindex = (lib_errormonade.create_just<int>(testindex));
}
else
{
// auf Modus "correct" wechseln
round.testindex = (lib_errormonade.create_nothing<int>());
round.mode = mod_mode.correct;
notify(round, "aendrung_mode", {});
game.testindex = (lib_errormonade.create_nothing<int>());
game.mode = mod_mode.correct;
notify(game, "change_mode", {});
}
}
}
@ -411,7 +411,7 @@ module mod_vtm
throw (new Error(message));
}
}
notify(round, "aendrung_token", {});
notify(game, "change_token", {});
break;
}
case mod_mode.wrong:

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -43,7 +43,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function von_hash(hash : string) : type_spot
export function from_hash(hash : string) : type_spot
{
let teile : Array<string> = hash.split("_");
return {"u": parseInt(teile[0]), "v": parseInt(teile[1])};
@ -62,7 +62,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function von_direction(direction : mod_direction.type_direction) : type_spot
export function from_direction(direction : mod_direction.type_direction) : type_spot
{
switch (direction)
{
@ -100,7 +100,7 @@ module mod_vtm
*/
export function import_(spot_ : string) : type_spot
{
return von_hash(spot_);
return from_hash(spot_);
}
}

View file

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

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -31,7 +31,7 @@ module mod_vtm
export type type_acceptortask =
{
id : string;
titel : string;
title : string;
text : string;
tests : Array<mod_acceptortest.type_acceptortest>;
}
@ -44,7 +44,7 @@ module mod_vtm
export function create
(
id : string,
titel : string,
title : string,
text : string,
tests : Array<mod_acceptortest.type_acceptortest>
)
@ -52,7 +52,7 @@ module mod_vtm
{
return {
"id": id,
"titel": titel,
"title": title,
"text": text,
"tests": tests,
};
@ -75,13 +75,13 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function titel
export function title
(
acceptortask : type_acceptortask
)
: string
{
return acceptortask.titel;
return acceptortask.title;
}

View file

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

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -52,7 +52,7 @@ module mod_vtm
task,
{
"acceptortask": (data) => mod_acceptortask.id(data),
"transductortask": (data) => mod_transductortask.id(data),
"transducertask": (data) => mod_transducertask.id(data),
}
)
);
@ -62,7 +62,7 @@ module mod_vtm
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function titel
export function title
(
task : type_task
)
@ -73,8 +73,8 @@ module mod_vtm
(
task,
{
"acceptortask": (data) => mod_acceptortask.titel(data),
"transductortask": (data) => mod_transductortask.titel(data),
"acceptortask": (data) => mod_acceptortask.title(data),
"transducertask": (data) => mod_transducertask.title(data),
}
)
);
@ -96,7 +96,7 @@ module mod_vtm
task,
{
"acceptortask": (data) => mod_acceptortask.text(data),
"transductortask": (data) => mod_transductortask.text(data),
"transducertask": (data) => mod_transducertask.text(data),
}
)
);
@ -121,9 +121,9 @@ module mod_vtm
mod_acceptortask.tests(data)
.map(data_ => ({"kind": "acceptortest", "data": data_}))
),
"transductortask": (data) => (
mod_transductortask.tests(data)
.map(data_ => ({"kind": "transductortest", "data": data_}))
"transducertask": (data) => (
mod_transducertask.tests(data)
.map(data_ => ({"kind": "transducertest", "data": data_}))
),
}
)
@ -146,8 +146,8 @@ module mod_vtm
mod_acceptortask.create
(
task_raw["id"],
task_raw["parameter"]["titel"],
task_raw["parameter"]["text"],
lib_translate.get(["tasks", task_raw["id"], "title"].join(".")),
lib_translate.get(["tasks", task_raw["id"], "text"].join(".")),
task_raw["parameter"]["tests"].map
(
test_raw => (
@ -163,20 +163,20 @@ module mod_vtm
};
break;
}
case "transductor":
case "transducer":
{
return {
"kind": "transductortask",
"kind": "transducertask",
"data": (
mod_transductortask.create
mod_transducertask.create
(
task_raw["id"],
task_raw["parameter"]["titel"],
task_raw["parameter"]["text"],
lib_translate.get(["tasks", task_raw["id"], "title"].join(".")),
lib_translate.get(["tasks", task_raw["id"], "text"].join(".")),
task_raw["parameter"]["tests"].map
(
test_raw => (
mod_transductortest.create
mod_transducertest.create
(
test_raw["input"],
test_raw["output"]

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -46,7 +46,7 @@ module mod_vtm
test,
{
"acceptortest": (data) => mod_acceptortest.input(data),
"transductortest": (data) => mod_transductortest.input(data),
"transducertest": (data) => mod_transducertest.input(data),
}
)
);
@ -70,7 +70,7 @@ module mod_vtm
test,
{
"acceptortest": (data) => mod_acceptortest.pruefen(data, accepted, ausgabe),
"transductortest": (data) => mod_transductortest.pruefen(data, accepted, ausgabe),
"transducertest": (data) => mod_transducertest.pruefen(data, accepted, ausgabe),
}
)
);
@ -102,12 +102,12 @@ module mod_vtm
};
break;
}
case "transductortest":
case "transducertest":
{
return {
"kind": "transductortest",
"kind": "transducertest",
"data": (
mod_transductortest.create
mod_transducertest.create
(
test_raw["data"]["input"],
test_raw["data"]["output"]

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -22,18 +22,18 @@ module mod_vtm
export module mod_model
{
export module mod_transductortask
export module mod_transducertask
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_transductortask =
export type type_transducertask =
{
id : string;
titel : string;
title : string;
text : string;
tests : Array<mod_transductortest.type_transductortest>;
tests : Array<mod_transducertest.type_transducertest>;
}
;
@ -44,15 +44,15 @@ module mod_vtm
export function create
(
id : string,
titel : string,
title : string,
text : string,
tests : Array<mod_transductortest.type_transductortest>
tests : Array<mod_transducertest.type_transducertest>
)
: type_transductortask
: type_transducertask
{
return {
"id": id,
"titel": titel,
"title": title,
"text": text,
"tests": tests,
};
@ -64,24 +64,24 @@ module mod_vtm
*/
export function id
(
transductortask : type_transductortask
transducertask : type_transducertask
)
: string
{
return transductortask.id;
return transducertask.id;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function titel
export function title
(
transductortask : type_transductortask
transducertask : type_transducertask
)
: string
{
return transductortask.titel;
return transducertask.title;
}
@ -90,11 +90,11 @@ module mod_vtm
*/
export function text
(
transductortask : type_transductortask
transducertask : type_transducertask
)
: string
{
return transductortask.text;
return transducertask.text;
}
@ -103,11 +103,11 @@ module mod_vtm
*/
export function tests
(
transductortask : type_transductortask
transducertask : type_transducertask
)
: Array<mod_transductortest.type_transductortest>
: Array<mod_transducertest.type_transducertest>
{
return transductortask.tests;
return transducertask.tests;
}
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -22,13 +22,13 @@ module mod_vtm
export module mod_model
{
export module mod_transductortest
export module mod_transducertest
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_transductortest =
export type type_transducertest =
{
input : Array<mod_vtm.mod_model.mod_symbol.type_symbol>;
output : Array<mod_vtm.mod_model.mod_symbol.type_symbol>;
@ -44,7 +44,7 @@ module mod_vtm
input : Array<mod_vtm.mod_model.mod_symbol.type_symbol>,
output : Array<mod_vtm.mod_model.mod_symbol.type_symbol>
)
: type_transductortest
: type_transducertest
{
return {
"input": input,
@ -58,11 +58,11 @@ module mod_vtm
*/
export function input
(
transductortest : type_transductortest
transducertest : type_transducertest
)
: Array<mod_vtm.mod_model.mod_symbol.type_symbol>
{
return transductortest.input;
return transducertest.input;
}
@ -71,22 +71,22 @@ module mod_vtm
*/
export function pruefen
(
transductortest : type_transductortest,
transducertest : type_transducertest,
accepted : boolean,
output : Array<mod_vtm.mod_model.mod_symbol.type_symbol>
)
: boolean
{
if (transductortest.output.length !== output.length)
if (transducertest.output.length !== output.length)
{
return false;
}
else
{
let gleich : boolean = true;
for (let index : int = 0; index < transductortest.output.length; index += 1)
for (let index : int = 0; index < transducertest.output.length; index += 1)
{
if (! mod_vtm.mod_model.mod_symbol.vergleichen(transductortest.output[index], output[index]))
if (! mod_vtm.mod_model.mod_symbol.vergleichen(transducertest.output[index], output[index]))
{
gleich = false;
break;

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -104,7 +104,7 @@ module mod_vtm
)
: void
{
let summand : mod_spot.type_spot = mod_spot.von_direction(direction);
let summand : mod_spot.type_spot = mod_spot.from_direction(direction);
token.spot = mod_spot.add(token.spot, summand);
}

View file

@ -1,6 +1,6 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* Copyright (C) 2016-2018 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
@ -110,29 +110,29 @@ module mod_vtm
)
: void
{
let erweitert : boolean = true;
let extended : boolean = true;
let liste : Array<{pruefer : (actuator : mod_actuator.type_actuator)=>boolean; erspotr : ()=>mod_actuator.type_actuator;}> = (
[]
.concat
(
[
{
"pruefer": (actuator) => (actuator.kind === "befoerderer"),
"erspotr": () => mod_actuator.mod_befoerderer.create_actuator(0),
"pruefer": (actuator) => (actuator.kind === "conveyer"),
"erspotr": () => mod_actuator.mod_conveyer.create_extended(0),
},
]
)
.concat
(
mod_vtm.mod_helfer.sequence(erweitert ? 4 : 2).map
mod_vtm.mod_helfer.sequence(extended ? 4 : 2).map
(
symbol => (
{
"pruefer": (actuator) =>
{
if (actuator.kind === "schreiber")
if (actuator.kind === "writer")
{
return (mod_actuator.mod_schreiber.symbol_read(actuator.data) === symbol);
return (mod_actuator.mod_writer.symbol_read(actuator.data) === symbol);
}
else
{
@ -140,14 +140,14 @@ module mod_vtm
}
}
,
"erspotr": () => mod_actuator.mod_schreiber.create_actuator(0, symbol)
"erspotr": () => mod_actuator.mod_writer.create_extended(0, symbol)
}
)
)
)
.concat
(
mod_vtm.mod_helfer.sequence(erweitert ? 2 : 1).map
mod_vtm.mod_helfer.sequence(extended ? 2 : 1).map
(
index =>
{
@ -157,12 +157,12 @@ module mod_vtm
{
"pruefer": (actuator) =>
{
if (actuator.kind === "leser")
if (actuator.kind === "reader")
{
return (
(mod_actuator.mod_leser.symbol_links_read(actuator.data) === symbol_links)
(mod_actuator.mod_reader.symbol_links_read(actuator.data) === symbol_links)
&&
(mod_actuator.mod_leser.symbol_rechts_read(actuator.data) === symbol_rechts)
(mod_actuator.mod_reader.symbol_rechts_read(actuator.data) === symbol_rechts)
);
}
else
@ -171,7 +171,7 @@ module mod_vtm
}
}
,
"erspotr": () => mod_actuator.mod_leser.create_actuator(0, symbol_links, symbol_rechts)
"erspotr": () => mod_actuator.mod_reader.create_extended(0, symbol_links, symbol_rechts)
}
);
}
@ -181,8 +181,8 @@ module mod_vtm
(
[
{
"pruefer": (actuator) => (actuator.kind === "verwerfer"),
"erspotr": () => mod_actuator.mod_verwerfer.create_actuator(),
"pruefer": (actuator) => (actuator.kind === "rejector"),
"erspotr": () => mod_actuator.mod_rejector.create_extended(),
},
]
)
@ -266,7 +266,7 @@ module mod_vtm
* @author kcf <vidofnir@folksprak.org>
* @throws {Error}
*/
export function erzeuger_finden
export function generator_finden
(
world : type_world
)
@ -278,7 +278,7 @@ module mod_vtm
world.tiles,
(spot_, actuator) =>
{
if (actuator.kind === "erzeuger")
if (actuator.kind === "generator")
{
if (lib_errormonade.filled<mod_spot.type_spot>(spot))
{
@ -325,15 +325,15 @@ module mod_vtm
let actuator : mod_actuator.type_actuator;
if ((u === -groesse) && (v === 0))
{
actuator = mod_actuator.mod_erzeuger.create_actuator(0);
actuator = mod_actuator.mod_generator.create_extended(0);
}
else if ((u === +groesse) && (v === 0))
{
actuator = mod_actuator.mod_annehmer.create_actuator();
actuator = mod_actuator.mod_acceptor.create_extended();
}
else
{
actuator = mod_actuator.mod_verwerfer.create_actuator();
actuator = mod_actuator.mod_rejector.create_extended();
}
lib_hashmap.set(world.tiles, spot, actuator);
}