Compare commits

..

No commits in common. "745cd50236bf25b345800b9186fcf649675e7867" and "6dca386ce6c1d5a81671e3f1f2d2f8422a1a165e" have entirely different histories.

97 changed files with 5094 additions and 6101 deletions

4
.gitignore vendored
View file

@ -1,3 +1 @@
build/ erzeugnis
/.geany

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

55
hilfe.md Normal file
View file

@ -0,0 +1,55 @@
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.

View file

@ -1,693 +0,0 @@
Verrückte Turing-Maschinen — A turing complete game
Copyright (C) 2016-2018 kcf <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/>.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

96
makefile Normal file
View file

@ -0,0 +1,96 @@
cmd_md := mkdir -p
cmd_rm := rm -rf
cmd_echo := echo # -e
cmd_cp := cp -ruv
cmd_cat := cat
cmd_tsc := tsc --allowUnreachableCode
cmd_sass := sass
dir_quelldatein := quelldatein
dir_erzeugnis := erzeugnis
all: \
${dir_erzeugnis}/vtm.html \
${dir_erzeugnis}/vtm.css \
${dir_erzeugnis}/vtm.dat.js \
${dir_erzeugnis}/vtm.js
.PHONY: all
clear:
@ ${cmd_echo} "-- zurücksetzen …"
@ ${cmd_rm} ${dir_erzeugnis}
.PHONY: clear
${dir_erzeugnis}/vtm.html: \
${dir_quelldatein}/manifestation/web/vtm.html
@ ${cmd_echo} "-- Struktur …"
@ ${cmd_md} ${dir_erzeugnis}
@ ${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}
@ ${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}
@ ${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}
@ ${cmd_tsc} $^ --outFile $@

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,31 +16,31 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_actuator export module mod_aktor
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_actuator = lib_call.type_complex<any>; export type typ_aktor = lib_aufruf.typ_komplex<any>;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type signature_actuator = export type signatur_aktor =
{ {
example : ()=>type_actuator; beispiel : ()=>typ_aktor;
rotate : (actuator : type_actuator, increment : int)=>void; drehen : (aktor : typ_aktor, inkrement : int)=>void;
use : (actuator : type_actuator, token : mod_token.type_token)=>void; verwenden : (aktor : typ_aktor, figur : mod_figur.typ_figur)=>void;
export : (actuator : type_actuator)=>any; exportieren : (aktor : typ_aktor)=>any;
import : (raw : any)=>type_actuator; importieren : (roh : any)=>typ_aktor;
} }
; ;
@ -48,16 +48,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export var trait_actuator : lib_trait.type_trait<signature_actuator> = lib_trait.create<signature_actuator>(); export var brauch_aktor : lib_brauch.typ_brauch<signatur_aktor> = lib_brauch.erstellen<signatur_aktor>();
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
/* /*
export function create(kind : string, kern : any) : type_actuator export function erstellen(art : string, kern : any) : typ_aktor
{ {
return lib_call.wrap(kind, kern); return lib_aufruf.einpacken(art, kern);
} }
*/ */
@ -65,45 +65,45 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function example(kind : string) : type_actuator export function beispiel(art : string) : typ_aktor
{ {
return lib_trait.deploy(trait_actuator, kind)["example"](); return lib_brauch.anwenden(brauch_aktor, art)["beispiel"]();
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function rotate(actuator : type_actuator, increment ?: int) : void export function drehen(aktor : typ_aktor, inkrement ?: int) : void
{ {
return lib_trait.deploy(trait_actuator, actuator.kind)["rotate"](actuator, increment); return lib_brauch.anwenden(brauch_aktor, aktor.art)["drehen"](aktor, inkrement);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function use(actuator : type_actuator, token : mod_token.type_token) : void export function verwenden(aktor : typ_aktor, figur : mod_figur.typ_figur) : void
{ {
return lib_trait.deploy(trait_actuator, actuator.kind)["use"](actuator, token); return lib_brauch.anwenden(brauch_aktor, aktor.art)["verwenden"](aktor, figur);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function export_(actuator : type_actuator) : any export function exportieren(aktor : typ_aktor) : any
{ {
return lib_trait.deploy(trait_actuator, actuator.kind)["export"](actuator); return lib_brauch.anwenden(brauch_aktor, aktor.art)["exportieren"](aktor);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function import_(raw : any) : type_actuator export function importieren(roh : any) : typ_aktor
{ {
return lib_trait.deploy(trait_actuator, raw.kind)["import"](raw); return lib_brauch.anwenden(brauch_aktor, roh.art)["importieren"](roh);
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,28 +16,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_actuator export module mod_aktor
{ {
export namespace mod_acceptor export module mod_annehmer
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
const kind : string = "acceptor"; let art : string = "annehmer";
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_acceptor = export type typ_annehmer =
{ {
} }
; ;
@ -46,10 +46,10 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function create function erstellen
( (
) )
: type_acceptor : typ_annehmer
{ {
return { return {
}; };
@ -59,34 +59,34 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_extended export function erstellen_aktor
( (
) )
: mod_actuator.type_actuator : mod_aktor.typ_aktor
{ {
return lib_call.wrap(kind, create()); return lib_aufruf.einpacken(art, erstellen());
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function example function beispiel
( (
) )
: type_acceptor : typ_annehmer
{ {
return create(); return erstellen();
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function rotate function drehen
( (
acceptor : type_acceptor, annehmer : typ_annehmer,
increment ?: int inkrement ?: int
) )
: void : void
{ {
@ -96,23 +96,23 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function use function verwenden
( (
acceptor : type_acceptor, annehmer : typ_annehmer,
token : mod_token.type_token figur : mod_figur.typ_figur
) )
: void : void
{ {
mod_token.accept(token); mod_figur.annehmen(figur);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function export_ function exportieren
( (
acceptor : type_acceptor annehmer : typ_annehmer
) )
: any : any
{ {
@ -124,14 +124,14 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function import_ function importieren
( (
raw : any roh : any
) )
: type_acceptor : typ_annehmer
{ {
return ( return (
create erstellen
( (
) )
); );
@ -141,16 +141,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend<signature_actuator> lib_brauch.umsetzen<signatur_aktor>
( (
trait_actuator, brauch_aktor,
kind, art,
{ {
"example": () => lib_call.wrap(kind, example()), "beispiel": () => lib_aufruf.einpacken(art, beispiel()),
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment), "drehen": (aktor, inkrement) => drehen(lib_aufruf.auspacken(aktor), inkrement),
"use": (actuator, token) => use(lib_call.unwrap(actuator), token), "verwenden": (aktor, figur) => verwenden(lib_aufruf.auspacken(aktor), figur),
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}), "exportieren": (aktor) => ({"art": art, "angaben": exportieren(aktor.angaben)}),
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])), "importieren": (roh) => lib_aufruf.einpacken(art, importieren(roh["angaben"])),
} }
) )
; ;

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,30 +16,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_actuator export module mod_aktor
{ {
export namespace mod_conveyer export module mod_befoerderer
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
const kind : string = "conveyer"; let art : string = "befoerderer";
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_conveyer = export type typ_befoerderer =
{ {
direction : mod_direction.type_direction; richtung : mod_richtung.typ_richtung;
} }
; ;
@ -47,14 +47,14 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function create function erstellen
( (
direction : mod_direction.type_direction richtung : mod_richtung.typ_richtung
) )
: type_conveyer : typ_befoerderer
{ {
return { return {
"direction": direction, "richtung": richtung,
}; };
} }
@ -62,80 +62,80 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_extended export function erstellen_aktor
( (
direction : mod_direction.type_direction richtung : mod_richtung.typ_richtung
) )
: mod_actuator.type_actuator : mod_aktor.typ_aktor
{ {
return lib_call.wrap(kind, create(direction)); return lib_aufruf.einpacken(art, erstellen(richtung));
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function example function beispiel
( (
) )
: type_conveyer : typ_befoerderer
{ {
return create(0); return erstellen(0);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function direction_read export function richtung_lesen
( (
conveyer : type_conveyer befoerderer : typ_befoerderer
) )
: mod_direction.type_direction : mod_richtung.typ_richtung
{ {
return conveyer.direction; return befoerderer.richtung;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function rotate function drehen
( (
conveyer : type_conveyer, befoerderer : typ_befoerderer,
increment : int = +1 inkrement : int = +1
) )
: void : void
{ {
conveyer.direction = mod_direction.add(conveyer.direction, increment); befoerderer.richtung = mod_richtung.addieren(befoerderer.richtung, inkrement);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function use function verwenden
( (
conveyer : type_conveyer, befoerderer : typ_befoerderer,
token : mod_token.type_token figur : mod_figur.typ_figur
) )
: void : void
{ {
mod_token.move(token, conveyer.direction); mod_figur.bewegen(figur, befoerderer.richtung);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function export_ function exportieren
( (
conveyer : type_conveyer befoerderer : typ_befoerderer
) )
: any : any
{ {
return { return {
"direction": mod_direction.export_(conveyer.direction), "richtung": mod_richtung.exportieren(befoerderer.richtung),
}; };
} }
@ -143,16 +143,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function import_ function importieren
( (
conveyer_ : any befoerderer_ : any
) )
: type_conveyer : typ_befoerderer
{ {
return ( return (
create erstellen
( (
mod_direction.import_(conveyer_["direction"]) mod_richtung.importieren(befoerderer_["richtung"])
) )
); );
} }
@ -161,16 +161,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend<signature_actuator> lib_brauch.umsetzen<signatur_aktor>
( (
trait_actuator, brauch_aktor,
kind, art,
{ {
"example": () => lib_call.wrap(kind, example()), "beispiel": () => lib_aufruf.einpacken(art, beispiel()),
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment), "drehen": (aktor, inkrement) => drehen(lib_aufruf.auspacken(aktor), inkrement),
"use": (actuator, token) => use(lib_call.unwrap(actuator), token), "verwenden": (aktor, figur) => verwenden(lib_aufruf.auspacken(aktor), figur),
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}), "exportieren": (aktor) => ({"art": art, "angaben": exportieren(aktor.angaben)}),
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])), "importieren": (roh) => lib_aufruf.einpacken(art, importieren(roh["angaben"])),
} }
) )
; ;

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,30 +16,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_actuator export module mod_aktor
{ {
export namespace mod_generator export module mod_erzeuger
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
const kind : string = "generator"; let art : string = "erzeuger";
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_generator = export type typ_erzeuger =
{ {
direction : mod_direction.type_direction; richtung : mod_richtung.typ_richtung;
} }
; ;
@ -47,14 +47,14 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function create function erstellen
( (
direction : mod_direction.type_direction richtung : mod_richtung.typ_richtung
) )
: type_generator : typ_erzeuger
{ {
return { return {
"direction": direction, "richtung": richtung,
}; };
} }
@ -62,80 +62,80 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_extended export function erstellen_aktor
( (
direction : mod_direction.type_direction richtung : mod_richtung.typ_richtung
) )
: mod_actuator.type_actuator : mod_aktor.typ_aktor
{ {
return lib_call.wrap(kind, create(direction)); return lib_aufruf.einpacken(art, erstellen(richtung));
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function example function beispiel
( (
) )
: type_generator : typ_erzeuger
{ {
return create(0); return erstellen(0);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function direction_read export function richtung_lesen
( (
generator : type_generator erzeuger : typ_erzeuger
) )
: mod_direction.type_direction : mod_richtung.typ_richtung
{ {
return generator.direction; return erzeuger.richtung;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function rotate function drehen
( (
generator : type_generator, erzeuger : typ_erzeuger,
increment : int = +1 inkrement : int = +1
) )
: void : void
{ {
generator.direction = mod_direction.add(generator.direction, increment); erzeuger.richtung = mod_richtung.addieren(erzeuger.richtung, inkrement);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function use function verwenden
( (
generator : type_generator, erzeuger : typ_erzeuger,
token : mod_token.type_token figur : mod_figur.typ_figur
) )
: void : void
{ {
mod_token.move(token, generator.direction); mod_figur.bewegen(figur, erzeuger.richtung);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function export_ function exportieren
( (
generator : type_generator erzeuger : typ_erzeuger
) )
: any : any
{ {
return { return {
"direction": mod_direction.export_(generator.direction), "richtung": mod_richtung.exportieren(erzeuger.richtung),
}; };
} }
@ -143,16 +143,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function import_ function importieren
( (
raw : any roh : any
) )
: type_generator : typ_erzeuger
{ {
return ( return (
create erstellen
( (
mod_direction.import_(raw["direction"]) mod_richtung.importieren(roh["richtung"])
) )
); );
} }
@ -161,16 +161,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend<signature_actuator> lib_brauch.umsetzen<signatur_aktor>
( (
trait_actuator, brauch_aktor,
kind, art,
{ {
"example": () => lib_call.wrap(kind, example()), "beispiel": () => lib_aufruf.einpacken(art, beispiel()),
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment), "drehen": (aktor, inkrement) => drehen(lib_aufruf.auspacken(aktor), inkrement),
"use": (actuator, token) => use(lib_call.unwrap(actuator), token), "verwenden": (aktor, figur) => verwenden(lib_aufruf.auspacken(aktor), figur),
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}), "exportieren": (aktor) => ({"art": art, "angaben": exportieren(aktor.angaben)}),
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])), "importieren": (roh) => lib_aufruf.einpacken(art, importieren(roh["angaben"])),
} }
) )
; ;

View file

@ -0,0 +1,248 @@
/*
* 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_aufbau
{
export module mod_aktor
{
export module mod_leser
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
let art : string = "leser";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_leser =
{
"richtung": mod_richtung.typ_richtung,
"symbol_links": mod_symbol.typ_symbol,
"symbol_rechts": mod_symbol.typ_symbol,
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen
(
richtung : mod_richtung.typ_richtung,
symbol_links : mod_symbol.typ_symbol,
symbol_rechts : mod_symbol.typ_symbol
)
: typ_leser
{
return {
"richtung": richtung,
"symbol_links": symbol_links,
"symbol_rechts": symbol_rechts,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_aktor
(
richtung : mod_richtung.typ_richtung,
symbol_links : mod_symbol.typ_symbol,
symbol_rechts : mod_symbol.typ_symbol
)
: mod_aktor.typ_aktor
{
return lib_aufruf.einpacken(art, erstellen(richtung, symbol_links, symbol_rechts));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function beispiel
(
)
: typ_leser
{
return erstellen(0, 0, 1);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function richtung_lesen
(
leser : typ_leser
)
: mod_richtung.typ_richtung
{
return leser.richtung;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function symbol_links_lesen
(
leser : typ_leser
)
: mod_symbol.typ_symbol
{
return leser.symbol_links;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function symbol_rechts_lesen
(
leser : typ_leser
)
: mod_symbol.typ_symbol
{
return leser.symbol_rechts;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function drehen
(
leser : typ_leser,
inkrement : int = +1
)
: void
{
leser.richtung = mod_richtung.addieren(leser.richtung, inkrement);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function verwenden
(
leser : typ_leser,
figur : mod_figur.typ_figur
)
: void
{
let symbol_ : lib_fehlermonade.typ_fehlermonade<mod_symbol.typ_symbol> = mod_figur.lesen(figur);
let summand : mod_richtung.typ_richtung;
if (lib_fehlermonade.voll(symbol_))
{
let symbol : mod_symbol.typ_symbol = lib_fehlermonade.lesen(symbol_);
if (symbol === leser.symbol_links)
{
mod_figur.schieben(figur);
summand = +2;
}
else if (symbol === leser.symbol_rechts)
{
mod_figur.schieben(figur);
summand = -2;
}
else
{
summand = 0;
}
}
else
{
summand = 0;
}
let richtung : mod_richtung.typ_richtung = mod_richtung.addieren(leser.richtung, summand);
mod_figur.bewegen(figur, richtung);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function exportieren
(
leser : typ_leser
)
: any
{
return {
"richtung": mod_richtung.exportieren(leser.richtung),
"symbol_links": mod_symbol.exportieren(leser.symbol_links),
"symbol_rechts": mod_symbol.exportieren(leser.symbol_rechts),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function importieren
(
roh : any
)
: typ_leser
{
return (
erstellen
(
mod_richtung.importieren(roh["richtung"]),
mod_symbol.importieren(roh["symbol_links"]),
mod_symbol.importieren(roh["symbol_rechts"])
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_aktor>
(
brauch_aktor,
art,
{
"beispiel": () => lib_aufruf.einpacken(art, beispiel()),
"drehen": (aktor, inkrement) => drehen(lib_aufruf.auspacken(aktor), inkrement),
"verwenden": (aktor, figur) => verwenden(lib_aufruf.auspacken(aktor), figur),
"exportieren": (aktor) => ({"art": art, "angaben": exportieren(aktor.angaben)}),
"importieren": (roh) => lib_aufruf.einpacken(art, importieren(roh["angaben"])),
}
)
;
}
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,31 +16,31 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_actuator export module mod_aktor
{ {
export namespace mod_writer export module mod_schreiber
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
const kind : string = "writer"; let art : string = "schreiber";
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_writer = export type typ_schreiber =
{ {
direction : mod_direction.type_direction; richtung : mod_richtung.typ_richtung;
symbol : mod_symbol.type_symbol; symbol : mod_symbol.typ_symbol;
} }
; ;
@ -48,15 +48,15 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function create function erstellen
( (
direction : mod_direction.type_direction, richtung : mod_richtung.typ_richtung,
symbol : mod_symbol.type_symbol symbol : mod_symbol.typ_symbol
) )
: type_writer : typ_schreiber
{ {
return { return {
"direction": direction, "richtung": richtung,
"symbol": symbol, "symbol": symbol,
}; };
} }
@ -65,96 +65,96 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_extended export function erstellen_aktor
( (
direction : mod_direction.type_direction, richtung : mod_richtung.typ_richtung,
symbol : mod_symbol.type_symbol symbol : mod_symbol.typ_symbol
) )
: mod_actuator.type_actuator : mod_aktor.typ_aktor
{ {
return lib_call.wrap(kind, create(direction, symbol)); return lib_aufruf.einpacken(art, erstellen(richtung, symbol));
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function example function beispiel
( (
) )
: type_writer : typ_schreiber
{ {
return create(0, 0); return erstellen(0, 0);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function direction_read export function richtung_lesen
( (
writer : type_writer schreiber : typ_schreiber
) )
: mod_direction.type_direction : mod_richtung.typ_richtung
{ {
return writer.direction; return schreiber.richtung;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function symbol_read export function symbol_lesen
( (
writer : type_writer schreiber : typ_schreiber
) )
: mod_symbol.type_symbol : mod_symbol.typ_symbol
{ {
return writer.symbol; return schreiber.symbol;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function rotate function drehen
( (
writer : type_writer, schreiber : typ_schreiber,
increment : int = +1 inkrement : int = +1
) )
: void : void
{ {
writer.direction = mod_direction.add(writer.direction, increment); schreiber.richtung = mod_richtung.addieren(schreiber.richtung, inkrement);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function use function verwenden
( (
writer : type_writer, schreiber : typ_schreiber,
token : mod_token.type_token figur : mod_figur.typ_figur
) )
: void : void
{ {
mod_token.write(token, writer.symbol); mod_figur.schreiben(figur, schreiber.symbol);
mod_token.move(token, writer.direction); mod_figur.bewegen(figur, schreiber.richtung);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function export_ function exportieren
( (
writer : type_writer schreiber : typ_schreiber
) )
: any : any
{ {
return { return {
"direction": mod_direction.export_(writer.direction), "richtung": mod_richtung.exportieren(schreiber.richtung),
"symbol": mod_symbol.export_(writer.symbol), "symbol": mod_symbol.exportieren(schreiber.symbol),
}; };
} }
@ -162,17 +162,17 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function import_ function importieren
( (
raw : any roh : any
) )
: type_writer : typ_schreiber
{ {
return ( return (
create erstellen
( (
mod_direction.import_(raw["direction"]), mod_richtung.importieren(roh["richtung"]),
mod_symbol.import_(raw["symbol"]) mod_symbol.importieren(roh["symbol"])
) )
); );
} }
@ -181,16 +181,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend<signature_actuator> lib_brauch.umsetzen<signatur_aktor>
( (
trait_actuator, brauch_aktor,
kind, art,
{ {
"example": () => lib_call.wrap(kind, example()), "beispiel": () => lib_aufruf.einpacken(art, beispiel()),
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment), "drehen": (aktor, inkrement) => drehen(lib_aufruf.auspacken(aktor), inkrement),
"use": (actuator, token) => use(lib_call.unwrap(actuator), token), "verwenden": (aktor, figur) => verwenden(lib_aufruf.auspacken(aktor), figur),
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}), "exportieren": (aktor) => ({"art": art, "angaben": exportieren(aktor.angaben)}),
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])), "importieren": (roh) => lib_aufruf.einpacken(art, importieren(roh["angaben"])),
} }
) )
; ;

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,28 +16,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_actuator export module mod_aktor
{ {
export namespace mod_rejector export module mod_verwerfer
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
const kind : string = "rejector"; let art : string = "verwerfer";
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_rejector = export type typ_verwerfer =
{ {
} }
; ;
@ -46,10 +46,10 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function create function erstellen
( (
) )
: type_rejector : typ_verwerfer
{ {
return { return {
}; };
@ -59,34 +59,34 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_extended export function erstellen_aktor
( (
) )
: mod_actuator.type_actuator : mod_aktor.typ_aktor
{ {
return lib_call.wrap(kind, create()); return lib_aufruf.einpacken(art, erstellen());
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function example function beispiel
( (
) )
: type_rejector : typ_verwerfer
{ {
return create(); return erstellen();
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function rotate function drehen
( (
rejector : type_rejector, verwerfer : typ_verwerfer,
increment ?: int inkrement ?: int
) )
: void : void
{ {
@ -96,23 +96,23 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function use function verwenden
( (
rejector : type_rejector, verwerfer : typ_verwerfer,
token : mod_token.type_token figur : mod_figur.typ_figur
) )
: void : void
{ {
mod_token.reject(token); mod_figur.verwerfen(figur);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function export_ function exportieren
( (
rejector : type_rejector verwerfer : typ_verwerfer
) )
: any : any
{ {
@ -124,14 +124,14 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function import_ function importieren
( (
raw : any roh : any
) )
: type_rejector : typ_verwerfer
{ {
return ( return (
create erstellen
( (
) )
); );
@ -141,16 +141,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend<signature_actuator> lib_brauch.umsetzen<signatur_aktor>
( (
trait_actuator, brauch_aktor,
kind, art,
{ {
"example": () => lib_call.wrap(kind, example()), "beispiel": () => lib_aufruf.einpacken(art, beispiel()),
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment), "drehen": (aktor, inkrement) => drehen(lib_aufruf.auspacken(aktor), inkrement),
"use": (actuator, token) => use(lib_call.unwrap(actuator), token), "verwenden": (aktor, figur) => verwenden(lib_aufruf.auspacken(aktor), figur),
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}), "exportieren": (aktor) => ({"art": art, "angaben": exportieren(aktor.angaben)}),
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])), "importieren": (roh) => lib_aufruf.einpacken(art, importieren(roh["angaben"])),
} }
) )
; ;

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,24 +16,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_acceptortask export module mod_akzeptoraufgabe
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_acceptortask = export type typ_akzeptoraufgabe =
{ {
id : string; id : string;
title : string; titel : string;
text : string; text : string;
tests : Array<mod_acceptortest.type_acceptortest>; tests : Array<mod_akzeptortest.typ_akzeptortest>;
} }
; ;
@ -41,18 +41,18 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create export function erstellen
( (
id : string, id : string,
title : string, titel : string,
text : string, text : string,
tests : Array<mod_acceptortest.type_acceptortest> tests : Array<mod_akzeptortest.typ_akzeptortest>
) )
: type_acceptortask : typ_akzeptoraufgabe
{ {
return { return {
"id": id, "id": id,
"title": title, "titel": titel,
"text": text, "text": text,
"tests": tests, "tests": tests,
}; };
@ -64,24 +64,24 @@ namespace mod_vtm
*/ */
export function id export function id
( (
acceptortask : type_acceptortask akzeptoraufgabe : typ_akzeptoraufgabe
) )
: string : string
{ {
return acceptortask.id; return akzeptoraufgabe.id;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function title export function titel
( (
acceptortask : type_acceptortask akzeptoraufgabe : typ_akzeptoraufgabe
) )
: string : string
{ {
return acceptortask.title; return akzeptoraufgabe.titel;
} }
@ -90,11 +90,11 @@ namespace mod_vtm
*/ */
export function text export function text
( (
acceptortask : type_acceptortask akzeptoraufgabe : typ_akzeptoraufgabe
) )
: string : string
{ {
return acceptortask.text; return akzeptoraufgabe.text;
} }
@ -103,11 +103,11 @@ namespace mod_vtm
*/ */
export function tests export function tests
( (
acceptortask : type_acceptortask akzeptoraufgabe : typ_akzeptoraufgabe
) )
: Array<mod_acceptortest.type_acceptortest> : Array<mod_akzeptortest.typ_akzeptortest>
{ {
return acceptortask.tests; return akzeptoraufgabe.tests;
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,22 +16,22 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_acceptortest export module mod_akzeptortest
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_acceptortest = export type typ_akzeptortest =
{ {
input : Array<mod_vtm.mod_model.mod_symbol.type_symbol>; eingabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>;
accept : boolean; annehmen : boolean;
} }
; ;
@ -39,16 +39,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create export function erstellen
( (
input : Array<mod_vtm.mod_model.mod_symbol.type_symbol>, eingabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>,
accept : boolean annehmen : boolean
) )
: type_acceptortest : typ_akzeptortest
{ {
return { return {
"input": input, "eingabe": eingabe,
"accept": accept, "annehmen": annehmen,
}; };
} }
@ -56,13 +56,13 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function input export function eingabe
( (
acceptortest : type_acceptortest akzeptortest : typ_akzeptortest
) )
: Array<mod_vtm.mod_model.mod_symbol.type_symbol> : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
{ {
return acceptortest.input; return akzeptortest.eingabe;
} }
@ -71,13 +71,13 @@ namespace mod_vtm
*/ */
export function pruefen export function pruefen
( (
acceptortest : type_acceptortest, akzeptortest : typ_akzeptortest,
accepted : boolean, angenommen : boolean,
ausgabe : Array<mod_vtm.mod_model.mod_symbol.type_symbol> ausgabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
) )
: boolean : boolean
{ {
return (acceptortest.accept === accepted); return (akzeptortest.annehmen === angenommen);
} }
} }

View file

@ -0,0 +1,223 @@
/*
* 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_aufbau
{
export module mod_aufgabe
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_aufgabe = lib_aufruf.typ_komplex<Object>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _liste : Array<typ_aufgabe> = [];
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function id
(
aufgabe : typ_aufgabe
)
: string
{
return (
lib_aufruf.fallunterscheidung<string>
(
aufgabe,
{
"akzeptoraufgabe": (angaben) => mod_akzeptoraufgabe.id(angaben),
"transduktoraufgabe": (angaben) => mod_transduktoraufgabe.id(angaben),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function titel
(
aufgabe : typ_aufgabe
)
: string
{
return (
lib_aufruf.fallunterscheidung<string>
(
aufgabe,
{
"akzeptoraufgabe": (angaben) => mod_akzeptoraufgabe.titel(angaben),
"transduktoraufgabe": (angaben) => mod_transduktoraufgabe.titel(angaben),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function text
(
aufgabe : typ_aufgabe
)
: string
{
return (
lib_aufruf.fallunterscheidung<string>
(
aufgabe,
{
"akzeptoraufgabe": (angaben) => mod_akzeptoraufgabe.text(angaben),
"transduktoraufgabe": (angaben) => mod_transduktoraufgabe.text(angaben),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tests
(
aufgabe : typ_aufgabe
)
: Array<mod_test.typ_test>
{
return (
lib_aufruf.fallunterscheidung<Array<mod_test.typ_test>>
(
aufgabe,
{
"akzeptoraufgabe": (angaben) => (
mod_akzeptoraufgabe.tests(angaben)
.map(angaben_ => ({"art": "akzeptortest", "angaben": angaben_}))
),
"transduktoraufgabe": (angaben) => (
mod_transduktoraufgabe.tests(angaben)
.map(angaben_ => ({"art": "transduktortest", "angaben": angaben_}))
),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function importieren(aufgabe_roh : any) : typ_aufgabe
{
switch (aufgabe_roh["art"])
{
case "akzeptor":
{
return {
"art": "akzeptoraufgabe",
"angaben": (
mod_akzeptoraufgabe.erstellen
(
aufgabe_roh["id"],
aufgabe_roh["parameter"]["titel"],
aufgabe_roh["parameter"]["text"],
aufgabe_roh["parameter"]["tests"].map
(
test_roh => (
mod_akzeptortest.erstellen
(
test_roh["eingabe"],
test_roh["annehmen"]
)
)
)
)
)
};
break;
}
case "transduktor":
{
return {
"art": "transduktoraufgabe",
"angaben": (
mod_transduktoraufgabe.erstellen
(
aufgabe_roh["id"],
aufgabe_roh["parameter"]["titel"],
aufgabe_roh["parameter"]["text"],
aufgabe_roh["parameter"]["tests"].map
(
test_roh => (
mod_transduktortest.erstellen
(
test_roh["eingabe"],
test_roh["ausgabe"]
)
)
)
)
)
};
break;
}
default:
{
let meldung : string = "unbehandelte Art";
throw (new Error(meldung));
break;
}
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function registrieren(aufgabe : typ_aufgabe) : void
{
_liste.push(aufgabe);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function holen(index : int) : typ_aufgabe
{
return _liste[index];
}
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,37 +16,37 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_test export module mod_test
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_test = lib_call.type_complex<Object>; export type typ_test = lib_aufruf.typ_komplex<Object>;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function input export function eingabe
( (
test : type_test test : typ_test
) )
: Array<mod_vtm.mod_model.mod_symbol.type_symbol> : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
{ {
return ( return (
lib_call.distinguish<Array<mod_vtm.mod_model.mod_symbol.type_symbol>> lib_aufruf.fallunterscheidung<Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>>
( (
test, test,
{ {
"acceptortest": (data) => mod_acceptortest.input(data), "akzeptortest": (angaben) => mod_akzeptortest.eingabe(angaben),
"transducertest": (data) => mod_transducertest.input(data), "transduktortest": (angaben) => mod_transduktortest.eingabe(angaben),
} }
) )
); );
@ -58,19 +58,19 @@ namespace mod_vtm
*/ */
export function pruefen export function pruefen
( (
test : type_test, test : typ_test,
accepted : boolean, angenommen : boolean,
ausgabe : Array<mod_vtm.mod_model.mod_symbol.type_symbol> ausgabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
) )
: boolean : boolean
{ {
return ( return (
lib_call.distinguish<boolean> lib_aufruf.fallunterscheidung<boolean>
( (
test, test,
{ {
"acceptortest": (data) => mod_acceptortest.pruefen(data, accepted, ausgabe), "akzeptortest": (angaben) => mod_akzeptortest.pruefen(angaben, angenommen, ausgabe),
"transducertest": (data) => mod_transducertest.pruefen(data, accepted, ausgabe), "transduktortest": (angaben) => mod_transduktortest.pruefen(angaben, angenommen, ausgabe),
} }
) )
); );
@ -80,37 +80,37 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function import_ export function importieren
( (
test_raw : any test_roh : any
) )
: type_test : typ_test
{ {
switch (test_raw["kind"]) switch (test_roh["art"])
{ {
case "acceptortest": case "akzeptortest":
{ {
return { return {
"kind": "acceptortest", "art": "akzeptortest",
"data": ( "angaben": (
mod_acceptortest.create mod_akzeptortest.erstellen
( (
test_raw["data"]["input"], test_roh["angaben"]["eingabe"],
test_raw["data"]["accept"] test_roh["angaben"]["annehmen"]
) )
), ),
}; };
break; break;
} }
case "transducertest": case "transduktortest":
{ {
return { return {
"kind": "transducertest", "art": "transduktortest",
"data": ( "angaben": (
mod_transducertest.create mod_transduktortest.erstellen
( (
test_raw["data"]["input"], test_roh["angaben"]["eingabe"],
test_raw["data"]["output"] test_roh["angaben"]["ausgabe"]
) )
), ),
}; };

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,24 +16,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_transducertask export module mod_transduktoraufgabe
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_transducertask = export type typ_transduktoraufgabe =
{ {
id : string; id : string;
title : string; titel : string;
text : string; text : string;
tests : Array<mod_transducertest.type_transducertest>; tests : Array<mod_transduktortest.typ_transduktortest>;
} }
; ;
@ -41,18 +41,18 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create export function erstellen
( (
id : string, id : string,
title : string, titel : string,
text : string, text : string,
tests : Array<mod_transducertest.type_transducertest> tests : Array<mod_transduktortest.typ_transduktortest>
) )
: type_transducertask : typ_transduktoraufgabe
{ {
return { return {
"id": id, "id": id,
"title": title, "titel": titel,
"text": text, "text": text,
"tests": tests, "tests": tests,
}; };
@ -64,24 +64,24 @@ namespace mod_vtm
*/ */
export function id export function id
( (
transducertask : type_transducertask transduktoraufgabe : typ_transduktoraufgabe
) )
: string : string
{ {
return transducertask.id; return transduktoraufgabe.id;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function title export function titel
( (
transducertask : type_transducertask transduktoraufgabe : typ_transduktoraufgabe
) )
: string : string
{ {
return transducertask.title; return transduktoraufgabe.titel;
} }
@ -90,11 +90,11 @@ namespace mod_vtm
*/ */
export function text export function text
( (
transducertask : type_transducertask transduktoraufgabe : typ_transduktoraufgabe
) )
: string : string
{ {
return transducertask.text; return transduktoraufgabe.text;
} }
@ -103,11 +103,11 @@ namespace mod_vtm
*/ */
export function tests export function tests
( (
transducertask : type_transducertask transduktoraufgabe : typ_transduktoraufgabe
) )
: Array<mod_transducertest.type_transducertest> : Array<mod_transduktortest.typ_transduktortest>
{ {
return transducertask.tests; return transduktoraufgabe.tests;
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,22 +16,22 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_transducertest export module mod_transduktortest
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_transducertest = export type typ_transduktortest =
{ {
input : Array<mod_vtm.mod_model.mod_symbol.type_symbol>; eingabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>;
output : Array<mod_vtm.mod_model.mod_symbol.type_symbol>; ausgabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>;
} }
; ;
@ -39,16 +39,16 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create export function erstellen
( (
input : Array<mod_vtm.mod_model.mod_symbol.type_symbol>, eingabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>,
output : Array<mod_vtm.mod_model.mod_symbol.type_symbol> ausgabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
) )
: type_transducertest : typ_transduktortest
{ {
return { return {
"input": input, "eingabe": eingabe,
"output": output, "ausgabe": ausgabe,
}; };
} }
@ -56,13 +56,13 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function input export function eingabe
( (
transducertest : type_transducertest transduktortest : typ_transduktortest
) )
: Array<mod_vtm.mod_model.mod_symbol.type_symbol> : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
{ {
return transducertest.input; return transduktortest.eingabe;
} }
@ -71,29 +71,29 @@ namespace mod_vtm
*/ */
export function pruefen export function pruefen
( (
transducertest : type_transducertest, transduktortest : typ_transduktortest,
accepted : boolean, angenommen : boolean,
output : Array<mod_vtm.mod_model.mod_symbol.type_symbol> ausgabe : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>
) )
: boolean : boolean
{ {
if (transducertest.output.length !== output.length) if (transduktortest.ausgabe.length !== ausgabe.length)
{ {
return false; return false;
} }
else else
{ {
let gleich : boolean = true; let gleich : boolean = true;
for (let index : int = 0; index < transducertest.output.length; index += 1) for (let index : int = 0; index < transduktortest.ausgabe.length; index += 1)
{ {
if (! mod_vtm.mod_model.mod_symbol.collate(transducertest.output[index], output[index])) if (! mod_vtm.mod_aufbau.mod_symbol.vergleichen(transduktortest.ausgabe[index], ausgabe[index]))
{ {
gleich = false; gleich = false;
break; break;
} }
else else
{ {
// nothing tun // nichts tun
} }
} }
return gleich; return gleich;

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,23 +16,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_token export module mod_figur
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_token = export type typ_figur =
{ {
state : mod_state.type_state; zustand : mod_zustand.typ_zustand;
tape : Array<mod_symbol.type_symbol>; band : Array<mod_symbol.typ_symbol>;
spot : mod_spot.type_spot; stelle : mod_stelle.typ_stelle;
} }
; ;
@ -40,17 +40,17 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create export function erstellen
( (
tape : Array<mod_symbol.type_symbol> = [], band : Array<mod_symbol.typ_symbol> = [],
spot : mod_spot.type_spot = mod_spot.null_() stelle : mod_stelle.typ_stelle = mod_stelle.null_()
) )
: type_token : typ_figur
{ {
return { return {
"state": mod_state.running, "zustand": mod_zustand.laufend,
"tape": tape, "band": band,
"spot": spot, "stelle": stelle,
}; };
} }
@ -58,87 +58,87 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function state_read export function zustand_lesen
( (
token : type_token figur : typ_figur
) )
: mod_state.type_state : mod_zustand.typ_zustand
{ {
return token.state; return figur.zustand;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function tape_read export function band_lesen
( (
token : type_token figur : typ_figur
) )
: Array<mod_symbol.type_symbol> : Array<mod_symbol.typ_symbol>
{ {
return token.tape; return figur.band;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function spot_read export function stelle_lesen
( (
token : type_token figur : typ_figur
) )
: mod_spot.type_spot : mod_stelle.typ_stelle
{ {
return token.spot; return figur.stelle;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function move export function bewegen
( (
token : type_token, figur : typ_figur,
direction : mod_direction.type_direction richtung : mod_richtung.typ_richtung
) )
: void : void
{ {
let summand : mod_spot.type_spot = mod_spot.from_direction(direction); let summand : mod_stelle.typ_stelle = mod_stelle.von_richtung(richtung);
token.spot = mod_spot.add(token.spot, summand); figur.stelle = mod_stelle.addieren(figur.stelle, summand);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function write export function schreiben
( (
token : type_token, figur : typ_figur,
symbol : mod_symbol.type_symbol symbol : mod_symbol.typ_symbol
) )
: void : void
{ {
token.tape.push(symbol); figur.band.push(symbol);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function read export function lesen
( (
token : type_token figur : typ_figur
) )
: lib_errormonade.type_errormonade<mod_symbol.type_symbol> : lib_fehlermonade.typ_fehlermonade<mod_symbol.typ_symbol>
{ {
if (token.tape.length <= 0) if (figur.band.length <= 0)
{ {
return (lib_errormonade.create_nothing<mod_symbol.type_symbol>()); return (lib_fehlermonade.erstellen_nichts<mod_symbol.typ_symbol>());
} }
else else
{ {
return (lib_errormonade.create_just<mod_symbol.type_symbol>(token.tape[0])); return (lib_fehlermonade.erstellen_schlicht<mod_symbol.typ_symbol>(figur.band[0]));
} }
} }
@ -146,20 +146,20 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function shift export function schieben
( (
token : type_token figur : typ_figur
) )
: void : void
{ {
if (token.tape.length <= 0) if (figur.band.length <= 0)
{ {
let message : string = "Band ist leer"; let meldung : string = "Band ist leer";
throw (new Error(message)); throw (new Error(meldung));
} }
else else
{ {
token.tape.shift(); figur.band.shift();
} }
} }
@ -167,26 +167,26 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function accept export function annehmen
( (
token : type_token figur : typ_figur
) )
: void : void
{ {
token.state = mod_state.accepted; figur.zustand = mod_zustand.angenommen;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function reject export function verwerfen
( (
token : type_token figur : typ_figur
) )
: void : void
{ {
token.state = mod_state.rejected; figur.zustand = mod_zustand.abgelehnt;
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,28 +16,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_mode export module mod_modus
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_mode = int; export type typ_modus = int;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export const initial = 0; export const initial = 0;
export const uncertain = 1; export const ungewiss = 1;
export const wrong = 2; export const fehlerhaft = 2;
export const correct = 3; export const korrekt = 3;
} }

View file

@ -0,0 +1,438 @@
/*
* 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_aufbau
{
export module mod_partie
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_partie =
{
welt : mod_welt.typ_welt;
figur : lib_fehlermonade.typ_fehlermonade<mod_figur.typ_figur>;
aufgabe : mod_aufgabe.typ_aufgabe;
testindex : lib_fehlermonade.typ_fehlermonade<int>;
modus : mod_modus.typ_modus;
lauscher : {[ereignis : string] : Array<(angaben ?: any)=>void>};
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen
(
aufgabe : mod_aufgabe.typ_aufgabe
)
: typ_partie
{
let partie : typ_partie = {
"welt": undefined,
"figur": undefined,
"aufgabe": aufgabe,
"testindex": undefined,
"modus": undefined,
"lauscher": undefined,
};
partie.lauscher = {
"aenderung_aufgabe": [],
"aenderung_welt": [],
"aenderung_figur": [],
"aenderung_modus": [],
};
welt_leeren(partie, false);
zuruecksetzen(partie, false);
return partie;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function lauschen
(
partie : typ_partie,
ereignis : string,
prozedur : (angaben ?: any)=>void
)
: void
{
if (ereignis in partie.lauscher)
{
partie.lauscher[ereignis].push(prozedur);
}
else
{
let meldung : string = "kein Ereignis mit diesem Name";
throw (new Error(meldung));
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function benachrichtigen
(
partie : typ_partie,
ereignis : string,
angaben : any = {}
) : void
{
if (ereignis in partie.lauscher)
{
partie.lauscher[ereignis].forEach
(
prozedur =>
{
prozedur(angaben);
}
)
;
}
else
{
let meldung : string = "kein Ereignis mit diesem Name";
throw (new Error(meldung));
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function zuruecksetzen
(
partie : typ_partie,
bescheid_geben : boolean = true
)
: void
{
partie.figur = (lib_fehlermonade.erstellen_nichts<mod_figur.typ_figur>());
partie.testindex = (lib_fehlermonade.erstellen_nichts<int>());
partie.modus = mod_modus.initial;
if (bescheid_geben)
{
benachrichtigen(partie, "aenderung_figur", {});
benachrichtigen(partie, "aenderung_modus", {});
}
else
{
// nichts tun
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aufgabe_lesen
(
partie : typ_partie
)
: mod_aufgabe.typ_aufgabe
{
return partie.aufgabe;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aufgabe_setzen
(
partie : typ_partie,
aufgabe : mod_aufgabe.typ_aufgabe
) : void
{
partie.aufgabe = aufgabe;
// partie.welt_leeren();
benachrichtigen(partie, "aenderung_aufgabe", {});
zuruecksetzen(partie);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function welt_lesen
(
partie : typ_partie
)
: mod_welt.typ_welt
{
return partie.welt;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function welt_setzen
(
partie : typ_partie,
welt : mod_welt.typ_welt,
bescheid_geben : boolean = true
)
: void
{
partie.welt = welt;
if (bescheid_geben)
{
benachrichtigen(partie, "aenderung_welt", {});
}
else
{
// nichts tun
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function welt_leeren
(
partie : typ_partie,
bescheid_geben : boolean = true
)
: void
{
partie.welt = mod_welt.blanko();
if (bescheid_geben)
{
benachrichtigen(partie, "aenderung_welt", {});
}
else
{
// nichts tun
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function figur_lesen
(
partie : typ_partie
)
: lib_fehlermonade.typ_fehlermonade<mod_figur.typ_figur>
{
return partie.figur;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function modus_lesen
(
partie : typ_partie
)
: mod_modus.typ_modus
{
return partie.modus;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function welt_feld_wechseln
(
partie : typ_partie,
stelle : mod_stelle.typ_stelle,
umgekehrt : boolean = false
)
: void
{
if (! (partie.modus === mod_modus.initial))
{
let meldung : string = "gesperrt";
}
else
{
mod_welt.feld_wechseln(partie.welt, stelle, umgekehrt);
benachrichtigen
(
partie,
"aenderung_welt",
{
"art": "feld_wechseln",
"angaben":
{
"stelle": stelle,
"umgekehrt": umgekehrt,
"feld": mod_welt.feld_holen(partie.welt, stelle),
}
}
)
;
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function welt_feld_drehen
(
partie : typ_partie,
stelle : mod_stelle.typ_stelle,
inkrement : int = +1
)
: void
{
if (! (partie.modus === mod_modus.initial))
{
let meldung : string = "gesperrt";
}
else
{
mod_welt.feld_drehen(partie.welt, stelle, inkrement);
benachrichtigen(partie, "aenderung_welt", {});
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function fortfahren
(
partie : typ_partie
)
: void
{
switch (partie.modus)
{
case mod_modus.initial:
{
partie.modus = mod_modus.ungewiss;
partie.testindex = (lib_fehlermonade.erstellen_schlicht<int>(0));
benachrichtigen(partie, "aenderung_modus", {});
break;
}
case mod_modus.ungewiss:
{
if (! lib_fehlermonade.voll<mod_figur.typ_figur>(partie.figur))
{
let test : mod_test.typ_test = mod_aufgabe.tests(partie.aufgabe)[lib_fehlermonade.lesen<int>(partie.testindex)];
let band : Array<mod_symbol.typ_symbol> = mod_vtm.mod_helfer.liste_kopieren<mod_symbol.typ_symbol>(mod_test.eingabe(test));
let stelle : mod_stelle.typ_stelle = mod_welt.erzeuger_finden(partie.welt);
partie.figur = (
lib_fehlermonade.erstellen_schlicht<mod_figur.typ_figur>
(
mod_figur.erstellen
(
band,
stelle
)
)
);
}
else
{
let figur : mod_figur.typ_figur = lib_fehlermonade.lesen<mod_figur.typ_figur>(partie.figur);
let stelle : mod_stelle.typ_stelle = mod_figur.stelle_lesen(figur);
let aktor_ : lib_fehlermonade.typ_fehlermonade<mod_aktor.typ_aktor> = mod_welt.feld_holen(partie.welt, stelle);
let aktor : mod_aktor.typ_aktor = (
lib_fehlermonade.voll<mod_aktor.typ_aktor>(aktor_)
? lib_fehlermonade.lesen<mod_aktor.typ_aktor>(aktor_)
: mod_aktor.mod_verwerfer.erstellen_aktor()
);
mod_aktor.verwenden(aktor, figur);
let zustand : mod_zustand.typ_zustand = mod_figur.zustand_lesen(figur);
if (zustand === mod_zustand.laufend)
{
// nichts tun
}
else if ((zustand === mod_zustand.angenommen) || (zustand === mod_zustand.abgelehnt))
{
let angenommen : boolean = (zustand === mod_zustand.angenommen);
let ausgabe : Array<mod_symbol.typ_symbol> = mod_figur.band_lesen(figur);
partie.figur = (lib_fehlermonade.erstellen_nichts<mod_figur.typ_figur>());
let testindex : int = lib_fehlermonade.lesen<int>(partie.testindex);
let tests : Array<mod_test.typ_test> = mod_aufgabe.tests(partie.aufgabe);
let test : mod_test.typ_test = tests[testindex];
if (! mod_test.pruefen(test, angenommen, ausgabe))
{
partie.modus = mod_modus.fehlerhaft;
benachrichtigen(partie, "aenderung_modus", {});
}
else
{
testindex += 1;
if (testindex < tests.length)
{
// nächsten Test auswählen
partie.testindex = (lib_fehlermonade.erstellen_schlicht<int>(testindex));
}
else
{
// auf Modus "korrekt" wechseln
partie.testindex = (lib_fehlermonade.erstellen_nichts<int>());
partie.modus = mod_modus.korrekt;
benachrichtigen(partie, "aenderung_modus", {});
}
}
}
else
{
let meldung : string = "unbehandelter Zustand";
throw (new Error(meldung));
}
}
benachrichtigen(partie, "aenderung_figur", {});
break;
}
case mod_modus.fehlerhaft:
{
// nichts tun
break;
}
case mod_modus.korrekt:
{
// nichts tun
break;
}
default:
{
let meldung : string = "unbehandelter Modus";
throw (new Error(meldung));
break;
}
}
}
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,45 +16,45 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_direction export module mod_richtung
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_direction = int; export type typ_richtung = int;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function add(direction1 : type_direction, direction2 : type_direction) : type_direction export function addieren(richtung1 : typ_richtung, richtung2 : typ_richtung) : typ_richtung
{ {
return lib_math.mod(direction1 + direction2, 6); return lib_mathematik.mod(richtung1 + richtung2, 6);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function export_(direction : type_direction) : int export function exportieren(richtung : typ_richtung) : int
{ {
return direction; return richtung;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function import_(direction_ : int) : type_direction export function importieren(richtung_ : int) : typ_richtung
{ {
return direction_; return richtung_;
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,34 +16,34 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_spot export module mod_stelle
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_spot = {u : int; v : int;}; export type typ_stelle = {u : int; v : int;};
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function hash(spot : type_spot) : string export function hash(stelle : typ_stelle) : string
{ {
return (spot.u.toFixed(0) + "_" + spot.v.toFixed(0)); return (stelle.u.toFixed(0) + "_" + stelle.v.toFixed(0));
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function from_hash(hash : string) : type_spot export function von_hash(hash : string) : typ_stelle
{ {
let teile : Array<string> = hash.split("_"); let teile : Array<string> = hash.split("_");
return {"u": parseInt(teile[0]), "v": parseInt(teile[1])}; return {"u": parseInt(teile[0]), "v": parseInt(teile[1])};
@ -53,7 +53,7 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function null_() : type_spot export function null_() : typ_stelle
{ {
return {"u": 0, "v": 0}; return {"u": 0, "v": 0};
} }
@ -62,9 +62,9 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function from_direction(direction : mod_direction.type_direction) : type_spot export function von_richtung(richtung : mod_richtung.typ_richtung) : typ_stelle
{ {
switch (direction) switch (richtung)
{ {
case 0: {return {"u": +1, "v": 0}; break;} case 0: {return {"u": +1, "v": 0}; break;}
case 1: {return {"u": +1, "v": +1}; break;} case 1: {return {"u": +1, "v": +1}; break;}
@ -72,7 +72,7 @@ namespace mod_vtm
case 3: {return {"u": -1, "v": 0}; break;} case 3: {return {"u": -1, "v": 0}; break;}
case 4: {return {"u": -1, "v": -1}; break;} case 4: {return {"u": -1, "v": -1}; break;}
case 5: {return {"u": 0, "v": -1}; break;} case 5: {return {"u": 0, "v": -1}; break;}
default: {throw (new Error("ungültige Richtung '" + String(direction) + "'")); break;} default: {throw (new Error("ungültige Richtung '" + String(richtung) + "'")); break;}
} }
} }
@ -80,27 +80,27 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function add(spot1 : type_spot, spot2 : type_spot) : type_spot export function addieren(stelle1 : typ_stelle, stelle2 : typ_stelle) : typ_stelle
{ {
return {"u": (spot1.u + spot2.u), "v": (spot1.v + spot2.v)}; return {"u": (stelle1.u + stelle2.u), "v": (stelle1.v + stelle2.v)};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function export_(spot : type_spot) : string export function exportieren(stelle : typ_stelle) : string
{ {
return hash(spot); return hash(stelle);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function import_(spot_ : string) : type_spot export function importieren(stelle_ : string) : typ_stelle
{ {
return from_hash(spot_); return von_hash(stelle_);
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,25 +16,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_symbol export module mod_symbol
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_symbol = int; export type typ_symbol = int;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function collate(symbol1 : type_symbol, symbol2 : type_symbol) : boolean export function vergleichen(symbol1 : typ_symbol, symbol2 : typ_symbol) : boolean
{ {
return (symbol1 === symbol2); return (symbol1 === symbol2);
} }
@ -43,7 +43,7 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function export_(symbol : type_symbol) : int export function exportieren(symbol : typ_symbol) : int
{ {
return symbol; return symbol;
} }
@ -52,7 +52,7 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function import_(symbol_ : int) : type_symbol export function importieren(symbol_ : int) : typ_symbol
{ {
return symbol_; return symbol_;
} }

402
quelldatein/aufbau/welt.ts Normal file
View file

@ -0,0 +1,402 @@
/*
* 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_aufbau
{
export module mod_welt
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_welt =
{
felder : lib_hashmap.typ_hashmap<mod_stelle.typ_stelle, mod_aktor.typ_aktor>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen
(
felder : lib_hashmap.typ_hashmap<mod_stelle.typ_stelle, mod_aktor.typ_aktor> = lib_hashmap.erstellen<mod_stelle.typ_stelle, mod_aktor.typ_aktor>(mod_stelle.hash)
)
: typ_welt
{
return {
"felder": felder,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function felder_lesen
(
welt : typ_welt
)
: Array<{stelle : mod_stelle.typ_stelle; aktor : mod_aktor.typ_aktor;}>
{
let felder : Array<{stelle : mod_stelle.typ_stelle; aktor : mod_aktor.typ_aktor;}> = [];
lib_hashmap.iterieren
(
welt.felder,
(stelle, aktor) => felder.push({"stelle": stelle, "aktor": aktor})
)
;
return felder;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function feld_holen
(
welt : typ_welt,
stelle : mod_stelle.typ_stelle
)
: lib_fehlermonade.typ_fehlermonade<mod_aktor.typ_aktor>
{
return lib_hashmap.holen(welt.felder, stelle);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function feld_setzen
(
welt : typ_welt,
stelle : mod_stelle.typ_stelle,
aktor : mod_aktor.typ_aktor
)
: void
{
lib_hashmap.setzen(welt.felder, stelle, aktor);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function feld_wechseln
(
welt : typ_welt,
stelle : mod_stelle.typ_stelle,
umgekehrt : boolean = false
)
: void
{
let erweitert : boolean = true;
let liste : Array<{pruefer : (aktor : mod_aktor.typ_aktor)=>boolean; ersteller : ()=>mod_aktor.typ_aktor;}> = (
[]
.concat
(
[
{
"pruefer": (aktor) => (aktor.art === "befoerderer"),
"ersteller": () => mod_aktor.mod_befoerderer.erstellen_aktor(0),
},
]
)
.concat
(
mod_vtm.mod_helfer.sequenz(erweitert ? 4 : 2).map
(
symbol => (
{
"pruefer": (aktor) =>
{
if (aktor.art === "schreiber")
{
return (mod_aktor.mod_schreiber.symbol_lesen(aktor.angaben) === symbol);
}
else
{
return false;
}
}
,
"ersteller": () => mod_aktor.mod_schreiber.erstellen_aktor(0, symbol)
}
)
)
)
.concat
(
mod_vtm.mod_helfer.sequenz(erweitert ? 2 : 1).map
(
index =>
{
let symbol_links : mod_symbol.typ_symbol = (2*index+0);
let symbol_rechts : mod_symbol.typ_symbol = (2*index+1);
return (
{
"pruefer": (aktor) =>
{
if (aktor.art === "leser")
{
return (
(mod_aktor.mod_leser.symbol_links_lesen(aktor.angaben) === symbol_links)
&&
(mod_aktor.mod_leser.symbol_rechts_lesen(aktor.angaben) === symbol_rechts)
);
}
else
{
return false;
}
}
,
"ersteller": () => mod_aktor.mod_leser.erstellen_aktor(0, symbol_links, symbol_rechts)
}
);
}
)
)
.concat
(
[
{
"pruefer": (aktor) => (aktor.art === "verwerfer"),
"ersteller": () => mod_aktor.mod_verwerfer.erstellen_aktor(),
},
]
)
);
let index_alt : lib_fehlermonade.typ_fehlermonade<int>;
let aktor_alt_ : lib_fehlermonade.typ_fehlermonade<mod_aktor.typ_aktor> = lib_hashmap.holen(welt.felder, stelle);
if (lib_fehlermonade.voll<mod_aktor.typ_aktor>(aktor_alt_))
{
let aktor_alt : mod_aktor.typ_aktor = lib_fehlermonade.lesen(aktor_alt_);
let gefunden : boolean = (
liste.some
(
(eintrag, index) =>
{
if (eintrag.pruefer(aktor_alt))
{
index_alt = (lib_fehlermonade.erstellen_schlicht<int>(index));
return true;
}
else
{
return false;
}
}
)
);
if (! gefunden)
{
index_alt = (lib_fehlermonade.erstellen_nichts<int>());
}
else
{
// nichts tun
}
}
else
{
let meldung : string = "kein Aktor gesetzt";
// console.warn(meldung);
index_alt = (lib_fehlermonade.erstellen_schlicht<int>(0));
}
if (lib_fehlermonade.voll<int>(index_alt))
{
let index_neu : int = lib_mathematik.mod(lib_fehlermonade.lesen<int>(index_alt) + (umgekehrt ? -1 : +1), liste.length);
let aktor_neu : mod_aktor.typ_aktor = liste[index_neu].ersteller();
feld_setzen(welt, stelle, aktor_neu);
}
else
{
let meldung : string = ("Aktor nicht gefunden");
// throw (new Error(meldung));
console.warn(meldung);
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function feld_drehen
(
welt : typ_welt,
stelle : mod_stelle.typ_stelle,
inkrement : int = +1
)
: void
{
let aktor_ : lib_fehlermonade.typ_fehlermonade<mod_aktor.typ_aktor> = lib_hashmap.holen(welt.felder, stelle);
if (lib_fehlermonade.voll<mod_aktor.typ_aktor>(aktor_))
{
mod_aktor.drehen(lib_fehlermonade.lesen<mod_aktor.typ_aktor>(aktor_), inkrement);
}
else
{
console.warn("kein Aktor gesetzt");
}
}
/**
* @author kcf <vidofnir@folksprak.org>
* @throws {Error}
*/
export function erzeuger_finden
(
welt : typ_welt
)
: mod_stelle.typ_stelle
{
let stelle : lib_fehlermonade.typ_fehlermonade<mod_stelle.typ_stelle> = (lib_fehlermonade.erstellen_nichts<mod_stelle.typ_stelle>());
lib_hashmap.iterieren
(
welt.felder,
(stelle_, aktor) =>
{
if (aktor.art === "erzeuger")
{
if (lib_fehlermonade.voll<mod_stelle.typ_stelle>(stelle))
{
let meldung : string = "mehrere Erzeuger gefunden";
throw (new Error(meldung));
}
else
{
stelle = (lib_fehlermonade.erstellen_schlicht<mod_stelle.typ_stelle>(stelle_));
}
}
}
)
;
if (lib_fehlermonade.voll<mod_stelle.typ_stelle>(stelle))
{
return lib_fehlermonade.lesen<mod_stelle.typ_stelle>(stelle);
}
else
{
let meldung : string = "kein Erzeuger gefunden";
throw (new Error(meldung));
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function blanko
(
groesse : int = 3
)
: typ_welt
{
let welt : typ_welt = erstellen();
for (let u : int = -groesse; u <= +groesse; u += 1)
{
for (let v : int = -groesse; v <= +groesse; v += 1)
{
if (Math.abs(u-v) <= groesse)
{
let stelle : mod_stelle.typ_stelle = {"u": u, "v": v};
let aktor : mod_aktor.typ_aktor;
if ((u === -groesse) && (v === 0))
{
aktor = mod_aktor.mod_erzeuger.erstellen_aktor(0);
}
else if ((u === +groesse) && (v === 0))
{
aktor = mod_aktor.mod_annehmer.erstellen_aktor();
}
else
{
aktor = mod_aktor.mod_verwerfer.erstellen_aktor();
}
lib_hashmap.setzen(welt.felder, stelle, aktor);
}
}
}
return welt;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function exportieren
(
welt : typ_welt
)
: any
{
let roh : any = {};
roh["felder"] = {};
lib_hashmap.iterieren
(
welt.felder,
(stelle, aktor) =>
{
let stelle_ : string = mod_stelle.exportieren(stelle);
let aktor_ : any = mod_aktor.exportieren(aktor);
roh["felder"][stelle_] = aktor_;
}
)
;
return roh;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function importieren
(
roh : any
)
: typ_welt
{
let felder : lib_hashmap.typ_hashmap<mod_stelle.typ_stelle, mod_aktor.typ_aktor> = (lib_hashmap.erstellen<mod_stelle.typ_stelle, mod_aktor.typ_aktor>(mod_stelle.hash));
for (let stelle_ in roh["felder"])
{
let stelle : mod_stelle.typ_stelle = mod_stelle.importieren(stelle_);
let aktor_ : mod_aktor.typ_aktor = roh["felder"][stelle_];
let aktor : mod_aktor.typ_aktor = mod_aktor.importieren(aktor_);
lib_hashmap.setzen(felder, stelle, aktor);
}
return (
erstellen
(
felder
)
);
}
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,27 +16,27 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_model export module mod_aufbau
{ {
export namespace mod_state export module mod_zustand
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_state = int; export type typ_zustand = int;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export var rejected = -1; export var abgelehnt = -1;
export var running = 0; export var laufend = 0;
export var accepted = +1; export var angenommen = +1;
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,39 +16,39 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_data export module mod_daten
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
var _store = {}; var _speicher = {};
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function write(key : string, value : any) : void export function schreiben(schluessel : string, wert : any) : void
{ {
_store[key] = value; _speicher[schluessel] = wert;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function read(key : string) : lib_errormonade.type_errormonade<any> export function lesen(schluessel : string) : lib_fehlermonade.typ_fehlermonade<any>
{ {
if (key in _store) if (schluessel in _speicher)
{ {
return (lib_errormonade.create_just<any>(_store[key])); return (lib_fehlermonade.erstellen_schlicht<any>(_speicher[schluessel]));
} }
else else
{ {
return (lib_errormonade.create_nothing<any>()); return (lib_fehlermonade.erstellen_nichts<any>());
} }
} }
@ -60,8 +60,8 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
function jsonp_handle(objekt : {key : string; value : any;}) : void function jsonp_behandlung(objekt : {schluessel : string; wert : any;}) : void
{ {
mod_vtm.mod_data.write(objekt.key, objekt.value); mod_vtm.mod_daten.schreiben(objekt.schluessel, objekt.wert);
} }

View file

@ -0,0 +1,261 @@
jsonp_behandlung(
{
"schluessel": "aufgaben",
"wert": [
{
"id": "einfuehrung",
"art": "akzeptor",
"parameter": {
"titel": "Einführung",
"text": "Bewege die Figur vom Eingang (links) zum Ausgang (rechts)!",
"tests": [
{
"eingabe": [],
"annehmen": true
}
]
}
},
{
"id": "start_symbol",
"art": "akzeptor",
"parameter": {
"titel": "Start-Symbol",
"text": "Annehmen, wenn die Eingabe mit ${s1} beginnt; andernfalls ablehnen",
"tests": [
{
"eingabe": [],
"annehmen": false
},
{
"eingabe": [0],
"annehmen": false
},
{
"eingabe": [1],
"annehmen": true
},
{
"eingabe": [0,1],
"annehmen": false
},
{
"eingabe": [1,0,1,1,0,0,0,1,0],
"annehmen": true
}
]
}
},
{
"id": "dreifaltigkeit",
"art": "akzeptor",
"parameter": {
"titel": "Dreifaltigkeit",
"text": "Annehmen genau dann, wenn die Eingabe mindestens drei ${s1} enthält",
"tests": [
{
"eingabe": [1],
"annehmen": false
},
{
"eingabe": [0,0,1,1],
"annehmen": false
},
{
"eingabe": [1,0,1,0,0,1,0],
"annehmen": true
}
]
}
},
{
"id": "abwechslung_erfreuet",
"art": "akzeptor",
"parameter": {
"titel": "Abwechslung erfreuet",
"text": "annehmen genau dann wenn: Die Farben der Eingabe (${s0} / ${s1}) sich immer abwechseln",
"tests": [
{
"eingabe": [],
"annehmen": true
},
{
"eingabe": [0],
"annehmen": true
},
{
"eingabe": [0,0],
"annehmen": false
},
{
"eingabe": [1,0,1],
"annehmen": true
},
{
"eingabe": [0,1,0,1,0,1],
"annehmen": true
}
]
}
},
{
"id": "ans_ende",
"art": "transduktor",
"parameter": {
"titel": "Ans Ende",
"text": "die Eingabe (${s0} / ${s1}), aber mit dem ersten Symbol am Ende",
"tests": [
{
"eingabe": [0,0,1,1,1,0,1,0,1,1,1,0,1],
"ausgabe": [0,1,1,1,0,1,0,1,1,1,0,1,0]
}
]
}
},
{
"id": "tauschen",
"art": "transduktor",
"parameter": {
"titel": "Tauschen",
"text": "aus der Eingabe (${s0} / ${s1}) alle ${s0} durch ${s2} ersetzen und alle ${s1} durch ${s3}",
"tests": [
{
"eingabe": [0,1,1,0],
"ausgabe": [2,3,3,2]
},
{
"eingabe": [0,1,0,1,0,1,1,0,0,0,0,1,0,1,1,0],
"ausgabe": [2,3,2,3,2,3,3,2,2,2,2,3,2,3,3,2]
}
]
}
},
{
"id": "waehlerisch",
"art": "transduktor",
"parameter": {
"titel": "Wählerisch",
"text": "aus der Eingabe alle ${s0} entfernen und alle ${s1} beibehalten",
"tests": [
{
"eingabe": [0,0,0,1,0],
"ausgabe": [1]
},
{
"eingabe": [1,0,1,0,1],
"ausgabe": [1,1,1]
},
{
"eingabe": [1,1,1,1,0],
"ausgabe": [1,1,1,1]
},
{
"eingabe": [0,0,0,0,1,0,1,1,0],
"ausgabe": [1,1,1]
},
]
}
},
{
"id": "dekorator",
"art": "transduktor",
"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": [
{
"eingabe": [1,1,0],
"ausgabe": [2,1,1,0,3]
},
{
"eingabe": [0,0,1,0,0],
"ausgabe": [2,0,0,1,0,0,3]
}
]
}
},
{
"id": "alpha_und_omega",
"art": "akzeptor",
"parameter": {
"titel": "Alpha und Omega",
"text": "Eingaben (${s0} / ${s1}), die mit den gleichen Symbolen anfangen und enden",
"tests": [
{
"eingabe": [],
"annehmen": true
},
{
"eingabe": [1],
"annehmen": true
},
{
"eingabe": [0,1],
"annehmen": false
},
{
"eingabe": [0,1,1,1,0],
"annehmen": true
},
{
"eingabe": [1,1,0,0],
"annehmen": false
},
{
"eingabe": [1,0,1,1,1],
"annehmen": true
}
]
}
},
{
"id": "an_den_anfang",
"art": "transduktor",
"parameter": {
"titel": "An den Anfang",
"text": "die Eingabe (${s0} / ${s1}), aber mit dem letzten Symbol am Anfang",
"tests": [
{
"eingabe": [0,0,1,1,1,0,1,0,1,1,1,0,1],
"ausgabe": [1,0,0,1,1,1,0,1,0,1,1,1,0]
}
]
}
},
{
"id": "a_n_b_n",
"art": "akzeptor",
"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": [
{
"eingabe": [],
"annehmen": true
},
{
"eingabe": [0],
"annehmen": false
},
{
"eingabe": [0,0,1,1],
"annehmen": true
},
{
"eingabe": [0,0,0,1,1],
"annehmen": false
},
{
"eingabe": [0,0,0,0,0,0,0,1,1,1,1,1,1,1],
"annehmen": 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

@ -0,0 +1,51 @@
jsonp_behandlung(
{
"schluessel": "zeichenketten-de",
"wert": {
"allgemein.titel": "Verrückte Turing-Maschinen",
"allgemein.hilfe": "Hilfe",
"allgemein.spiel": "Spiel",
"aufbau.figur.worter.singular": "Figur",
"aufbau.figur.worter.plural": "Figuren",
"aufbau.aktoren.woerter.singular": "Aktor",
"aufbau.aktoren.woerter.plural": "Aktoren",
"aufbau.aktoren.arten.erzeuger.name": "Eingang",
"aufbau.aktoren.arten.annehmer.name": "Ausgang",
"aufbau.aktoren.arten.verwerfer.name": "Abweiser",
"aufbau.aktoren.arten.befoerderer.name": "Schieber",
"aufbau.aktoren.arten.schreiber.name": "Schreiber",
"aufbau.aktoren.arten.leser.name": "Weiche",
"aufbau.aufgaben.woerter.singular": "Aufgabe",
"aufbau.aufgaben.woerter.plural": "Aufgaben",
"aufbau.aufgaben.arten.akzeptor.name": "Akzeptor",
"aufbau.aufgaben.arten.akzeptor.kuerzel": "AKZ",
"aufbau.aufgaben.arten.transduktor.name": "Transduktor",
"aufbau.aufgaben.arten.transduktor.kuerzel": "TRA",
"steuerung.auswaehlen": "Aufgabe auswählen",
"steuerung.schritt": "Nächster Schritt",
"steuerung.test": "Ablaufen",
"steuerung.anhalten": "Anhalten",
"steuerung.bearbeiten": "Bearbeiten",
"steuerung.leeren": "Leeren",
"hilfe.einleitung": "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",
"hilfe.steuerung.titel": "Steuerung",
"hilfe.steuerung.eintrag1": "Links-Klick/Rechts-Klick: Feldtyp wechseln",
"hilfe.steuerung.eintrag2": "Mausrad-Drehen: Feld drehen",
"hilfe.figur.satz1": "Die Figur kann durch Aktoren auf dem Spielplan umher bewegt werden und wird als schwarzer Kreis dargestellt.",
"hilfe.figur.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).",
"hilfe.aktoren.einleitung": "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:",
"hilfe.aktoren.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 Spielfigur auf den Plan gesetzt und bewegt sich anschließend in die angezeigte Richtung.",
"hilfe.aktoren.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.",
"hilfe.aktoren.verwerfer": "Jedes leere Feld beendet den Lauf der Figur mit einer Abweisung des aktuellen Band-Inhalts.",
"hilfe.aktoren.befoerderer": "Dieser Aktor dient dazu die Figur von einem Feld zu einem benachbarten zu befördern ohne dabei den Band-Inhalt zu ändern.",
"hilfe.aktoren.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.",
"hilfe.aktoren.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.",
"hilfe.aufgaben.einleitung": "Ziel ist das Lösen von bestimmten Aufgaben. Dabei wird zwischen zwei Arten von Aufgaben unterschieden:",
"hilfe.aufgaben.akzeptor.erklaerung": "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.",
"hilfe.aufgaben.akzeptor.beispiel": "Beispiel: Genau dann akzeptieren, wenn das Band mindestens zwei mal rot enthält.",
"hilfe.aufgaben.transduktor.erklaerung": "Bei einer Transduktor-Aufgabe soll eine Ausgabe erzeugt werden, die in einer bestimmten Beziehung zur vorgefundenen Eingabe steht, also sozusagen eine Funktion angewendet werden.",
"hilfe.aufgaben.transduktor.beispiel": "Beispiel: Die Eingabe zwei mal wiederholt."
}
}
);

View file

@ -0,0 +1,51 @@
jsonp_behandlung(
{
"schluessel": "zeichenketten-en",
"wert": {
"allgemein.titel": "Crazy Turing Machines",
"allgemein.hilfe": "Help",
"allgemein.spiel": "Game",
"aufbau.figur.worter.singular": "token",
"aufbau.figur.worter.plural": "tokens",
"aufbau.aktoren.woerter.singular": "actor",
"aufbau.aktoren.woerter.plural": "actors",
"aufbau.aktoren.arten.erzeuger.name": "entrance",
"aufbau.aktoren.arten.annehmer.name": "exit",
"aufbau.aktoren.arten.verwerfer.name": "dropper",
"aufbau.aktoren.arten.befoerderer.name": "conveyer",
"aufbau.aktoren.arten.schreiber.name": "writer",
"aufbau.aktoren.arten.leser.name": "switch",
"aufbau.aufgaben.woerter.singular": "task",
"aufbau.aufgaben.woerter.plural": "tasks",
"aufbau.aufgaben.arten.akzeptor.name": "acceptor",
"aufbau.aufgaben.arten.akzeptor.kuerzel": "ACC",
"aufbau.aufgaben.arten.transduktor.name": "transductor",
"aufbau.aufgaben.arten.transduktor.kuerzel": "TRA",
"steuerung.auswaehlen": "choose task",
"steuerung.schritt": "next step",
"steuerung.test": "run",
"steuerung.anhalten": "stop",
"steuerung.bearbeiten": "edit",
"steuerung.leeren": "clear",
"hilfe.einleitung": "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",
"hilfe.steuerung.titel": "controls",
"hilfe.steuerung.eintrag1": "left click/right click: change tile type",
"hilfe.steuerung.eintrag2": "rotate mousewheel: rotate tile",
"hilfe.figur.satz1": "The token can be moved around the board by actors and it is displayed as a black circle.",
"hilfe.figur.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).",
"hilfe.aktoren.einleitung": "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:",
"hilfe.aktoren.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.",
"hilfe.aktoren.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.",
"hilfe.aktoren.verwerfer": "Every empty tile will cancel the tokens run with a rejection of the current tape content.",
"hilfe.aktoren.befoerderer": "This actor is used for moving the token to neighbour tile without changing the tape content.",
"hilfe.aktoren.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.",
"hilfe.aktoren.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.",
"hilfe.aufgaben.einleitung": "The goal is to solve certain tasks. Two kind of tasks are distinguished:",
"hilfe.aufgaben.akzeptor.erklaerung": "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.",
"hilfe.aufgaben.akzeptor.beispiel": "Example: Accept then and only then, if the tape contains at least two red symbols.",
"hilfe.aufgaben.transduktor.erklaerung": "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.",
"hilfe.aufgaben.transduktor.beispiel": "Example: The input repeated two times."
}
}
);

222
quelldatein/haupt.ts Normal file
View file

@ -0,0 +1,222 @@
/*
* 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
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function aufgaben_eintragen(behandler : (aufgabe : mod_aufbau.mod_aufgabe.typ_aufgabe)=>void) : void
{
let aufgaben_roh_ : lib_fehlermonade.typ_fehlermonade<Array<any>> = mod_vtm.mod_daten.lesen("aufgaben");
if (lib_fehlermonade.voll(aufgaben_roh_))
{
let aufgaben_roh : Array<any> = lib_fehlermonade.lesen(aufgaben_roh_);
let dom_auswahl : Element = document.querySelector("#aufgabe_auswahl");
aufgaben_roh.forEach
(
(aufgabe_roh, index) =>
{
// Aufgabe registrieren
{
let aufgabe : mod_aufbau.mod_aufgabe.typ_aufgabe = mod_aufbau.mod_aufgabe.importieren(aufgabe_roh);
mod_aufbau.mod_aufgabe.registrieren(aufgabe);
}
// Option eintragen
{
let praefix : string = (
{
"akzeptor": lib_uebersetzung.holen("aufbau.aufgaben.arten.akzeptor.kuerzel"),
"transduktor": lib_uebersetzung.holen("aufbau.aufgaben.arten.transduktor.kuerzel"),
}[aufgabe_roh["art"]]
);
let titel : string = ("[" + praefix + "]" + " " + aufgabe_roh["parameter"]["titel"]);
let value : string = index.toFixed(0);
let dom_option : Element = document.createElement("option");
dom_option.setAttribute("value", value);
dom_option.textContent = titel;
dom_auswahl.appendChild(dom_option);
}
}
)
;
dom_auswahl.addEventListener
(
"change",
event =>
{
let value : string = dom_auswahl["value"];
let index : int = parseInt(value);
let aufgabe : mod_aufbau.mod_aufgabe.typ_aufgabe = mod_aufbau.mod_aufgabe.holen(index);
behandler(aufgabe);
}
)
;
}
else
{
console.warn("Daten nicht auffindbar");
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function haupt() : void
{
// Übersetzungen
{
let sprachen : Array<string> = navigator.languages.map(sprache => sprache);
let sprache_nativ : string = "de";
if (! sprachen[""+"includes"](sprache_nativ))
sprachen.push(sprache_nativ);
lib_uebersetzung.einrichten(sprachen);
lib_uebersetzung.anwenden(document);
}
// Hilfe
{
// Einleitung
{
document.querySelector("#hilfe_einleitung").innerHTML = (
lib_uebersetzung.holen
(
"hilfe.einleitung",
{
"manufacturia": "<a href=\"http://www.kongregate.com/games/PleasingFungus/manufactoria\">Manufacturia</a>",
"crazy_machines": "<a href=\"http://www.crazy-machines.com/\">Crazy Machines</a>",
"world_of_goo": "<a href=\"http://worldofgoo.com/\">World of Goo</a>",
}
)
);
}
// Aktoren
{
// 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;
[
{
"aufbau": mod_aufbau.mod_aktor.beispiel("erzeuger"),
"bereich": document.querySelector("#hilfe_aktoren_aktor_erzeuger"),
},
{
"aufbau": mod_aufbau.mod_aktor.beispiel("annehmer"),
"bereich": document.querySelector("#hilfe_aktoren_aktor_annehmer"),
},
{
"aufbau": mod_aufbau.mod_aktor.beispiel("verwerfer"),
"bereich": document.querySelector("#hilfe_aktoren_aktor_verwerfer"),
},
{
"aufbau": mod_aufbau.mod_aktor.beispiel("befoerderer"),
"bereich": document.querySelector("#hilfe_aktoren_aktor_befoerderer"),
},
{
"aufbau": mod_aufbau.mod_aktor.beispiel("schreiber"),
"bereich": document.querySelector("#hilfe_aktoren_aktor_schreiber"),
},
{
"aufbau": mod_aufbau.mod_aktor.beispiel("leser"),
"bereich": document.querySelector("#hilfe_aktoren_aktor_leser"),
},
]
.forEach
(
eintrag =>
{
let manifestation = (
mod_manifestation.mod_svg.mod_aktor.erstellen_manifestation
(
eintrag.aufbau,
mod_aufbau.mod_stelle.null_()
)
);
let xmlknoten : lib_xml.typ_knoten = (
mod_manifestation.mod_svg.wurzel
(
von_x, von_y,
bis_x, bis_y,
breite, hoehe,
[mod_manifestation.darstellen(manifestation)]
)
);
eintrag.bereich.querySelector(".hilfe_aktoren_aktor_bild").innerHTML = lib_xml.darstellen(xmlknoten);
}
)
;
}
}
}
// Spiel
{
let partie : mod_aufbau.mod_partie.typ_partie;
// Aufgaben
{
aufgaben_eintragen
(
function (aufgabe : mod_aufbau.mod_aufgabe.typ_aufgabe) : void {mod_aufbau.mod_partie.aufgabe_setzen(partie, aufgabe);}
)
;
}
// Aufbau
{
partie = mod_aufbau.mod_partie.erstellen(mod_aufbau.mod_aufgabe.holen(0));
}
// Manifestationen
{
[
mod_manifestation.mod_web.mod_partie.erstellen_erweitert
(
partie,
document.querySelector("#bereich_mitte")
)
,
mod_manifestation.mod_speicher.mod_partie.erstellen_erweitert
(
partie
)
,
]
.forEach(mod_manifestation.einrichten);
}
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function eingang_web() : void
{
document.addEventListener
(
"DOMContentLoaded",
event => {haupt();}
)
;
}
}

View file

@ -0,0 +1,72 @@
/*
* 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 lib_aufruf
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_komplex<typ_angaben> = {art : string; angaben : typ_angaben;};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function einpacken<typ_angaben>(art : string, angaben : typ_angaben) : typ_komplex<typ_angaben>
{
return {"art": art, "angaben": angaben};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function auspacken<typ_angaben>(komplex : typ_komplex<typ_angaben>) : typ_angaben
{
return komplex.angaben;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function fallunterscheidung<typ_ergebnis>
(
komplex : typ_komplex<any>,
faelle : {[art : string] : (angaben ?: any)=>typ_ergebnis},
ersatz : (komplex : typ_komplex<any>)=>typ_ergebnis = ((komplex) => {throw (new Error("unbehandelt"));})
)
: typ_ergebnis
{
if (komplex.art in faelle)
{
let funktion : (angaben ?: any)=>typ_ergebnis = faelle[komplex.art];
let ergebnis : typ_ergebnis = funktion(komplex.angaben);
return ergebnis;
}
else
{
let meldung : string = ("unbehandelte Art '" + komplex.art + "'");
console.warn(meldung);
let ergebnis : typ_ergebnis = ersatz(komplex);
return ergebnis;
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,22 +17,22 @@
*/ */
namespace lib_trait module lib_brauch
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_trait<type_signature> = {[domain : string] : type_signature}; export type typ_brauch<typ_signatur> = {[domäne : string] : typ_signatur};
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create<type_signature> export function erstellen<typ_signatur>
( (
) )
: type_trait<type_signature> : typ_brauch<typ_signatur>
{ {
return {}; return {};
} }
@ -41,22 +41,22 @@ namespace lib_trait
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function attend<type_signature> export function umsetzen<typ_signatur>
( (
trait : type_trait<type_signature>, brauch : typ_brauch<typ_signatur>,
domain : string, domaene : string,
implementation : type_signature implementierung : typ_signatur
) )
: void : void
{ {
if (domain in trait) if (domaene in brauch)
{ {
let message : string = ("Domäne '" + domain + "' bereits vorhanden"); let meldung : string = ("Domäne '" + domaene + "' bereits vorhanden");
throw (new Error(message)); throw (new Error(meldung));
} }
else else
{ {
trait[domain] = implementation; brauch[domaene] = implementierung;
} }
} }
@ -64,21 +64,21 @@ namespace lib_trait
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function deploy<type_signature> export function anwenden<typ_signatur>
( (
trait : type_trait<type_signature>, brauch : typ_brauch<typ_signatur>,
domain : string domaene : string
) )
: type_signature : typ_signatur
{ {
if (! (domain in trait)) if (! (domaene in brauch))
{ {
let message : string = ("keine Implementierung für Domäne '" + domain + "' vorhanden"); let meldung : string = ("keine Implementierung für Domäne '" + domaene + "' vorhanden");
throw (new Error(message)); throw (new Error(meldung));
} }
else else
{ {
return trait[domain]; return brauch[domaene];
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,27 +16,27 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace lib_errormonade module lib_fehlermonade
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_errormonade<type_value> = lib_call.type_complex<any>; export type typ_fehlermonade<typ_wert> = lib_aufruf.typ_komplex<any>;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_nothing<type_value> export function erstellen_nichts<typ_wert>
( (
) )
: type_errormonade<type_value> : typ_fehlermonade<typ_wert>
{ {
return ( return (
lib_call.wrap<any> lib_aufruf.einpacken<any>
( (
"nothing", "nichts",
{ {
} }
) )
@ -47,18 +47,18 @@ namespace lib_errormonade
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function create_just<type_value> export function erstellen_schlicht<typ_wert>
( (
value : type_value wert : typ_wert
) )
: type_errormonade<type_value> : typ_fehlermonade<typ_wert>
{ {
return ( return (
lib_call.wrap<any> lib_aufruf.einpacken<any>
( (
"just", "schlicht",
{ {
"value": value "wert": wert
} }
) )
); );
@ -68,19 +68,19 @@ namespace lib_errormonade
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function filled<type_value> export function voll<typ_wert>
( (
errormonade : type_errormonade<type_value> fehlermonade : typ_fehlermonade<typ_wert>
) )
: boolean : boolean
{ {
return ( return (
lib_call.distinguish<any> lib_aufruf.fallunterscheidung<any>
( (
errormonade, fehlermonade,
{ {
"nothing": ({}) => false, "nichts": ({}) => false,
"just": ({"value": value}) => true, "schlicht": ({"wert": wert}) => true,
} }
) )
); );
@ -90,19 +90,19 @@ namespace lib_errormonade
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function read<type_value> export function lesen<typ_wert>
( (
errormonade : type_errormonade<type_value> fehlermonade : typ_fehlermonade<typ_wert>
) )
: type_value : typ_wert
{ {
return ( return (
lib_call.distinguish<any> lib_aufruf.fallunterscheidung<any>
( (
errormonade, fehlermonade,
{ {
"nothing": ({}) => {throw (new Error("read von nothing"));}, "nichts": ({}) => {throw (new Error("lesen von nichts"));},
"just": ({"value": value}) => value, "schlicht": ({"wert": wert}) => wert,
} }
) )
); );
@ -112,20 +112,20 @@ namespace lib_errormonade
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function propagate<type_value1, type_value2> export function fortfuehren<typ_wert1, typ_wert2>
( (
errormonade : type_errormonade<type_value1>, fehlermonade : typ_fehlermonade<typ_wert1>,
funktion : (value1 : type_value1)=>type_errormonade<type_value2> funktion : (wert1 : typ_wert1)=>typ_fehlermonade<typ_wert2>
) )
: type_errormonade<type_value2> : typ_fehlermonade<typ_wert2>
{ {
return ( return (
lib_call.distinguish<any> lib_aufruf.fallunterscheidung<any>
( (
errormonade, fehlermonade,
{ {
"nothing": ({}) => create_nothing<type_value2>(), "nichts": ({}) => erstellen_nichts<typ_wert2>(),
"just": ({"value": value1}) => funktion(value1), "schlicht": ({"wert": wert1}) => funktion(wert1),
} }
) )
); );

View file

@ -0,0 +1,110 @@
/*
* 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 lib_hashmap
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_hashmap<typ_schluessel, typ_wert> =
{
hashfunction : (schluessel : typ_schluessel)=>string;
speicher : {[hashwert : string] : {schluessel : typ_schluessel; wert : typ_wert;}};
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen<typ_schluessel, typ_wert>
(
hashfunction : (schluessel : typ_schluessel)=>string
)
: typ_hashmap<typ_schluessel, typ_wert>
{
return {
"hashfunction": hashfunction,
"speicher": {},
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function setzen<typ_schluessel, typ_wert>
(
hashmap : typ_hashmap<typ_schluessel, typ_wert>,
schluessel : typ_schluessel,
wert : typ_wert
)
: void
{
let hashwert : string = hashmap.hashfunction(schluessel);
hashmap.speicher[hashwert] = {"schluessel": schluessel, "wert": wert};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function holen<typ_schluessel, typ_wert>
(
hashmap : typ_hashmap<typ_schluessel, typ_wert>,
schluessel : typ_schluessel
)
: lib_fehlermonade.typ_fehlermonade<typ_wert>
{
let hashwert : string = hashmap.hashfunction(schluessel);
if (hashwert in hashmap.speicher)
{
let wert : typ_wert = hashmap.speicher[hashwert].wert;
return (lib_fehlermonade.erstellen_schlicht<typ_wert>(wert));
}
else
{
return (lib_fehlermonade.erstellen_nichts<typ_wert>());
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function iterieren<typ_schluessel, typ_wert>
(
hashmap : typ_hashmap<typ_schluessel, typ_wert>,
prozedur : (schluessel ?: typ_schluessel, wert ?: typ_wert)=>void
)
: void
{
Object.keys(hashmap.speicher).forEach
(
(hashwert) =>
{
let paar : {schluessel : typ_schluessel; wert : typ_wert;} = hashmap.speicher[hashwert];
prozedur(paar.schluessel, paar.wert);
}
)
;
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,33 +16,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace lib_list module lib_mathematik
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function sequence export function div(x : int, y : int) : int
(
length : int
)
: Array<int>
{ {
return ((length <= 0) ? [] : sequence(length-1).concat([length-1])); return Math.floor(x/y);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function copy<type_element> export function mod(x : int, y : int) : int
(
list : ReadonlyArray<type_element>,
copy_element : (element : type_element)=>type_element = (x => x)
)
: Array<type_element>
{ {
return list.map(copy_element); return (x - (y * div(x, y)));
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View file

@ -0,0 +1,173 @@
/*
* 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 lib_uebersetzung
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _sprachstapel : Array<string>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _daten : {[sprache : string] : {[schluessel : string] : string}} = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function einrichten(sprachen : Array<string>) : void
{
_sprachstapel = [];
sprachen.forEach
(
sprache =>
{
let zeichenketten_roh_ : lib_fehlermonade.typ_fehlermonade<any> = mod_vtm.mod_daten.lesen("zeichenketten-" + sprache);
if (lib_fehlermonade.voll(zeichenketten_roh_))
{
let zeichenketten_roh : {[schluessel : string] : string} = (<{[schluessel : string] : string}>(lib_fehlermonade.lesen(zeichenketten_roh_)));
_daten[sprache] = {};
for (let schluessel in zeichenketten_roh)
{
_daten[sprache][schluessel] = (<string>(zeichenketten_roh[schluessel]));
}
_sprachstapel.push(sprache);
}
else
{
let meldung : string = ("Zeichenketten für Sprache '" + sprache + "' konnten nicht geladen werden");
console.warn(meldung);
}
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function lesen(sprache : string, schluessel : string) : lib_fehlermonade.typ_fehlermonade<string>
{
if (sprache in _daten)
{
let satz : {[schluessel : string] : string} = _daten[sprache];
if (schluessel in satz)
{
return (lib_fehlermonade.erstellen_schlicht<string>(satz[schluessel]));
}
else
{
let meldung : string = ("keine Zeichenketten für Schlüssel '" + schluessel + "' in Sprache '" + sprache + "'");
console.warn(meldung);
return (lib_fehlermonade.erstellen_nichts<string>());
}
}
else
{
let meldung : string = ("keine Zeichenketten für Sprache '" + sprache + "'");
console.warn(meldung);
return (lib_fehlermonade.erstellen_nichts<string>());
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function holen(schluessel : string, vars : {[name : string] : string} = {}) : string
{
let ergebnis : lib_fehlermonade.typ_fehlermonade<string> = (lib_fehlermonade.erstellen_nichts<string>());
let gefunden : boolean = (
_sprachstapel
.some
(
sprache =>
{
let ergebnis_ : lib_fehlermonade.typ_fehlermonade<string> = lesen(sprache, schluessel);
if (lib_fehlermonade.voll(ergebnis_))
{
ergebnis = ergebnis_;
return true;
}
else
{
return false;
}
}
)
);
if (gefunden)
{
let str : string = lib_fehlermonade.lesen(ergebnis);
for (let name in vars)
{
let muster : RegExp = (new RegExp("!var:" + name));
let wert : string = vars[name];
str = str.replace(muster, wert);
}
return str;
}
else
{
return ("{" + schluessel + "}");
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function anwenden(kontext : DocumentFragment) : void
{
let muster : RegExp = (new RegExp("^!translate:([a-z0-9\.]*)$"));
document.querySelectorAll("*")[""+"forEach"]
(
element =>
{
if (element.childElementCount === 0)
{
let inhalt : string = element.textContent;
let fund : any = muster.exec(inhalt);
if (fund != null)
{
let schluessel : string = fund[1];
let inhalt_ : string = holen(schluessel);
element.textContent = inhalt_;
}
else
{
// nichts tun
}
}
else
{
// nichts tun
}
}
)
;
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,53 +16,39 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace lib_math module lib_vektor
{ {
/** /**
* @desc golden ration
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export const phi : float = 0.6180339887498949; export type typ_vektor = {x : float; y : float;};
/** /**
* @desc square
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function sqr(x : float) : float export function polar(winkel : float, radius : float = 1) : typ_vektor
{ {
return (x*x); return {"x": (radius * Math.cos(winkel)), "y": (radius * Math.sin(winkel))};
} }
/** /**
* @desc square root
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function sqrt(x : float) : float export function skalieren(vektor : typ_vektor, faktor : float) : typ_vektor
{ {
return Math.sqrt(x); return {"x": (vektor.x * faktor), "y": (vektor.y * faktor)};
} }
/** /**
* @desc quotient of integer division
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function div(x : int, y : int) : int export function addieren(vektor1 : typ_vektor, vektor2 : typ_vektor) : typ_vektor
{ {
return Math.floor(x/y); return {"x": (vektor1.x + vektor2.x), "y": (vektor1.y + vektor2.y)};
}
/**
* @desc rest of integer division
* @author kcf <vidofnir@folksprak.org>
*/
export function mod(x : int, y : int) : int
{
return (x - (y * div(x, y)));
} }
} }

View file

@ -0,0 +1,55 @@
/*
* 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_helfer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function sequenz(laenge : int) : Array<int>
{
return ((laenge <= 0) ? [] : sequenz(laenge-1).concat([laenge-1]));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function liste_kopieren<type_element>(liste : Array<type_element>, element_kopieren : (element : type_element)=>type_element = (x => x)) : Array<type_element>
{
let liste_ : Array<type_element> = [];
liste.forEach
(
element =>
{
let element_ : type_element = element_kopieren(element);
liste_.push(element);
}
)
;
return liste_;
}
}
}

156
quelldatein/helfer/xml.ts Normal file
View file

@ -0,0 +1,156 @@
/*
* 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 lib_xml
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function einrueckung
(
tiefe : int,
zeichen : string = "\t"
)
: string
{
return (
(tiefe === 0)
? ""
: (zeichen + einrueckung(tiefe-1))
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_knoten = lib_aufruf.typ_komplex<any>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_text
(
inhalt : string
)
: typ_knoten
{
return (
lib_aufruf.einpacken
(
"text",
{
"inhalt": inhalt
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_normal
(
name : string,
attribute : {[schluessel : string] : string} = {},
kinder : Array<typ_knoten> = []
)
: typ_knoten
{
return (
lib_aufruf.einpacken
(
"normal",
{
"name": name,
"attribute": attribute,
"kinder": kinder
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function darstellen
(
knoten : typ_knoten,
tiefe : int = 0
)
: string
{
return (
lib_aufruf.fallunterscheidung<any>
(
knoten,
{
"text": ({"inhalt": inhalt}) =>
{
return inhalt;
}
,
"normal": ({"name": name, "attribute": attribute, "kinder": kinder}) =>
{
let str : string = "";
// anfang
{
let str_anfang : string = "";
str_anfang += name;
// attribute
{
let str_attribute : string = "";
Object.keys(attribute).forEach
(
schluessel =>
{
let wert : string = attribute[schluessel];
str_attribute += (" " + schluessel + "=" + ("\"" + wert + "\""));
}
)
;
str_anfang += str_attribute;
}
str_anfang = (einrueckung(tiefe) + "<" + str_anfang + ">" + "\n");
str += str_anfang;
}
// kinder
{
kinder.forEach(kind => (str += darstellen(kind, tiefe+1)));
}
// ende
{
let str_ende : string = "";
str_ende += name;
str_ende = (einrueckung(tiefe) + "<" + "/" + str_ende + ">" + "\n");
str += str_ende;
}
return str;
}
,
}
)
);
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,25 +16,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_manifestation<type_model> = lib_call.type_complex<any>; export type typ_manifestation<typ_aufbau> = lib_aufruf.typ_komplex<any>;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type signature_manifestation<type_model, type_ausgabe> = export type signatur_manifestation<typ_aufbau, typ_ausgabe> =
{ {
view : (manifestation : type_manifestation<type_model>)=>type_ausgabe; darstellen : (manifestation : typ_manifestation<typ_aufbau>)=>typ_ausgabe;
bind : (manifestation : type_manifestation<type_model>)=>void; binden : (manifestation : typ_manifestation<typ_aufbau>)=>void;
} }
; ;
@ -42,46 +42,46 @@ namespace mod_vtm
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export var trait_manifestation : lib_trait.type_trait<signature_manifestation<any, any>> = lib_trait.create<signature_manifestation<any, any>>(); export var brauch_manifestation : lib_brauch.typ_brauch<signatur_manifestation<any, any>> = lib_brauch.erstellen<signatur_manifestation<any, any>>();
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function view<type_model, type_ausgabe> export function darstellen<typ_aufbau, typ_ausgabe>
( (
manifestation : type_manifestation<type_model> manifestation : typ_manifestation<typ_aufbau>
) )
: type_ausgabe : typ_ausgabe
{ {
return lib_trait.deploy(trait_manifestation, manifestation.kind)["view"](manifestation); return lib_brauch.anwenden(brauch_manifestation, manifestation.art)["darstellen"](manifestation);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function bind<type_model, type_ausgabe> export function binden<typ_aufbau, typ_ausgabe>
( (
manifestation : type_manifestation<type_model> manifestation : typ_manifestation<typ_aufbau>
) )
: void : void
{ {
return lib_trait.deploy(trait_manifestation, manifestation.kind)["bind"](manifestation); return lib_brauch.anwenden(brauch_manifestation, manifestation.art)["binden"](manifestation);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function setup<type_model, type_ausgabe> export function einrichten<typ_aufbau, typ_ausgabe>
( (
manifestation : type_manifestation<type_model> manifestation : typ_manifestation<typ_aufbau>
) )
: void : void
{ {
view<type_model, type_ausgabe>(manifestation); darstellen<typ_aufbau, typ_ausgabe>(manifestation);
bind<type_model, type_ausgabe>(manifestation); binden<typ_aufbau, typ_ausgabe>(manifestation);
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,38 +16,38 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
export namespace mod_position export module mod_position
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type type_position = lib_vector.type_vector; export type typ_position = lib_vektor.typ_vektor;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
var basis1 : type_position = lib_vector.polar((0/6) * (2*Math.PI)); var basis1 : typ_position = lib_vektor.polar((0/6) * (2*Math.PI));
var basis2 : type_position = lib_vector.polar((2/6) * (2*Math.PI)); var basis2 : typ_position = lib_vektor.polar((2/6) * (2*Math.PI));
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function from_spot(spot : mod_vtm.mod_model.mod_spot.type_spot) : type_position export function von_stelle(stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle) : typ_position
{ {
return ( return (
lib_vector.add lib_vektor.addieren
( (
lib_vector.scale(basis1, spot.u), lib_vektor.skalieren(basis1, stelle.u),
lib_vector.scale(basis2, spot.v) lib_vektor.skalieren(basis2, stelle.v)
) )
); );
} }

View file

@ -0,0 +1,172 @@
/*
* 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_speicher
{
export module mod_partie
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_partie =
{
aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen
(
aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie
)
: typ_partie
{
return {
"aufbau": aufbau
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_erweitert
(
aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie
)
: typ_manifestation<mod_vtm.mod_aufbau.mod_partie.typ_partie>
{
return {
"art": "speicher_partie",
"angaben": erstellen(aufbau)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function darstellen(partie : typ_partie) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(partie : typ_partie) : void
{
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_aufgabe",
(angaben) =>
{
// console.info("aenderung_aufgabe", angaben);
let aufgabe : mod_vtm.mod_aufbau.mod_aufgabe.typ_aufgabe = mod_vtm.mod_aufbau.mod_partie.aufgabe_lesen(partie.aufbau);
let id : string = mod_vtm.mod_aufbau.mod_aufgabe.id(aufgabe);
let key : string = ("vtm_" + id);
//
if (key in localStorage)
{
let item : string = localStorage.getItem(key);
let welt_ : any = JSON.parse(item);
let welt : mod_vtm.mod_aufbau.mod_welt.typ_welt = mod_vtm.mod_aufbau.mod_welt.importieren(welt_);
mod_vtm.mod_aufbau.mod_partie.welt_setzen(partie.aufbau, welt, false);
}
else
{
mod_vtm.mod_aufbau.mod_partie.welt_leeren(partie.aufbau);
// nichts tun
}
}
)
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_welt",
(angaben) =>
{
let aufgabe : mod_vtm.mod_aufbau.mod_aufgabe.typ_aufgabe = mod_vtm.mod_aufbau.mod_partie.aufgabe_lesen(partie.aufbau);
let id : string = mod_vtm.mod_aufbau.mod_aufgabe.id(aufgabe);
let key : string = ("vtm_" + id);
//
let welt : mod_vtm.mod_aufbau.mod_welt.typ_welt = mod_vtm.mod_aufbau.mod_partie.welt_lesen(partie.aufbau);
let welt_ : any = mod_vtm.mod_aufbau.mod_welt.exportieren(welt);
let item : string = JSON.stringify(welt_);
localStorage.setItem(key, item);
}
)
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_figur",
(angaben) =>
{
// console.info("aenderung_figur", angaben);
}
)
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_modus",
(angaben) =>
{
// console.info("aenderung_modus", angaben);
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_partie.typ_partie, void>>
(
brauch_manifestation,
"speicher_partie",
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
)
;
}
}
}
}

View file

@ -0,0 +1,163 @@
/*
* 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_praezission : int = 4;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const form_pfeil : 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_praezission)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function translation
(
x : float,
y : float
)
: string
{
return (
"translate"
+ "("
+ x.toFixed(float_praezission)
+ ", "
+ y.toFixed(float_praezission)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function skalierung
(
staerke : float
)
: string
{
return (
"scale"
+ "("
+ staerke.toFixed(float_praezission)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function pfad
(
vertices : Array<lib_vektor.typ_vektor>,
schliessen : boolean = true,
attribute : {[schlussel : string] : string} = {},
)
: lib_xml.typ_knoten
{
let d : string = "";
vertices.forEach
(
(vertex, index) =>
{
let c : string = ((index <= 0) ? "M" : "L");
let x : string = vertex.x.toFixed(float_praezission);
let y : string = vertex.y.toFixed(float_praezission);
d += [c, x, y].join(" ");
}
)
;
if (schliessen)
d += "Z";
attribute["d"] = d;
return (lib_xml.erstellen_normal("path", attribute));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function wurzel
(
von_x : float,
von_y : float,
bis_x : float,
bis_y : float,
hoehe : int = 500,
breite : int = 500,
kinder : Array<lib_xml.typ_knoten> = []
)
: lib_xml.typ_knoten
{
return (
lib_xml.erstellen_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(" "),
},
kinder,
)
);
}
}
}
}

View file

@ -0,0 +1,161 @@
/*
* 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
{
export module mod_aktor
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type signatur_aktor =
{
darstellen : (aktor : mod_vtm.mod_aufbau.mod_aktor.typ_aktor)=>Array<lib_xml.typ_knoten>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export var brauch_aktor : lib_brauch.typ_brauch<signatur_aktor> = lib_brauch.erstellen<signatur_aktor>();
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_aktor =
{
aufbau : mod_vtm.mod_aufbau.mod_aktor.typ_aktor;
stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen
(
aufbau : mod_vtm.mod_aufbau.mod_aktor.typ_aktor,
stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle
)
: typ_aktor
{
return {
"aufbau": aufbau,
"stelle": stelle
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_manifestation
(
aufbau : mod_vtm.mod_aufbau.mod_aktor.typ_aktor,
stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle
)
: typ_manifestation<mod_vtm.mod_aufbau.mod_aktor.typ_aktor>
{
return {
"art": "svg_aktor",
"angaben": erstellen(aufbau, stelle),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function darstellen(aktor_ : typ_aktor) : lib_xml.typ_knoten
{
let aktor : mod_vtm.mod_aufbau.mod_aktor.typ_aktor = aktor_.aufbau;
let knoten_rahmen = function () : lib_xml.typ_knoten
{
return (
pfad
(
mod_vtm.mod_helfer.sequenz(6).map(i => lib_vektor.polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true,
{
"class": "rahmen"
}
)
);
}
;
let position : mod_position.typ_position = mod_position.von_stelle(aktor_.stelle);
let knoten_feld : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"g",
{
"class": "feld",
"rel": mod_vtm.mod_aufbau.mod_stelle.hash(aktor_.stelle),
"transform": translation(position.x, position.y),
},
(
[knoten_rahmen()]
.concat(lib_brauch.anwenden<signatur_aktor>(brauch_aktor, aktor.art)["darstellen"](aktor))
)
)
);
return knoten_feld;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(aktor : typ_aktor) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_aktor.typ_aktor, lib_xml.typ_knoten>>
(
brauch_manifestation,
"svg_aktor",
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
)
;
}
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,48 +16,48 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
export namespace mod_svg export module mod_svg
{ {
export namespace mod_actuator export module mod_aktor
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend lib_brauch.umsetzen
( (
trait_actuator, brauch_aktor,
"rejector", "annehmer",
{ {
"view": (actuator) => "darstellen": (aktor) =>
{ {
let children : Array<lib_xml.type_node> = []; let kinder : Array<lib_xml.typ_knoten> = [];
let node_circle : lib_xml.type_node = ( let knoten_kreis : lib_xml.typ_knoten = (
lib_xml.create_normal lib_xml.erstellen_normal
( (
"circle", "circle",
{ {
"cx": (0.0).toFixed(lib_svg.float_precision), "cx": (0.0).toFixed(float_praezission),
"cy": (0.0).toFixed(lib_svg.float_precision), "cy": (0.0).toFixed(float_praezission),
"r": (0.25).toFixed(lib_svg.float_precision), "r": (0.25).toFixed(float_praezission),
"class": ( "class": (
[ [
"circle", "kreis",
"negative", "positiv",
].join(" ") ].join(" ")
), ),
} }
) )
); );
children.push(node_circle); kinder.push(knoten_kreis);
return children; return kinder;
} }
, ,
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,53 +16,53 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
export namespace mod_svg export module mod_svg
{ {
export namespace mod_actuator export module mod_aktor
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend lib_brauch.umsetzen
( (
trait_actuator, brauch_aktor,
"conveyer", "befoerderer",
{ {
"view": ({"data": {"direction": direction}}) => "darstellen": ({"angaben": {"richtung": richtung}}) =>
{ {
let children : Array<lib_xml.type_node> = []; let kinder : Array<lib_xml.typ_knoten> = [];
let node_arrow : lib_xml.type_node = ( let knoten_pfeil : lib_xml.typ_knoten = (
lib_xml.create_normal lib_xml.erstellen_normal
( (
"path", "path",
{ {
"d": shape_arrow_1, "d": form_pfeil,
"class": ( "class": (
[ [
"arrow", "pfeil",
"neutral", "neutral",
].join(" ") ].join(" ")
), ),
"transform": ( "transform": (
[ [
lib_svg.rotation(direction/6), rotation(richtung/6),
lib_svg.translation(-0.2, 0), translation(-0.2, 0),
lib_svg.scaling(0.12), skalierung(0.12),
].join(" ") ].join(" ")
), ),
} }
) )
); );
children.push(node_arrow); kinder.push(knoten_pfeil);
return children; return kinder;
} }
, ,
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,53 +16,53 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
export namespace mod_svg export module mod_svg
{ {
export namespace mod_actuator export module mod_aktor
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend lib_brauch.umsetzen
( (
trait_actuator, brauch_aktor,
"generator", "erzeuger",
{ {
"view": ({"data": {"direction": direction}}) => "darstellen": ({"angaben": {"richtung": richtung}}) =>
{ {
let children : Array<lib_xml.type_node> = []; let kinder : Array<lib_xml.typ_knoten> = [];
let node_arrow : lib_xml.type_node = ( let knoten_pfeil : lib_xml.typ_knoten = (
lib_xml.create_normal lib_xml.erstellen_normal
( (
"path", "path",
{ {
"d": shape_arrow_1, "d": form_pfeil,
"class": ( "class": (
[ [
"arrow", "pfeil",
"generator", "erzeuger",
].join(" ") ].join(" ")
), ),
"transform": ( "transform": (
[ [
lib_svg.rotation(direction/6), rotation(richtung/6),
lib_svg.translation(-0.2, 0), translation(-0.2, 0),
lib_svg.scaling(0.12), skalierung(0.12),
].join(" ") ].join(" ")
), ),
} }
) )
); );
children.push(node_arrow); kinder.push(knoten_pfeil);
return children; return kinder;
} }
, ,
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,87 +16,87 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
export namespace mod_svg export module mod_svg
{ {
export namespace mod_actuator export module mod_aktor
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend lib_brauch.umsetzen
( (
trait_actuator, brauch_aktor,
"reader", "leser",
{ {
"view": ({"data": {"direction": direction, "symbol_links": symbol_links, "symbol_rechts": symbol_rechts}}) => "darstellen": ({"angaben": {"richtung": richtung, "symbol_links": symbol_links, "symbol_rechts": symbol_rechts}}) =>
{ {
let children : Array<lib_xml.type_node> = []; let kinder : Array<lib_xml.typ_knoten> = [];
type type_entry = type typ_eintrag =
{ {
summand : mod_vtm.mod_model.mod_direction.type_direction; summand : mod_vtm.mod_aufbau.mod_richtung.typ_richtung;
symbol : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_symbol.type_symbol>; symbol : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>;
} }
; ;
let ausgaenge : Array<type_entry> = let ausgaenge : Array<typ_eintrag> =
[ [
{ {
"summand": 0, "summand": 0,
"symbol": lib_errormonade.create_nothing<mod_vtm.mod_model.mod_symbol.type_symbol>(), "symbol": lib_fehlermonade.erstellen_nichts<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>(),
}, },
{ {
"summand": +2, "summand": +2,
"symbol": lib_errormonade.create_just<mod_vtm.mod_model.mod_symbol.type_symbol>(symbol_links), "symbol": lib_fehlermonade.erstellen_schlicht<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>(symbol_links),
}, },
{ {
"summand": -2, "summand": -2,
"symbol": lib_errormonade.create_just<mod_vtm.mod_model.mod_symbol.type_symbol>(symbol_rechts), "symbol": lib_fehlermonade.erstellen_schlicht<mod_vtm.mod_aufbau.mod_symbol.typ_symbol>(symbol_rechts),
}, },
] ]
; ;
ausgaenge.forEach ausgaenge.forEach
( (
entry => eintrag =>
{ {
let anglestaerke : float = (mod_vtm.mod_model.mod_direction.add(direction, entry.summand) / 6); let winkelstaerke : float = (mod_vtm.mod_aufbau.mod_richtung.addieren(richtung, eintrag.summand) / 6);
let node_arrow : lib_xml.type_node = ( let knoten_pfeil : lib_xml.typ_knoten = (
lib_xml.create_normal lib_xml.erstellen_normal
( (
"path", "path",
{ {
"d": shape_arrow_2, "d": form_pfeil,
"class": ( "class": (
[ [
"arrow", "pfeil",
( (
lib_errormonade.filled<mod_model.mod_symbol.type_symbol>(entry.symbol) lib_fehlermonade.voll<mod_aufbau.mod_symbol.typ_symbol>(eintrag.symbol)
? "symbol_" + lib_errormonade.read<mod_model.mod_symbol.type_symbol>(entry.symbol).toFixed(0) ? "symbol_" + lib_fehlermonade.lesen<mod_aufbau.mod_symbol.typ_symbol>(eintrag.symbol).toFixed(0)
: "neutral" : "neutral"
), ),
].join(" ") ].join(" ")
), ),
"transform": ( "transform": (
[ [
lib_svg.rotation(anglestaerke), rotation(winkelstaerke),
lib_svg.translation(+0.1, 0), translation(+0.1, 0),
lib_svg.scaling(0.075), skalierung(0.075),
].join(" ") ].join(" ")
), ),
} }
) )
); );
children.push(node_arrow); kinder.push(knoten_pfeil);
} }
) )
; ;
return children; return kinder;
} }
, ,
} }

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,53 +16,53 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace mod_vtm module mod_vtm
{ {
export namespace mod_manifestation export module mod_manifestation
{ {
export namespace mod_svg export module mod_svg
{ {
export namespace mod_actuator export module mod_aktor
{ {
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
lib_trait.attend lib_brauch.umsetzen
( (
trait_actuator, brauch_aktor,
"writer", "schreiber",
{ {
"view": ({"data": {"direction": direction, "symbol": symbol}}) => "darstellen": ({"angaben": {"richtung": richtung, "symbol": symbol}}) =>
{ {
let children : Array<lib_xml.type_node> = []; let kinder : Array<lib_xml.typ_knoten> = [];
let node_arrow : lib_xml.type_node = ( let knoten_pfeil : lib_xml.typ_knoten = (
lib_xml.create_normal lib_xml.erstellen_normal
( (
"path", "path",
{ {
"d": shape_arrow_1, "d": form_pfeil,
"class": ( "class": (
[ [
"arrow", "pfeil",
"symbol_" + symbol.toFixed(0), "symbol_" + symbol.toFixed(0),
].join(" ") ].join(" ")
), ),
"transform": ( "transform": (
[ [
lib_svg.rotation(direction/6), rotation(richtung/6),
lib_svg.translation(-0.2, 0), translation(-0.2, 0),
lib_svg.scaling(0.12), skalierung(0.12),
].join(" ") ].join(" ")
), ),
} }
) )
); );
children.push(node_arrow); kinder.push(knoten_pfeil);
return children; return kinder;
} }
, ,
} }

View file

@ -0,0 +1,74 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm
{
export module mod_manifestation
{
export module mod_svg
{
export module mod_aktor
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen
(
brauch_aktor,
"verwerfer",
{
"darstellen": (aktor) =>
{
let kinder : Array<lib_xml.typ_knoten> = [];
let knoten_kreis : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"circle",
{
"cx": (0.0).toFixed(float_praezission),
"cy": (0.0).toFixed(float_praezission),
"r": (0.25).toFixed(float_praezission),
"class": (
[
"kreis",
"negativ",
].join(" ")
),
}
)
);
kinder.push(knoten_kreis);
return kinder;
}
,
}
)
;
}
}
}
}

View file

@ -0,0 +1,194 @@
/*
* 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
{
export module mod_figur
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_figur =
{
aufbau : mod_vtm.mod_aufbau.mod_figur.typ_figur;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen
(
aufbau : mod_vtm.mod_aufbau.mod_figur.typ_figur
)
: typ_figur
{
return {
"aufbau": aufbau,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_manifestation
(
aufbau : mod_vtm.mod_aufbau.mod_figur.typ_figur
)
: typ_manifestation<mod_vtm.mod_aufbau.mod_figur.typ_figur>
{
return {
"art": "svg_figur",
"angaben": erstellen(aufbau),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function darstellen
(
figur_ : typ_figur
)
: lib_xml.typ_knoten
{
let figur : mod_vtm.mod_aufbau.mod_figur.typ_figur = figur_.aufbau;
let kinder_figur : Array<lib_xml.typ_knoten> = [];
// Stein
{
let knoten_stein : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"circle",
{
"cx": (0.0).toFixed(float_praezission),
"cy": (0.0).toFixed(float_praezission),
"r": (0.125).toFixed(float_praezission),
"class": "stein",
}
)
);
kinder_figur.push(knoten_stein);
}
// Band
{
let band : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol> = mod_vtm.mod_aufbau.mod_figur.band_lesen(figur);
let kinder_band : Array<lib_xml.typ_knoten> = [];
band.forEach
(
(symbol, index) =>
{
let r : float = 0.06125;
let x : float = (+0.1+(2*r*1.25)*index);
let y : float = (-0.1);
let knoten_eintrag : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"circle",
{
"cx": x.toFixed(float_praezission),
"cy": y.toFixed(float_praezission),
"r": r.toFixed(float_praezission),
/*
"x": (x-r).toFixed(float_praezission),
"y": (y-r).toFixed(float_praezission),
"width": (2*r).toFixed(float_praezission),
"height": (2*r).toFixed(float_praezission),
*/
"class": (
[
"eintrag",
"symbol_" + symbol.toFixed(0),
].join(" ")
),
}
)
);
kinder_band.push(knoten_eintrag);
}
)
;
let knoten_band = (
lib_xml.erstellen_normal
(
"g",
{
"class": "band",
},
kinder_band
)
);
kinder_figur.push(knoten_band);
}
let position : mod_position.typ_position = mod_position.von_stelle(mod_vtm.mod_aufbau.mod_figur.stelle_lesen(figur));
let knoten_figur = (
lib_xml.erstellen_normal
(
"g",
{
"class": "figur",
"transform": translation(position.x, position.y),
},
kinder_figur
)
);
return knoten_figur;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(figur : typ_figur) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_figur.typ_figur, lib_xml.typ_knoten>>
(
brauch_manifestation,
"svg_figur",
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
)
;
}
}
}
}

View file

@ -0,0 +1,169 @@
/*
* 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
{
export module mod_partie
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_partie =
{
aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen(aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie) : typ_partie
{
return {
"aufbau": aufbau
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_manifestation(aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie) : typ_manifestation<mod_vtm.mod_aufbau.mod_partie.typ_partie>
{
return {
"art": "svg_partie",
"angaben": erstellen(aufbau)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function darstellen(partie : typ_partie) : lib_xml.typ_knoten
{
let kinder_partie : Array<lib_xml.typ_knoten> = [];
// Welt
{
let kinder_welt : Array<lib_xml.typ_knoten> = [];
// Felder
{
let kinder_felder : Array<lib_xml.typ_knoten> = [];
mod_vtm.mod_aufbau.mod_welt.felder_lesen(mod_vtm.mod_aufbau.mod_partie.welt_lesen(partie.aufbau)).forEach
(
({"stelle": stelle, "aktor": aktor}) =>
{
let manifestation_feld : typ_manifestation<mod_vtm.mod_aufbau.mod_aktor.typ_aktor> = mod_aktor.erstellen_manifestation(aktor, stelle);
let knoten_feld : lib_xml.typ_knoten = mod_manifestation.darstellen(manifestation_feld);
kinder_felder.push(knoten_feld);
}
)
;
let knoten_felder : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"g",
{
"class": "felder",
},
kinder_felder
)
);
kinder_welt.push(knoten_felder);
}
let knoten_welt : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"g",
{
"class": "welt",
},
kinder_welt
)
);
kinder_partie.push(knoten_welt);
}
// Figur
{
let figur_ : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_figur.typ_figur> = mod_vtm.mod_aufbau.mod_partie.figur_lesen(partie.aufbau);
if (lib_fehlermonade.voll(figur_))
{
let figur : mod_vtm.mod_aufbau.mod_figur.typ_figur = lib_fehlermonade.lesen(figur_);
let manifestation_figur : typ_manifestation<mod_vtm.mod_aufbau.mod_figur.typ_figur> = mod_figur.erstellen_manifestation(figur);
let knoten_figur : lib_xml.typ_knoten = mod_manifestation.darstellen(manifestation_figur);
kinder_partie.push(knoten_figur);
}
else
{
// nichts tun
}
}
let knoten_partie : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"g",
{
"class": "partie",
},
kinder_partie
)
);
return knoten_partie;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(partie : typ_partie) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_partie.typ_partie, lib_xml.typ_knoten>>
(
brauch_manifestation,
"svg_partie",
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
)
;
}
}
}
}

View file

@ -1,6 +1,6 @@
/* /*
* Verrückte Turing-Maschinen A turing complete game * Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,26 +17,30 @@
*/ */
$phi: 0.6180339887498949; $phi: 0.6180339887498949;
// $sigma: $phi;
$sigma: 0.25;
$offset: 0.0; /*
$hue_symbol_0: (((($sigma*0)+$offset)%1)*360); $farbton_symbol_0: 000.0000000000000;
$hue_symbol_1: (((($sigma*1)+$offset)%1)*360); $farbton_symbol_1: 222.4922359499621;
$hue_symbol_2: (((($sigma*2)+$offset)%1)*360); $farbton_symbol_2: 084.9844718999243;
$hue_symbol_3: (((($sigma*3)+$offset)%1)*360); $farbton_symbol_3: 307.4767078498864;
*/
$offset: 0;
$farbton_symbol_0: ((($phi*($offset+0))%1)*360);
$farbton_symbol_1: ((($phi*($offset+1))%1)*360);
$farbton_symbol_2: ((($phi*($offset+2))%1)*360);
$farbton_symbol_3: ((($phi*($offset+3))%1)*360);
$saturation_symbol: 75%; $saettigung_symbol: 50%;
$lightness_symbol: 50%; $helligkeit_symbol: 50%;
.frame .rahmen
{ {
stroke: none; stroke: none;
fill: hsl( 0, 0%, 25%); fill: hsl( 0, 0%, 25%);
} }
.frame:hover .rahmen:hover
{ {
/* /*
fill: hsl( 0, 0%, 37.5%); fill: hsl( 0, 0%, 37.5%);
@ -44,18 +48,18 @@ $lightness_symbol: 50%;
*/ */
} }
.token .figur
{ {
stroke: none; stroke: none;
fill: hsl( 0, 0%, 0%); fill: hsl( 0, 0%, 0%);
} }
.arrow .pfeil
{ {
stroke: none; stroke: none;
} }
.generator .erzeuger
{ {
fill: hsl( 0, 0%, 100%); fill: hsl( 0, 0%, 100%);
} }
@ -67,39 +71,39 @@ $lightness_symbol: 50%;
.symbol_0 .symbol_0
{ {
fill: hsl($hue_symbol_0, $saturation_symbol, $lightness_symbol); fill: hsl($farbton_symbol_0, $saettigung_symbol, $helligkeit_symbol);
background-color: hsl($hue_symbol_0, $saturation_symbol, $lightness_symbol); background-color: hsl($farbton_symbol_0, $saettigung_symbol, $helligkeit_symbol);
} }
.symbol_1 .symbol_1
{ {
fill: hsl($hue_symbol_1, $saturation_symbol, $lightness_symbol); fill: hsl($farbton_symbol_1, $saettigung_symbol, $helligkeit_symbol);
background-color: hsl($hue_symbol_1, $saturation_symbol, $lightness_symbol); background-color: hsl($farbton_symbol_1, $saettigung_symbol, $helligkeit_symbol);
} }
.symbol_2 .symbol_2
{ {
fill: hsl($hue_symbol_2, $saturation_symbol, $lightness_symbol); fill: hsl($farbton_symbol_2, $saettigung_symbol, $helligkeit_symbol);
background-color: hsl($hue_symbol_2, $saturation_symbol, $lightness_symbol); background-color: hsl($farbton_symbol_2, $saettigung_symbol, $helligkeit_symbol);
} }
.symbol_3 .symbol_3
{ {
fill: hsl($hue_symbol_3, $saturation_symbol, $lightness_symbol); fill: hsl($farbton_symbol_3, $saettigung_symbol, $helligkeit_symbol);
background-color: hsl($hue_symbol_3, $saturation_symbol, $lightness_symbol); background-color: hsl($farbton_symbol_3, $saettigung_symbol, $helligkeit_symbol);
} }
.circle .kreis
{ {
stroke: none; stroke: none;
} }
.positive .positiv
{ {
fill: hsl( 0, 0%, 100%); fill: hsl( 0, 0%, 100%);
} }
.negative .negativ
{ {
/* /*
fill: hsl( 0, 0%, 0%); fill: hsl( 0, 0%, 0%);
@ -107,7 +111,7 @@ $lightness_symbol: 50%;
display: none; display: none;
} }
.entry .eintrag
{ {
/* /*
stroke: black; stroke: black;

View file

@ -0,0 +1,493 @@
/*
* 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_web
{
export module mod_partie
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function text_nachbearbeiten(text : string) : string
{
let regexp : RegExp = (new RegExp("\\$\{s(\\d*)\}", "g"));
return text.replace(regexp, "<span class=\"symbol_$1\">&nbsp;&nbsp;</span>");
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_partie =
{
aufbau : mod_aufbau.mod_partie.typ_partie;
bereich : Element;
intervall : lib_fehlermonade.typ_fehlermonade<any>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen
(
aufbau : mod_aufbau.mod_partie.typ_partie,
bereich : Element
)
: typ_partie
{
return {
"aufbau": aufbau,
"bereich": bereich,
"intervall": (lib_fehlermonade.erstellen_nichts<any>()),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_erweitert
(
aufbau : mod_aufbau.mod_partie.typ_partie,
bereich : Element
)
: typ_manifestation<mod_aufbau.mod_partie.typ_partie>
{
return {
"art": "web_partie",
"angaben": erstellen(aufbau, bereich)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erneuern_aufgabe(partie : typ_partie) : void
{
document.querySelector("#aufgabe_text").innerHTML = (
text_nachbearbeiten
(
mod_vtm.mod_aufbau.mod_aufgabe.text
(
mod_vtm.mod_aufbau.mod_partie.aufgabe_lesen(partie.aufbau)
)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erneuern_welt(partie : typ_partie) : void
{
let knoten_svg : lib_xml.typ_knoten = mod_svg.wurzel
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.darstellen(mod_svg.mod_partie.erstellen_manifestation(partie.aufbau))]
)
;
partie.bereich.innerHTML = lib_xml.darstellen(knoten_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erneuern_figur(partie : typ_partie) : void
{
let knoten_svg : lib_xml.typ_knoten = mod_svg.wurzel
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.darstellen(mod_svg.mod_partie.erstellen_manifestation(partie.aufbau))]
)
;
partie.bereich.innerHTML = lib_xml.darstellen(knoten_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erneuern_modus(partie : typ_partie) : void
{
let status : string;
switch (mod_vtm.mod_aufbau.mod_partie.modus_lesen(partie.aufbau))
{
case mod_vtm.mod_aufbau.mod_modus.initial:
{
status = "Maschine aufbauen";
break;
}
case mod_vtm.mod_aufbau.mod_modus.ungewiss:
{
status = "wird geprüft …";
break;
}
case mod_vtm.mod_aufbau.mod_modus.fehlerhaft:
{
status = "fehlerhaft :/";
break;
}
case mod_vtm.mod_aufbau.mod_modus.korrekt:
{
status = "anscheinend korrekt :)";
break;
}
default:
{
let meldung : string = "unbehandelter Modus";
throw (new Error(meldung));
break;
}
}
document.querySelector("#aufgabe_status").textContent = status;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erneuern_knoepfe(partie : typ_partie) : void
{
let modus : mod_vtm.mod_aufbau.mod_modus.typ_modus = mod_vtm.mod_aufbau.mod_partie.modus_lesen(partie.aufbau);
let klasse : string;
switch (modus)
{
case mod_vtm.mod_aufbau.mod_modus.initial:
{
klasse = "initial";
break;
}
case mod_vtm.mod_aufbau.mod_modus.ungewiss:
{
klasse = (
lib_fehlermonade.voll<any>(partie.intervall)
? "ungewiss_laufend"
: "ungewiss_stehend"
);
break;
}
case mod_vtm.mod_aufbau.mod_modus.fehlerhaft:
case mod_vtm.mod_aufbau.mod_modus.korrekt:
{
klasse = "fertig";
break;
}
default:
{
throw (new Error("unbehandelt!"));
break;
}
}
document.querySelector("#knoepfe").setAttribute("class", klasse);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function darstellen(partie : typ_partie) : void
{
erneuern_aufgabe(partie);
erneuern_welt(partie);
erneuern_figur(partie);
erneuern_modus(partie);
erneuern_knoepfe(partie);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function anhalten(partie : typ_partie) : void
{
if (lib_fehlermonade.voll(partie.intervall))
{
clearInterval(lib_fehlermonade.lesen(partie.intervall));
partie.intervall = (lib_fehlermonade.erstellen_nichts<any>());
}
else
{
let meldung : string = "kein Intervall gesetzt";
console.warn(meldung);
}
erneuern_knoepfe(partie);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function fortfahren(partie : typ_partie) : void
{
mod_vtm.mod_aufbau.mod_partie.fortfahren(partie.aufbau);
let modus : mod_vtm.mod_aufbau.mod_modus.typ_modus = mod_vtm.mod_aufbau.mod_partie.modus_lesen(partie.aufbau);
if (modus <= 1)
{
// nichts tun
}
else
{
anhalten(partie);
}
erneuern_knoepfe(partie);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function testen(partie : typ_partie) : void
{
let handle : any = setInterval(() => fortfahren(partie), 500);
partie.intervall = (lib_fehlermonade.erstellen_schlicht<any>(handle));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bearbeiten(partie : typ_partie) : void
{
anhalten(partie);
mod_vtm.mod_aufbau.mod_partie.zuruecksetzen(partie.aufbau);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function leeren(partie : typ_partie) : void
{
mod_vtm.mod_aufbau.mod_partie.welt_leeren(partie.aufbau);
mod_vtm.mod_aufbau.mod_partie.zuruecksetzen(partie.aufbau);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(partie : typ_partie) : void
{
let stelle_ermitteln = (target : EventTarget) =>
{
let stelle : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_stelle.typ_stelle>;
let dom_feld : Element = target["closest"](".feld");
if (dom_feld == null)
{
stelle = (lib_fehlermonade.erstellen_nichts<mod_vtm.mod_aufbau.mod_stelle.typ_stelle>());
}
else
{
let rel : string = dom_feld.getAttribute("rel")
stelle = (lib_fehlermonade.erstellen_schlicht<mod_vtm.mod_aufbau.mod_stelle.typ_stelle>(mod_vtm.mod_aufbau.mod_stelle.von_hash(rel)));
}
return stelle;
}
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_aufgabe",
(angaben) =>
{
erneuern_aufgabe(partie);
}
)
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_welt",
(angaben) =>
{
erneuern_welt(partie);
}
)
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_figur",
(angaben) =>
{
erneuern_figur(partie);
}
)
;
mod_vtm.mod_aufbau.mod_partie.lauschen
(
partie.aufbau,
"aenderung_modus",
(angaben) =>
{
erneuern_modus(partie);
erneuern_knoepfe(partie);
}
)
;
// Links-Klick
partie.bereich.addEventListener
(
"click",
event =>
{
event.preventDefault();
let stelle_ : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_stelle.typ_stelle> = stelle_ermitteln(event.target);
if (lib_fehlermonade.voll(stelle_))
{
mod_vtm.mod_aufbau.mod_partie.welt_feld_wechseln(partie.aufbau, lib_fehlermonade.lesen(stelle_), false);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Rechts-Klick
partie.bereich.addEventListener
(
"contextmenu",
event =>
{
event.preventDefault();
let stelle_ : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_stelle.typ_stelle> = stelle_ermitteln(event.target);
if (lib_fehlermonade.voll(stelle_))
{
mod_vtm.mod_aufbau.mod_partie.welt_feld_wechseln(partie.aufbau, lib_fehlermonade.lesen(stelle_), true);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Mausrad
partie.bereich.addEventListener
(
"wheel",
event =>
{
event.preventDefault();
let stelle_ : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_stelle.typ_stelle> = stelle_ermitteln(event.target);
if (lib_fehlermonade.voll(stelle_))
{
let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1);
mod_vtm.mod_aufbau.mod_partie.welt_feld_drehen(partie.aufbau, lib_fehlermonade.lesen(stelle_), inkrement);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Schritt
document.querySelector("#knopf_schritt").addEventListener
(
"click",
event =>
{
anhalten(partie);
fortfahren(partie);
}
)
;
// Testen
document.querySelector("#knopf_testen").addEventListener
(
"click",
event =>
{
testen(partie);
}
)
;
// Anhalten
document.querySelector("#knopf_anhalten").addEventListener
(
"click",
event =>
{
anhalten(partie);
}
)
;
// Bearbeiten
document.querySelector("#knopf_bearbeiten").addEventListener
(
"click",
event =>
{
bearbeiten(partie);
}
)
;
// Leeren
document.querySelector("#knopf_leeren").addEventListener
(
"click",
event =>
{
leeren(partie);
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_partie.typ_partie, void>>
(
brauch_manifestation,
"web_partie",
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
)
;
}
}
}
}

View file

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="vtm.js"></script>
<script type="text/javascript" src="vtm.dat.js"></script>
<script type="text/javascript">mod_vtm.eingang_web();</script>
<link rel="stylesheet" type="text/css" href="vtm.css"/>
</head>
<body>
<header>!translate:allgemein.titel</header>
<label for="radio_hilfe"><a>!translate:allgemein.hilfe</a></label><input type="radio" name="tab" id="radio_hilfe" checked="checked"/>
<label for="radio_spiel"><a>!translate:allgemein.spiel</a></label><input type="radio" name="tab" id="radio_spiel"/>
<!--
<hr/>
-->
<div id="spiel">
<div class="bereich" id="bereich_links">
<label for="aufgabe_auswahl">!translate:steuerung.auswaehlen</label>
<select id="aufgabe_auswahl"></select>
<p id="aufgabe_text"></p>
<hr/>
<div id="aufgabe_status"></div>
<div id="knoepfe">
<button id="knopf_schritt">!translate:steuerung.schritt</button>
<button id="knopf_testen">!translate:steuerung.test</button>
<button id="knopf_anhalten">!translate:steuerung.anhalten</button>
<button id="knopf_bearbeiten">!translate:steuerung.bearbeiten</button>
<button id="knopf_leeren">!translate:steuerung.leeren</button>
</div>
</div>
<div class="bereich" id="bereich_mitte">
</div>
<div class="bereich" id="bereich_rechts">
</div>
</div>
<div id="hilfe">
<p id="hilfe_einleitung"></p>
<section class="bereich">
<header id="hilfe_steuerung_titel">!translate:hilfe.steuerung.titel</header>
<ul>
<li id="hilfe_steuerung_eintrag1">!translate:hilfe.steuerung.eintrag1</li>
<li id="hilfe_steuerung_eintrag2">!translate:hilfe.steuerung.eintrag2</li>
</ul>
</section>
<section class="bereich">
<header id="hilfe_figur_titel">!translate:aufbau.figur.worter.singular</header>
<p id="hilfe_figur_satz1">!translate:hilfe.figur.satz1</p>
<p id="hilfe_figur_satz2">!translate:hilfe.figur.satz2</p>
</section>
<section class="bereich" id="hilfe_aktoren">
<header id="hilfe_aktoren_titel">!translate:aufbau.aktoren.woerter.plural</header>
<p id="hilfe_aktoren_einleitung">!translate:hilfe.aktoren.einleitung</p>
<ul>
<li class="hilfe_aktoren_aktor" id="hilfe_aktoren_aktor_erzeuger">
<header class="hilfe_aktoren_aktor_name">!translate:aufbau.aktoren.arten.erzeuger.name</header>
<div class="hilfe_aktoren_aktor_bild"></div>
<div class="hilfe_aktoren_aktor_text">!translate:hilfe.aktoren.erzeuger</div>
</li>
<li class="hilfe_aktoren_aktor" id="hilfe_aktoren_aktor_annehmer">
<header class="hilfe_aktoren_aktor_name">!translate:aufbau.aktoren.arten.annehmer.name</header>
<div class="hilfe_aktoren_aktor_bild"></div>
<div class="hilfe_aktoren_aktor_text">!translate:hilfe.aktoren.annehmer</div>
</li>
<li class="hilfe_aktoren_aktor" id="hilfe_aktoren_aktor_verwerfer">
<header class="hilfe_aktoren_aktor_name">!translate:aufbau.aktoren.arten.verwerfer.name</header>
<div class="hilfe_aktoren_aktor_bild"></div>
<div class="hilfe_aktoren_aktor_text">!translate:hilfe.aktoren.verwerfer</div>
</li>
<li class="hilfe_aktoren_aktor" id="hilfe_aktoren_aktor_befoerderer">
<header class="hilfe_aktoren_aktor_name">!translate:aufbau.aktoren.arten.befoerderer.name</header>
<div class="hilfe_aktoren_aktor_bild"></div>
<div class="hilfe_aktoren_aktor_text">!translate:hilfe.aktoren.befoerderer</div>
</li>
<li class="hilfe_aktoren_aktor" id="hilfe_aktoren_aktor_schreiber">
<header class="hilfe_aktoren_aktor_name">!translate:aufbau.aktoren.arten.schreiber.name</header>
<div class="hilfe_aktoren_aktor_bild"></div>
<div class="hilfe_aktoren_aktor_text">!translate:hilfe.aktoren.schreiber</div>
</li>
<li class="hilfe_aktoren_aktor" id="hilfe_aktoren_aktor_leser">
<header class="hilfe_aktoren_aktor_name">!translate:aufbau.aktoren.arten.leser.name</header>
<div class="hilfe_aktoren_aktor_bild"></div>
<div class="hilfe_aktoren_aktor_text">!translate:hilfe.aktoren.leser</div>
</li>
</ul>
</section>
<section class="bereich">
<header id="hilfe_aufgaben_titel">!translate:aufbau.aufgaben.woerter.plural</header>
<p id="hilfe_aufgaben_einleitung">!translate:hilfe.aufgaben.einleitung</p>
<ul>
<li id="hilfe_aufgaben_akzeptor">
<header id="hilfe_aufgaben_akzeptor_name">!translate:aufbau.aufgaben.arten.akzeptor.name</header>
<p id="hilfe_aufgaben_akzeptor_erklaerung">!translate:hilfe.aufgaben.akzeptor.erklaerung</p>
<p id="hilfe_aufgaben_akzeptor_beispiel">!translate:hilfe.aufgaben.akzeptor.beispiel</p>
</li>
<li id="hilfe_aufgaben_transduktor">
<header id="hilfe_aufgaben_akzeptor_name">!translate:aufbau.aufgaben.arten.transduktor.name</header>
<p id="hilfe_aufgaben_transduktor_erklaerung">!translate:hilfe.aufgaben.transduktor.erklaerung</p>
<p id="hilfe_aufgaben_transduktor_beispiel">!translate:hilfe.aufgaben.transduktor.beispiel</p>
</li>
</ul>
</section>
</div>
</body>
</html>

View file

@ -0,0 +1,211 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
html
{
margin: 0;
/*
height: 100%;
*/
background-color: hsl(120, 0%, 0%);
color: hsl(120, 0%, 100%);
font-family: monospace;
line-height: 200%;
}
body
{
margin: 0;
padding: 8px;
height: 100%;
background-color: hsl(120, 0%, 6.125%);
color: hsl(120, 0%, 93.75%);
}
a
{
color: hsl(120, 50%, 50%);
text-decoration: none;
cursor: pointer;
}
a:hover
{
color: hsl(120, 50%, 75%);
}
li
{
list-style-type: "» ";
}
body > header
{
font-size: 200%;
margin: 8px;
}
#radio_hilfe,
#radio_spiel
{
display: none;
}
#radio_hilfe:checked
{
& ~ #hilfe {}
& ~ #spiel {display: none;}
}
#radio_spiel:checked
{
& ~ #hilfe {display: none;}
& ~ #spiel {}
}
#spiel
{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
.bereich
{
margin: 8px;
padding: 8px;
background-color: hsl(120, 0%, 12.5%);
color: hsl(120, 0%, 87.5%);
}
#bereich_links
{
flex-basis: 19%;
flex-grow: 1;
flex-shrink: 1;
}
#bereich_mitte
{
flex-basis: 62%;
flex-grow: 1;
flex-shrink: 0;
min-width: 800px;
text-align: center;
}
#bereich_rechts
{
flex-basis: 19%;
flex-grow: 1;
flex-shrink: 1;
}
#hilfe section > header
{
font-size: 150%;
}
#knoepfe
{
& > *
{
margin: 2px;
}
&.initial
{
& > #knopf_schritt {}
& > #knopf_testen {}
& > #knopf_anhalten {display: none;}
& > #knopf_bearbeiten {display: none;}
& > #knopf_leeren {}
}
&.ungewiss_laufend
{
& > #knopf_schritt {display: none;}
& > #knopf_testen {display: none;}
& > #knopf_anhalten {}
& > #knopf_bearbeiten {display: none;}
& > #knopf_leeren {display: none;}
}
&.ungewiss_stehend
{
& > #knopf_schritt {}
& > #knopf_testen {}
& > #knopf_anhalten {display: none;}
& > #knopf_bearbeiten {}
& > #knopf_leeren {display: none;}
}
&.fertig
{
& > #knopf_schritt {display: none;}
& > #knopf_testen {display: none;}
& > #knopf_anhalten {display: none;}
& > #knopf_bearbeiten {}
& > #knopf_leeren {display: none;}
}
}
#aufgabe_status
{
margin-bottom: 8px;
}
.hilfe_aktoren_aktor
{
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin-bottom: 16px;
& > .hilfe_aktoren_aktor_name
{
flex-basis: 100%;
flex-shrink: 0;
flex-grow: 1;
text-transform: capitalize;
font-weight: bold;
}
& > .hilfe_aktoren_aktor_bild
{
flex-basis: 10%;
flex-shrink: 1;
flex-grow: 0;
}
& > .hilfe_aktoren_aktor_text
{
flex-basis: 90%;
flex-shrink: 1;
flex-grow: 1;
}
}

View file

@ -1,36 +1,10 @@
# Verrückte Turing-Maschinen # Verrückte Turing-Maschinen
— ein Turing-vollständiges Spiel ## Bauen
### Beschreibung
Dieses Spiel ist inspiriert von [Manufacturia](http://www.kongregate.com/games/PleasingFungus/manufactoria), [Crazy Machines](http://www.crazy-machines.com/), [World of Goo](http://worldofgoo.com/) … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P
## Erstellen
### Voraussetzungen
- [GNU-Make](https://www.gnu.org/software/make/manual/make.html)
- [TypeScript](http://www.typescriptlang.org/)-Compiler (Debian-Paket-Name: `node-typescript`, npm-Paket-Name: `typescript`)
- [Sass](http://sass-lang.com/)-Compiler (Debian-Paket-Name: `sassc`, npm-Paket-Name: `sass`)
### Anweisungen
Im Haupt-Verzeichnis ausführen:
tools/build
Dadurch wird das Verzeichnis `build` angelegt, welches die Ergebnis-Dateien enthält.
Zum Bauen wird ein Typscript-Compiler benötigt, den man beispielweise über **npm** beziehen kann: `npm install typescript`. Dadurch sollte das Kommando `tsc` verfügbar sein. Hat man das, kann man anschließend `make` ausführen, wodurch der Ordner `erzeugnis` erstellt wird.
## Starten ## Starten
Zum Starten/Testen einen Web-Server im Verzeichnis `build` starten (zum Beispiel per `cd build && python3 -m http.server 8888 ; cd -`) und im Browser `http://localhost:8888/vtm.html` aufrufen. 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.
## Anmerkungen
Das Programm folgt konsequent den Paradigmen der prozeduralen und funktionalen Programmierung und orientiert sich am Architektur-Muster [MVC](https://de.wikipedia.org/wiki/Model_View_Controller).

View file

@ -1,79 +0,0 @@
jsonp_handle(
{
"key": "strings-de",
"value": {
"common.title": "Verrückte Turing-Maschinen",
"common.help": "Hilfe",
"common.game": "Spiel",
"common.media": "Musik",
"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 ${manufacturia}, ${crazy_machines}, ${world_of_goo} … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P",
"help.controls.title": "Steuerung",
"help.controls.entry1": "Links-Klick/Rechts-Klick: Feldtyp wechseln",
"help.controls.entry2": "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 Spielfigur 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 benachbartes 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

@ -1,75 +0,0 @@
jsonp_handle(
{
"key": "strings-en",
"value": {
"common.title": "Crazy Turing Machines",
"common.help": "Help",
"common.game": "Game",
"common.media": "Media",
"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 ${manufacturia}, ${crazy_machines}, ${world_of_goo} … and also by memorable hours of the practical hardware course during computer science study :P",
"help.controls.title": "controls",
"help.controls.entry1": "left click/right click: change tile type",
"help.controls.entry2": "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 (right)!",
"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}!",
"tasks.start_symbol.title": "starting symbol",
"tasks.start_symbol.text": "Accept if the input commences with ${s1}; reject otherwise",
"tasks.dreifaltigkeit.title": "Trinity",
"tasks.dreifaltigkeit.text": "Accept only if the input contains ${s1} at least 3 times",
"tasks.abwechslung_erfreuet.title": "Variation pleases",
"tasks.abwechslung_erfreuet.text": "Accept only if the input colors (${s0} / ${s1}) alternate",
"tasks.ans_ende.title": "To the end",
"tasks.ans_ende.text": "The input, but with the first symbol moved to the end",
"tasks.tauschen.title": "Swap",
"tasks.tauschen.text": "In the input sequence (${s0} / ${s1}, replace all ${s0} by ${s2} and all ${s1} by ${s3}",
"tasks.waehlerisch.title": "Picky",
"tasks.waehlerisch.text": "remove all ${s0} from the input and keep all ${s1}",
"tasks.dekorator.title": "Decorator",
"tasks.dekorator.text": "Absolutely everything is better with ribbons, squiggle and trinkets of all kind! At least that's what people believe — shopping TV channels are the definite proof! But does it also hold for the tape of the token, if it contains only ${s0} and ${s1}? Let's find out: Put ${s2} to the begin and ${s3} to the end!"
}
}
);

View file

@ -1,68 +0,0 @@
jsonp_handle(
{
"key": "strings-eo",
"value": {
"common.title": "Frenezaj Turing-masxinoj",
"common.help": "Helpo",
"common.game": "Ludo",
"common.media": "Musiko",
"model.token.terms.singular": "figuro",
"model.token.terms.plural": "figuroj",
"model.modes.initial": "redakti masxinon",
"model.modes.uncertain": "provanta …",
"model.modes.wrong": "erara :/",
"model.modes.correct": "sxajne korekta :)",
"model.actuators.terms.singular": "agilo",
"model.actuators.terms.plural": "agiloj",
"model.actuators.kinds.generator.name": "eniro",
"model.actuators.kinds.acceptor.name": "eliro",
"model.actuators.kinds.rejector.name": "rifuzilo",
"model.actuators.kinds.conveyer.name": "movilo",
"model.actuators.kinds.writer.name": "skribilo",
"model.actuators.kinds.reader.name": "forko",
"model.tasks.terms.singular": "tasko",
"model.tasks.terms.plural": "taskoj",
"model.tasks.kinds.acceptor.name": "akceptilo",
"model.tasks.kinds.acceptor.shortcut": "AKC",
"model.tasks.kinds.transducer.name": "kondukilo",
"model.tasks.kinds.transducer.shortcut": "KON",
"controls.choose": "elekti taskon",
"controls.step": "sekva pasxo",
"controls.run": "trairi",
"controls.stop": "halti",
"controls.edit": "redakti",
"controls.clear": "malplenigi",
"help.introduction": "Tiu cxi ludo estas inspirita de ${manufacturia}, ${crazy_machines}, ${world_of_goo} … kaj ankaux de ne forgesitaj horoj da aparatar-stagxo dum la informadik-studado :P",
"help.controls.title": "stirado",
"help.controls.entry1": "maldekstra klako/dekstra klako: sxangxi kamp-tipon",
"help.controls.entry2": "turni mus-rondon: rotacii kampon",
"help.token.satz1": "La figuro povas esti movata tra la kamparo kaj gxi estas montrata kiel nigra rondo.",
"help.token.satz2": "Aldone la figuro havas liston da metitaj simboloj (bendo), kiuj estas montrataj kiel koloraj punktoj apud la figuro. La bendo estas legata de la plej maldekstra pozicio kaj skribita al la la plej dekstra pozicio (principo de FIFO)",
"help.actuators.introduction": "Cxiu kampo sur la kamparo povas esti ekipata per unu agilo, kiu havas influon al figuro depende de ties tipo. La jenaj tipoj disponeblas:",
"help.actuators.generator": "La eniro estas metita je la plej maldekstra kampo kaj estas montrata kiel blanka triangulo. Sur gxi la figuro estos metita je la kamparo kaj sekve movata al la montrita direkto.",
"help.actuators.acceptor": "Je la plej dekstra kampo metitas la eliro, kiu estas montrata kiel blanka rondo. Se oni stiras la figuron al tiu kampo, la bend-enhavo estos legata kaj poste akceptata.",
"help.actuators.rejector": "Cxiu malplena kampo finigos la iron de la figuro kun rifuzado de la bend-enhavo.",
"help.actuators.conveyer": "Tiun agilon oni uzas por movi la figuron al najbara kampo sen iu ajn sxangxo de la bend-enhavo.",
"help.actuators.writer": "Por skribi simbolon al bendo, oni bezonas tiun agilon. La koloro montras, kiu simbolo estos skribata kaj la direkto montras la kampon, al kiu la figuro estos movata poste.",
"help.actuators.reader": "Je forko la unua simbolo de la bendo estos legata kaj la konforma direkto estos elektata, al kiu la figuro estos movata poste. Se adekvata eliro troveblas, la unua simbolo de la bendo estos forigata. Se adekvata eliro mankas aux la bendo malplenas, la kompensa eliro (griza) estos uzata.",
"help.tasks.introduction": "La celo estas la solvado de taskoj. Ekzistas du tipoj da taskoj:",
"help.tasks.acceptor.description": "Oni ekzamenu la bend-enhavon de la figuro kaj decidu, cxu difinita kondicxo plenumas aux ne. Se jes, oni stiru la figuron al la eliro; alikaze al iu ajn malplena kampo.",
"help.tasks.acceptor.example": "Ekzemplo: Akceptu, se la bendo enhavas almenaux du da rugxaj simboloj.",
"help.tasks.transducer.description": "Je tia tasko oni generu eligon, kiu havas difinitan rilaton al la enigo; do kvazaux estas rezulto de funkcio.",
"help.tasks.transducer.example": "Ekzemplo: La enigo ripetita du-foje.",
"tasks.einfuehrung.title": "Enplektado",
"tasks.einfuehrung.text": "movu la figuron de la eniro (maldekstre) al la eliro (dekstre)!",
"tasks.start_symbol.title": "Komenca simbolo",
"tasks.start_symbol.text": "akceptu, se la enigo komencas je ${s1}; rifuzu alikaze!",
"tasks.dreifaltigkeit.title": "Triunuo",
"tasks.dreifaltigkeit.text": "akcptu, se la enigo enhavas almenaux tri da ${s1}!",
"tasks.abwechslung_erfreuet.title": "Alterno gxojigas",
"tasks.abwechslung_erfreuet.text": "akcptu se: La koloroj de la enigo (${s0} / ${s1}) sekvas unu la alian",
"tasks.ans_ende.title": "Al la fino",
"tasks.ans_ende.text": "la enigo (${s0} / ${s1}), sed kun la unua simbolo je la fino",
"tasks.tauschen.title": "Intersxangxado",
"tasks.tauschen.text": "anstatauxigi en la enigo (${s0} / ${s1}) cxiun ${s0} per ${s2} kaj cxiun ${s1} per ${s3}"
}
}
);

View file

@ -1,236 +0,0 @@
jsonp_handle(
{
"key": "tasks",
"value": [
{
"id": "einfuehrung",
"kind": "acceptor",
"parameter": {
"tests": [
{
"input": [],
"accept": true
}
]
}
},
{
"id": "start_symbol",
"kind": "acceptor",
"parameter": {
"tests": [
{
"input": [],
"accept": false
},
{
"input": [0],
"accept": false
},
{
"input": [1],
"accept": true
},
{
"input": [0,1],
"accept": false
},
{
"input": [1,0,1,1,0,0,0,1,0],
"accept": true
}
]
}
},
{
"id": "dreifaltigkeit",
"kind": "acceptor",
"parameter": {
"tests": [
{
"input": [1],
"accept": false
},
{
"input": [0,0,1,1],
"accept": false
},
{
"input": [1,0,1,0,0,1,0],
"accept": true
}
]
}
},
{
"id": "abwechslung_erfreuet",
"kind": "acceptor",
"parameter": {
"tests": [
{
"input": [],
"accept": true
},
{
"input": [0],
"accept": true
},
{
"input": [0,0],
"accept": false
},
{
"input": [1,0,1],
"accept": true
},
{
"input": [0,1,0,1,0,1],
"accept": true
}
]
}
},
{
"id": "ans_ende",
"kind": "transducer",
"parameter": {
"tests": [
{
"input": [0,0,1,1,1,0,1,0,1,1,1,0,1],
"output": [0,1,1,1,0,1,0,1,1,1,0,1,0]
}
]
}
},
{
"id": "tauschen",
"kind": "transducer",
"parameter": {
"tests": [
{
"input": [0,1,1,0],
"output": [2,3,3,2]
},
{
"input": [0,1,0,1,0,1,1,0,0,0,0,1,0,1,1,0],
"output": [2,3,2,3,2,3,3,2,2,2,2,3,2,3,3,2]
}
]
}
},
{
"id": "waehlerisch",
"kind": "transducer",
"parameter": {
"tests": [
{
"input": [0,0,0,1,0],
"output": [1]
},
{
"input": [1,0,1,0,1],
"output": [1,1,1]
},
{
"input": [1,1,1,1,0],
"output": [1,1,1,1]
},
{
"input": [0,0,0,0,1,0,1,1,0],
"output": [1,1,1]
},
]
}
},
{
"id": "dekorator",
"kind": "transducer",
"parameter": {
"tests": [
{
"input": [1,1,0],
"output": [2,1,1,0,3]
},
{
"input": [0,0,1,0,0],
"output": [2,0,0,1,0,0,3]
}
]
}
},
{
"id": "alpha_und_omega",
"kind": "acceptor",
"parameter": {
"tests": [
{
"input": [],
"accept": true
},
{
"input": [1],
"accept": true
},
{
"input": [0,1],
"accept": false
},
{
"input": [0,1,1,1,0],
"accept": true
},
{
"input": [1,1,0,0],
"accept": false
},
{
"input": [1,0,1,1,1],
"accept": true
}
]
}
},
{
"id": "an_den_anfang",
"kind": "transducer",
"parameter": {
"tests": [
{
"input": [0,0,1,1,1,0,1,0,1,1,1,0,1],
"output": [1,0,0,1,1,1,0,1,0,1,1,1,0]
}
]
}
},
{
"id": "a_n_b_n",
"kind": "acceptor",
"parameter": {
"tests": [
{
"input": [],
"accept": true
},
{
"input": [0],
"accept": false
},
{
"input": [0,0,1,1],
"accept": true
},
{
"input": [0,0,0,1,1],
"accept": false
},
{
"input": [0,0,0,0,0,0,0,1,1,1,1,1,1,1],
"accept": true
}
]
}
}
]
}
);

View file

@ -1,72 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace lib_call
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_complex<type_data> = {kind : string; data : type_data;};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function wrap<type_data>(kind : string, data : type_data) : type_complex<type_data>
{
return {"kind": kind, "data": data};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function unwrap<type_data>(complex : type_complex<type_data>) : type_data
{
return complex.data;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function distinguish<type_result>
(
complex : type_complex<any>,
cases : {[kind : string] : (data ?: any)=>type_result},
fallback : (complex : type_complex<any>)=>type_result = ((complex) => {throw (new Error("unbehandelt"));})
)
: type_result
{
if (complex.kind in cases)
{
let function_ : (data ?: any)=>type_result = cases[complex.kind];
let result : type_result = function_(complex.data);
return result;
}
else
{
let message : string = ("unbehandelte Art '" + complex.kind + "'");
console.warn(message);
let result : type_result = fallback(complex);
return result;
}
}
}

View file

@ -1,110 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace lib_hashmap
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_hashmap<type_key, type_value> =
{
hashfunction : (key : type_key)=>string;
store : {[hashvalue : string] : {key : type_key; value : type_value;}};
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create<type_key, type_value>
(
hashfunction : (key : type_key)=>string
)
: type_hashmap<type_key, type_value>
{
return {
"hashfunction": hashfunction,
"store": {},
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function set<type_key, type_value>
(
hashmap : type_hashmap<type_key, type_value>,
key : type_key,
value : type_value
)
: void
{
let hashvalue : string = hashmap.hashfunction(key);
hashmap.store[hashvalue] = {"key": key, "value": value};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function get<type_key, type_value>
(
hashmap : type_hashmap<type_key, type_value>,
key : type_key
)
: lib_errormonade.type_errormonade<type_value>
{
let hashvalue : string = hashmap.hashfunction(key);
if (hashvalue in hashmap.store)
{
let value : type_value = hashmap.store[hashvalue].value;
return (lib_errormonade.create_just<type_value>(value));
}
else
{
return (lib_errormonade.create_nothing<type_value>());
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function iterate<type_key, type_value>
(
hashmap : type_hashmap<type_key, type_value>,
procedure : (key ?: type_key, value ?: type_value)=>void
)
: void
{
Object.keys(hashmap.store).forEach
(
(hashvalue) =>
{
let paar : {key : type_key; value : type_value;} = hashmap.store[hashvalue];
procedure(paar.key, paar.value);
}
)
;
}
}

View file

@ -1,54 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace 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;
}
}

View file

@ -1,209 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace lib_svg
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const float_precision : int = 4;
/**
* @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 scaling
(
staerke : float
)
: string
{
return (
"scale"
+ "("
+ staerke.toFixed(float_precision)
+ ")"
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function path_description
(
vertices : Array<lib_vector.type_vector>,
close : boolean = true
)
: string
{
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";
return d;
}
/**
* @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
{
attributes["d"] = path_description(vertices, close);
return lib_xml.create_normal("path", attributes);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function group
(
attributes : {[key : string] : string} = {},
children : Array<lib_xml.type_node> = []
)
: lib_xml.type_node
{
return (
lib_xml.create_normal
(
"g",
attributes,
children
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function circle
(
center_x : float,
center_y : float,
radius : float,
classes : Array<string> = []
)
: lib_xml.type_node
{
return (
lib_xml.create_normal
(
"circle",
{
"cx": center_x.toFixed(float_precision),
"cy": center_y.toFixed(float_precision),
"r": radius.toFixed(float_precision),
"class": classes.join(" "),
}
)
);
}
/**
* @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,174 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace lib_translate
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _languagestack : Array<string>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _data : {[language : string] : {[key : string] : string}} = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function setup(languages : Array<string>) : void
{
_languagestack = [];
languages.forEach
(
language =>
{
const strs_raw_ : lib_errormonade.type_errormonade<any> = mod_vtm.mod_data.read("strings-" + language);
if (lib_errormonade.filled(strs_raw_))
{
const strs_raw : {[key : string] : string} = (<{[key : string] : string}>(lib_errormonade.read(strs_raw_)));
_data[language] = {};
for (const key in strs_raw)
{
_data[language][key] = (<string>(strs_raw[key]));
}
_languagestack.push(language);
}
else
{
const message : string = ("Zeichenketten für Sprache '" + language + "' konnten nicht geladen werden");
console.warn(message);
}
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function read(language : string, key : string) : lib_errormonade.type_errormonade<string>
{
if (language in _data)
{
let dataset : {[key : string] : string} = _data[language];
if (key in dataset)
{
return (lib_errormonade.create_just<string>(dataset[key]));
}
else
{
const message : string = ("keine Zeichenketten für Schlüssel '" + key + "' in Sprache '" + language + "'");
console.warn(message);
return (lib_errormonade.create_nothing<string>());
}
}
else
{
const message : string = ("keine Zeichenketten für Sprache '" + language + "'");
console.warn(message);
return (lib_errormonade.create_nothing<string>());
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function get(key : string, vars : {[name : string] : string} = {}) : string
{
let result : lib_errormonade.type_errormonade<string> = (lib_errormonade.create_nothing<string>());
const found : boolean = (
_languagestack
.some
(
language =>
{
const result_ : lib_errormonade.type_errormonade<string> = read(language, key);
if (lib_errormonade.filled(result_))
{
result = result_;
return true;
}
else
{
return false;
}
}
)
);
if (found)
{
return lib_string.stance(lib_errormonade.read(result), vars);
}
else
{
return ("{" + key + "}");
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function deploy(context : DocumentFragment) : void
{
const pattern : RegExp = (new RegExp("^!translate:([a-z0-9\.]*)$"));
const adjust = (
element =>
{
if (element.childElementCount > 0)
{
// nichts tun
}
else
{
const content : string = element.textContent;
const fund : any = pattern.exec(content);
if (fund === null)
{
// nichts tun
}
else
{
const key : string = fund[1];
const content_ : string = get(key);
element.textContent = content_;
}
}
}
);
const old : boolean = true;
const nodelist : NodeListOf<Element> = document.querySelectorAll("*");
if (old)
{
for (let index : int = 0; index < nodelist.length; index += 1) adjust(nodelist[index])
}
else
{
nodelist.forEach(element => adjust(element));
}
}
}

View file

@ -1,64 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace lib_vector
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_vector = {x : float; y : float;};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function cartesian(x : float, y : float) : type_vector
{
return {"x": x, "y": y};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function polar(angle : float, radius : float = 1) : type_vector
{
return {"x": (radius * Math.cos(angle)), "y": (radius * Math.sin(angle))};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function scale(vector : type_vector, factor : float) : type_vector
{
return {"x": (vector.x * factor), "y": (vector.y * factor)};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function add(vector1 : type_vector, vector2 : type_vector) : type_vector
{
return {"x": (vector1.x + vector2.x), "y": (vector1.y + vector2.y)};
}
}

View file

@ -1,138 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace lib_xml
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_node = lib_call.type_complex<any>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_text
(
content : string
)
: type_node
{
return (
lib_call.wrap
(
"text",
{
"content": content
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_normal
(
name : string,
attributes : {[key : string] : string} = {},
children : Array<type_node> = []
)
: type_node
{
return (
lib_call.wrap
(
"normal",
{
"name": name,
"attributes": attributes,
"children": children
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function view
(
node : type_node,
depth : int = 0
)
: string
{
return (
lib_call.distinguish<any>
(
node,
{
"text": ({"content": content}) =>
{
return content;
}
,
"normal": ({"name": name, "attributes": attributes, "children": children}) =>
{
let str : string = "";
// begin
{
let str_begin : string = "";
str_begin += name;
// attributes
{
let str_attributes : string = "";
Object.keys(attributes).forEach
(
key =>
{
let value : string = attributes[key];
str_attributes += (" " + key + "=" + ("\"" + value + "\""));
}
)
;
str_begin += str_attributes;
}
str_begin = (lib_string.indent(depth) + "<" + str_begin + ">" + "\n");
str += str_begin;
}
// children
{
children.forEach(child => (str += view(child, depth+1)));
}
// end
{
let str_end : string = "";
str_end += name;
str_end = (lib_string.indent(depth) + "<" + "/" + str_end + ">" + "\n");
str += str_end;
}
return str;
}
,
}
)
);
}
}

View file

@ -1,128 +0,0 @@
<!--
Verrückte Turing-Maschinen — A turing complete game
Copyright (C) 2016-2018 kcf <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/>.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script type="text/javascript" src="vtm.js"></script>
<script type="text/javascript" src="vtm.dat.js"></script>
<script type="text/javascript">mod_vtm.entry_web();</script>
<link rel="stylesheet" type="text/css" href="vtm.css"/>
<title>!translate:common.title</title>
</head>
<body>
<h1>!translate:common.title</h1>
<label class="tab" for="radio_help"><a>!translate:common.help</a></label><input type="radio" name="tab" id="radio_help"/>
<label class="tab" for="radio_game"><a>!translate:common.game</a></label><input type="radio" name="tab" id="radio_game" checked="checked"/>
<label class="tab" for="radio_media"><a>!translate:common.media</a></label><input type="radio" name="tab" id="radio_media"/>
<!--
<hr/>
-->
<div id="game">
<div class="section" id="section_left">
<label for="task_selection">!translate:controls.choose</label>
<select id="task_selection"></select>
<p id="task_text"></p>
<hr/>
<div id="task_status"></div>
<div id="buttons">
<button id="button_step">!translate:controls.step</button>
<button id="button_test">!translate:controls.run</button>
<button id="button_stop">!translate:controls.stop</button>
<button id="button_edit">!translate:controls.edit</button>
<button id="button_clear">!translate:controls.clear</button>
</div>
</div>
<div class="section" id="section_mid">
</div>
<div class="section" id="section_right">
</div>
</div>
<div id="help">
<p id="help_introduction"></p>
<section class="section">
<h2 id="help_controls_title">!translate:help.controls.title</h2>
<ul>
<li id="help_controls_entry1">!translate:help.controls.entry1</li>
<li id="help_controls_entry2">!translate:help.controls.entry2</li>
</ul>
</section>
<section class="section">
<h2 id="help_token_title">!translate:model.token.terms.singular</h2>
<p id="help_token_satz1">!translate:help.token.satz1</p>
<p id="help_token_satz2">!translate:help.token.satz2</p>
</section>
<section class="section" id="help_actuators">
<h2 id="help_actuators_title">!translate:model.actuators.terms.plural</h2>
<p id="help_actuators_introduction">!translate:help.actuators.introduction</p>
<ul>
<li class="help_actuators_actuator" id="help_actuators_actuator_generator">
<h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.generator.name</h3>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.generator</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_acceptor">
<h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.acceptor.name</h3>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.acceptor</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_rejector">
<h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.rejector.name</h3>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.rejector</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_conveyer">
<h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.conveyer.name</h3>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.conveyer</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_writer">
<h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.writer.name</h3>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.writer</div>
</li>
<li class="help_actuators_actuator" id="help_actuators_actuator_reader">
<h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.reader.name</h3>
<div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.reader</div>
</li>
</ul>
</section>
<section class="section">
<h2 id="help_tasks_title">!translate:model.tasks.terms.plural</h2>
<p id="help_tasks_introduction">!translate:help.tasks.introduction</p>
<ul>
<li id="help_tasks_acceptor">
<h3 id="help_tasks_acceptor_name">!translate:model.tasks.kinds.acceptor.name</h3>
<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_transducer">
<h3 id="help_tasks_acceptor_name">!translate:model.tasks.kinds.transducer.name</h3>
<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>
</div>
<div id="media">
<audio id="music" controls="controls"></audio>
</div>
</body>
</html>

View file

@ -1,271 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
$hue: 150;
html
{
margin: 0;
/*
height: 100%;
*/
background-color: hsl($hue, 0%, 0%);
color: hsl($hue, 0%, 100%);
font-family: monospace;
line-height: 200%;
}
body
{
margin: 0;
padding: 8px;
height: 100%;
background-color: hsl($hue, 0%, 6.125%);
color: hsl($hue, 0%, 93.75%);
}
a
{
text-decoration: none;
cursor: pointer;
&:not(:hover)
{
color: hsl($hue, 50%, 50%);
}
&:hover
{
color: hsl($hue, 50%, 75%);
}
}
li
{
list-style-type: "» ";
}
input,select,textarea,button
{
margin: 4px;
border: none;
padding: 8px;
min-width: 80px;
// border-radius: 2px;
// box-shadow: 1px 1px 1px black;
cursor: pointer;
font-family: monospace;
// font-weight: bold;
&:not(:hover)
{
background-color: hsl($hue, 0%, 25%);
color: hsl($hue, 0%, 100%);
}
&:hover
{
background-color: hsl($hue, 50%, 25%);
color: hsl($hue, 0%, 100%);
transition: 0.25s ease;
}
}
label.tab
{
margin: 8px;
}
#radio_help,
#radio_game,
#radio_media
{
display: none;
}
#radio_help:checked
{
& ~ #help {}
& ~ #game {display: none !important;}
& ~ #media {display: none !important;}
}
#radio_game:checked
{
& ~ #help {display: none !important;}
& ~ #game {}
& ~ #media {display: none !important;}
}
#radio_media:checked
{
& ~ #help {display: none !important;}
& ~ #game {display: none !important;}
& ~ #media {}
}
/*
#help {display: none !important;}
#game {}
*/
#game
{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
.section
{
margin: 8px;
padding: 16px;
background-color: hsl($hue, 0%, 12.5%);
color: hsl($hue, 0%, 87.5%);
}
#section_left
{
flex-basis: 19%;
flex-grow: 1;
flex-shrink: 1;
}
#section_mid
{
flex-basis: 62%;
flex-grow: 1;
flex-shrink: 0;
min-width: 800px;
text-align: center;
}
#section_right
{
flex-basis: 19%;
flex-grow: 1;
flex-shrink: 1;
}
h1,h2,h3,h4
{
margin-top: 0;
}
#buttons
{
& > *
{
margin: 4px;
display: block;
text-transform: capitalize;
}
&.initial
{
& > #button_step {}
& > #button_run {}
& > #button_stop {display: none !important;}
& > #button_edit {display: none !important;}
& > #button_clear {}
}
&.uncertain_running
{
& > #button_step {display: none !important;}
& > #button_run {display: none !important;}
& > #button_stop {}
& > #button_edit {display: none !important;}
& > #button_clear {display: none !important;}
}
&.uncertain_standing
{
& > #button_step {}
& > #button_run {}
& > #button_stop {display: none !important;}
& > #button_edit {}
& > #button_clear {display: none !important;}
}
&.done
{
& > #button_step {display: none !important;}
& > #button_run {display: none !important;}
& > #button_stop {display: none !important;}
& > #button_edit {}
& > #button_clear {display: none !important;}
}
}
#task_status
{
margin-bottom: 8px;
}
.help_actuators_actuator
{
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin-bottom: 16px;
& > .help_actuators_actuator_name
{
flex-basis: 100%;
flex-shrink: 0;
flex-grow: 1;
text-transform: capitalize;
font-weight: bold;
}
& > .help_actuators_actuator_image
{
flex-basis: 10%;
flex-shrink: 1;
flex-grow: 0;
}
& > .help_actuators_actuator_text
{
flex-basis: 90%;
flex-shrink: 1;
flex-grow: 1;
}
}
#music
{
/*
display: none;
*/
}

View file

@ -1,259 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function tasks_insert(handler : (task : mod_model.mod_task.type_task)=>void) : void
{
const tasks_raw_ : lib_errormonade.type_errormonade<Array<any>> = mod_vtm.mod_data.read("tasks");
if (lib_errormonade.filled(tasks_raw_))
{
let tasks_raw : Array<any> = lib_errormonade.read(tasks_raw_);
let dom_selection : Element = document.querySelector("#task_selection");
tasks_raw.forEach
(
(task_raw, index) =>
{
let task : mod_model.mod_task.type_task = mod_model.mod_task.import_(task_raw);
// Aufgabe registrieren
{
mod_model.mod_task.registrieren(task);
}
// Option entryen
{
let prefix : string = (
{
"acceptor": lib_translate.get("model.tasks.kinds.acceptor.shortcut"),
"transducer": lib_translate.get("model.tasks.kinds.transducer.shortcut"),
}[task_raw["kind"]]
);
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 = title;
dom_selection.appendChild(dom_option);
}
}
)
;
dom_selection.addEventListener
(
"change",
event =>
{
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);
handler(task);
}
)
;
}
else
{
console.warn("Daten nicht auffindbar");
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function main() : void
{
// Übersetzungen
{
const languages : Array<string> = lib_list.copy<string>(navigator.languages);
const language_native : string = "de";
// if (! languages.includes(language_native))
if (! languages.some((language) => (language === language_native)))
languages.push(language_native);
lib_translate.setup(languages);
lib_translate.deploy(document);
}
// Hilfe
{
// Einleitung
{
document.querySelector("#help_introduction").innerHTML = (
lib_translate.get
(
"help.introduction",
{
"manufacturia": "<a href=\"http://www.kongregate.com/games/PleasingFungus/manufactoria\">Manufacturia</a>",
"crazy_machines": "<a href=\"http://www.crazy-machines.com/\">Crazy Machines</a>",
"world_of_goo": "<a href=\"http://worldofgoo.com/\">World of Goo</a>",
}
)
);
}
// Aktoren
{
// Arten
{
const from_x : float = -0.5;
const from_y : float = -0.5;
const to_x : float = +0.5;
const to_y : float = +0.5;
const width : float = 80;
const height : float = 80;
[
{
"model": mod_model.mod_actuator.example("generator"),
"area": document.querySelector("#help_actuators_actuator_generator"),
},
{
"model": mod_model.mod_actuator.example("acceptor"),
"area": document.querySelector("#help_actuators_actuator_acceptor"),
},
{
"model": mod_model.mod_actuator.example("rejector"),
"area": document.querySelector("#help_actuators_actuator_rejector"),
},
{
"model": mod_model.mod_actuator.example("conveyer"),
"area": document.querySelector("#help_actuators_actuator_conveyer"),
},
{
"model": mod_model.mod_actuator.example("writer"),
"area": document.querySelector("#help_actuators_actuator_writer"),
},
{
"model": mod_model.mod_actuator.example("reader"),
"area": document.querySelector("#help_actuators_actuator_reader"),
},
]
.forEach
(
entry =>
{
const manifestation = (
mod_manifestation.mod_svg.mod_actuator.create_extended
(
entry.model,
mod_model.mod_spot.null_()
)
);
const xmlnode : lib_xml.type_node = (
lib_svg.root
(
from_x, from_y,
to_x, to_y,
width, height,
[mod_manifestation.view(manifestation)]
)
);
entry.area.querySelector(".help_actuators_actuator_image").innerHTML = lib_xml.view(xmlnode);
}
)
;
}
}
}
// Spiel
{
let game : mod_model.mod_game.type_game;
// Aufgaben
{
tasks_insert
(
function (task : mod_model.mod_task.type_task) : void {mod_model.mod_game.task_set(game, task);}
)
;
}
// Aufbau
{
game = mod_model.mod_game.create(mod_model.mod_task.get(0));
}
// Manifestationen
{
[
mod_manifestation.mod_web.mod_game.create_extended
(
game,
document.querySelector("#section_mid")
)
,
mod_manifestation.mod_store.mod_game.create_extended
(
game
)
,
]
.forEach(mod_manifestation.setup);
}
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function entry_web() : void
{
document.addEventListener
(
"DOMContentLoaded",
event =>
{
// music
{
let dom_audio : HTMLAudioElement = document.querySelector<HTMLAudioElement>("#music");
const playlist : Array<string> =
[
"time",
"marble_machine",
"elan",
"lux_aeterna",
"sweet_dreams",
];
let index : int = -1;
const next = function ()
{
index = ((index + 1) % playlist.length);
const path : string = ("music/" + playlist[index] + ".ogg");
let dom_source : HTMLSourceElement = document.createElement("source");
dom_source.setAttribute("type", "audio/ogg");
dom_source.setAttribute("src", path);
for (let i : int = 0; i < dom_audio.children.length; i += 1) dom_audio.removeChild(dom_audio.children[i]);
dom_audio.appendChild(dom_source);
dom_audio.load();
dom_audio.play();
}
;
dom_audio.volume = 0.25;
// dom_audio.setAttribute("autoplay", "autoplay");
// dom_audio.setAttribute("loop", "loop");
// dom_audio.setAttribute("controls", "controls");
dom_audio.addEventListener("ended", () => {next();});
next();
}
main();
}
)
;
}
}

View file

@ -1,172 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_manifestation
{
export namespace mod_store
{
export namespace mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_game =
{
model : mod_vtm.mod_model.mod_game.type_game;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create
(
model : mod_vtm.mod_model.mod_game.type_game
)
: type_game
{
return {
"model": model
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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": "store_game",
"data": create(model)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(game : type_game) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(game : type_game) : void
{
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_task",
(data) =>
{
// 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);
//
if (key in localStorage)
{
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_game.world_set(game.model, world, false);
}
else
{
mod_vtm.mod_model.mod_game.world_clear(game.model);
// nothing tun
}
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_world",
(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);
//
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_game.listen
(
game.model,
"change_token",
(data) =>
{
// console.info("change_token", data);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_mode",
(data) =>
{
// console.info("change_mode", data);
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, void>>
(
trait_manifestation,
"store_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}
}
}
}

View file

@ -1,181 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm.mod_manifestation.mod_svg.mod_actuator
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow_1 : string = (
lib_svg.path_description
(
(
[
lib_vector.cartesian( 4, 0),
lib_vector.cartesian( 0, +1),
lib_vector.cartesian(-0, 0),
lib_vector.cartesian( 0, -1),
]
),
true
)
);
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow_2 : string = (
lib_svg.path_description
(
[
lib_vector.cartesian(+3, 0),
lib_vector.cartesian( 0, +2),
lib_vector.cartesian(+1, 0),
lib_vector.cartesian( 0, -2),
],
true
)
);
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type signature_actuator =
{
view : (actuator : mod_vtm.mod_model.mod_actuator.type_actuator)=>Array<lib_xml.type_node>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export var trait_actuator : lib_trait.type_trait<signature_actuator> = lib_trait.create<signature_actuator>();
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_actuator =
{
model : mod_vtm.mod_model.mod_actuator.type_actuator;
spot : mod_vtm.mod_model.mod_spot.type_spot;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
)
: type_actuator
{
return {
"model": model,
"spot": spot
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
)
: type_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator>
{
return {
"kind": "svg_actuator",
"data": create(model, spot),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(actuator_ : type_actuator) : lib_xml.type_node
{
let actuator : mod_vtm.mod_model.mod_actuator.type_actuator = actuator_.model;
let node_frame = function () : lib_xml.type_node
{
return (
lib_svg.path
(
lib_list.sequence(6).map(i => lib_vector.polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true,
{
"class": "frame"
}
)
);
}
;
let position : mod_position.type_position = mod_position.from_spot(actuator_.spot);
let node_tile : lib_xml.type_node = (
lib_svg.group
(
{
"class": "tile",
"rel": mod_vtm.mod_model.mod_spot.hash(actuator_.spot),
"transform": lib_svg.translation(position.x, position.y),
},
(
[node_frame()]
.concat(lib_trait.deploy<signature_actuator>(trait_actuator, actuator.kind)["view"](actuator))
)
)
);
return node_tile;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(actuator : type_actuator) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator, lib_xml.type_node>>
(
trait_manifestation,
"svg_actuator",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}

View file

@ -1,54 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm.mod_manifestation.mod_svg.mod_actuator
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend
(
trait_actuator,
"acceptor",
{
"view": (actuator) =>
{
let children : Array<lib_xml.type_node> = [];
const node_circle : lib_xml.type_node = (
lib_svg.circle
(
0.0,
0.0,
0.25,
[
"circle",
"positive",
]
)
);
children.push(node_circle);
return children;
}
,
}
)
;
}

View file

@ -1,169 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_manifestation
{
export namespace mod_svg
{
export namespace mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_game =
{
model : mod_vtm.mod_model.mod_game.type_game;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create(model : mod_vtm.mod_model.mod_game.type_game) : type_game
{
return {
"model": model
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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_game",
"data": create(model)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(game : type_game) : 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_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_extended(actuator, spot);
let node_tile : lib_xml.type_node = mod_manifestation.view(manifestation_tile);
children_tiles.push(node_tile);
}
)
;
let node_tiles : lib_xml.type_node = (
lib_xml.create_normal
(
"g",
{
"class": "tiles",
},
children_tiles
)
);
children_world.push(node_tiles);
}
let node_world : lib_xml.type_node = (
lib_xml.create_normal
(
"g",
{
"class": "world",
},
children_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_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_extended(token);
let node_token : lib_xml.type_node = mod_manifestation.view(manifestation_token);
children_game.push(node_token);
}
else
{
// nothing tun
}
}
let node_game : lib_xml.type_node = (
lib_xml.create_normal
(
"g",
{
"class": "game",
},
children_game
)
);
return node_game;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(game : type_game) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, lib_xml.type_node>>
(
trait_manifestation,
"svg_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}
}
}
}

View file

@ -1,194 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_manifestation
{
export namespace mod_svg
{
export namespace mod_token
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_token =
{
model : mod_vtm.mod_model.mod_token.type_token;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_vtm.mod_model.mod_token.type_token
)
: type_token
{
return {
"model": model,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_vtm.mod_model.mod_token.type_token
)
: type_manifestation<mod_vtm.mod_model.mod_token.type_token>
{
return {
"kind": "svg_token",
"data": create(model),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view
(
token_ : type_token
)
: lib_xml.type_node
{
let token : mod_vtm.mod_model.mod_token.type_token = token_.model;
let children_token : Array<lib_xml.type_node> = [];
// Stein
{
let node_stone : lib_xml.type_node = (
lib_xml.create_normal
(
"circle",
{
"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": "stone",
}
)
);
children_token.push(node_stone);
}
// Band
{
let tape : Array<mod_vtm.mod_model.mod_symbol.type_symbol> = mod_vtm.mod_model.mod_token.tape_read(token);
let children_tape : Array<lib_xml.type_node> = [];
tape.forEach
(
(symbol, index) =>
{
let r : float = 0.06125;
let x : float = (+0.1+(2*r*1.25)*index);
let y : float = (-0.1);
let node_entry : lib_xml.type_node = (
lib_xml.create_normal
(
"circle",
{
"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(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": (
[
"entry",
"symbol_" + symbol.toFixed(0),
].join(" ")
),
}
)
);
children_tape.push(node_entry);
}
)
;
let node_tape = (
lib_xml.create_normal
(
"g",
{
"class": "tape",
},
children_tape
)
);
children_token.push(node_tape);
}
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": lib_svg.translation(position.x, position.y),
},
children_token
)
);
return node_token;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(token : type_token) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_token.type_token, lib_xml.type_node>>
(
trait_manifestation,
"svg_token",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}
}
}
}

View file

@ -1,483 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm.mod_manifestation.mod_web.mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function text_postprocess(text : string) : string
{
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_game =
{
model : mod_model.mod_game.type_game;
area : Element;
intervall : lib_errormonade.type_errormonade<any>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_model.mod_game.type_game,
area : Element
)
: type_game
{
return {
"model": model,
"area": area,
"intervall": (lib_errormonade.create_nothing<any>()),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_model.mod_game.type_game,
area : Element
)
: type_manifestation<mod_model.mod_game.type_game>
{
return (
lib_call.wrap
(
"web_game",
create(model, area)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_task(game : type_game) : void
{
document.querySelector("#task_text").innerHTML = (
text_postprocess
(
mod_vtm.mod_model.mod_task.text
(
mod_vtm.mod_model.mod_game.task_read(game.model)
)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_world(game : type_game) : void
{
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_token(game : type_game) : void
{
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_mode(game : type_game) : void
{
let status : string;
switch (mod_vtm.mod_model.mod_game.mode_read(game.model))
{
case mod_vtm.mod_model.mod_mode.initial:
{
status = lib_translate.get("model.modes.initial");
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
status = lib_translate.get("model.modes.uncertain");
break;
}
case mod_vtm.mod_model.mod_mode.wrong:
{
status = lib_translate.get("model.modes.wrong");
break;
}
case mod_vtm.mod_model.mod_mode.correct:
{
status = lib_translate.get("model.modes.correct");
break;
}
default:
{
let message : string = "unbehandelter Modus";
throw (new Error(message));
break;
}
}
document.querySelector("#task_status").textContent = status;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_buttons(game : type_game) : void
{
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:
{
class_ = "initial";
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
class_ = (
lib_errormonade.filled<any>(game.intervall)
? "uncertain_running"
: "uncertain_standing"
);
break;
}
case mod_vtm.mod_model.mod_mode.wrong:
case mod_vtm.mod_model.mod_mode.correct:
{
class_ = "done";
break;
}
default:
{
throw (new Error("unbehandelt!"));
break;
}
}
document.querySelector("#buttons").setAttribute("class", class_);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(game : type_game) : void
{
update_task(game);
update_world(game);
update_token(game);
update_mode(game);
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function stop(game : type_game) : void
{
if (lib_errormonade.filled(game.intervall))
{
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(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function resume(game : type_game) : void
{
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(game);
}
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function testen(game : type_game) : void
{
let handle : any = setInterval(() => resume(game), 500);
game.intervall = (lib_errormonade.create_just<any>(handle));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function edit(game : type_game) : void
{
stop(game);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function clear(game : type_game) : void
{
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(game : type_game) : void
{
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");
if (dom_tile == null)
{
spot = (lib_errormonade.create_nothing<mod_vtm.mod_model.mod_spot.type_spot>());
}
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.from_hash(rel)));
}
return spot;
}
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_task",
(data) =>
{
update_task(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_world",
(data) =>
{
update_world(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_token",
(data) =>
{
update_token(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_mode",
(data) =>
{
update_mode(game);
update_buttons(game);
}
)
;
// Links-Klick
game.area.addEventListener
(
"click",
event =>
{
event.preventDefault();
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_game.world_tile_change(game.model, lib_errormonade.read(spot_), false);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Rechts-Klick
game.area.addEventListener
(
"contextmenu",
event =>
{
event.preventDefault();
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_game.world_tile_change(game.model, lib_errormonade.read(spot_), true);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Mausrad
game.area.addEventListener
(
"wheel",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
let increment : int = ((event["deltaY"] < 0) ? -1 : +1);
mod_vtm.mod_model.mod_game.world_tile_rotate(game.model, lib_errormonade.read(spot_), increment);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Schritt
document.querySelector("#button_step").addEventListener
(
"click",
event =>
{
stop(game);
resume(game);
}
)
;
// Testen
document.querySelector("#button_test").addEventListener
(
"click",
event =>
{
testen(game);
}
)
;
// stop
document.querySelector("#button_stop").addEventListener
(
"click",
event =>
{
stop(game);
}
)
;
// edit
document.querySelector("#button_edit").addEventListener
(
"click",
event =>
{
edit(game);
}
)
;
// Leeren
document.querySelector("#button_clear").addEventListener
(
"click",
event =>
{
clear(game);
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, void>>
(
trait_manifestation,
"web_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}

View file

@ -1,248 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_model
{
export namespace mod_actuator
{
export namespace mod_reader
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
const kind : string = "reader";
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_reader =
{
"direction": mod_direction.type_direction,
"symbol_links": mod_symbol.type_symbol,
"symbol_rechts": mod_symbol.type_symbol,
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
direction : mod_direction.type_direction,
symbol_links : mod_symbol.type_symbol,
symbol_rechts : mod_symbol.type_symbol
)
: type_reader
{
return {
"direction": direction,
"symbol_links": symbol_links,
"symbol_rechts": symbol_rechts,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
direction : mod_direction.type_direction,
symbol_links : mod_symbol.type_symbol,
symbol_rechts : mod_symbol.type_symbol
)
: mod_actuator.type_actuator
{
return lib_call.wrap(kind, create(direction, symbol_links, symbol_rechts));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function example
(
)
: type_reader
{
return create(0, 0, 1);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function direction_read
(
reader : type_reader
)
: mod_direction.type_direction
{
return reader.direction;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function symbol_links_read
(
reader : type_reader
)
: mod_symbol.type_symbol
{
return reader.symbol_links;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function symbol_rechts_read
(
reader : type_reader
)
: mod_symbol.type_symbol
{
return reader.symbol_rechts;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function rotate
(
reader : type_reader,
increment : int = +1
)
: void
{
reader.direction = mod_direction.add(reader.direction, increment);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function use
(
reader : type_reader,
token : mod_token.type_token
)
: void
{
const symbol_ : lib_errormonade.type_errormonade<mod_symbol.type_symbol> = mod_token.read(token);
let summand : mod_direction.type_direction;
if (lib_errormonade.filled(symbol_))
{
const symbol : mod_symbol.type_symbol = lib_errormonade.read(symbol_);
if (symbol === reader.symbol_links)
{
mod_token.shift(token);
summand = +2;
}
else if (symbol === reader.symbol_rechts)
{
mod_token.shift(token);
summand = -2;
}
else
{
summand = 0;
}
}
else
{
summand = 0;
}
const direction : mod_direction.type_direction = mod_direction.add(reader.direction, summand);
mod_token.move(token, direction);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function export_
(
reader : type_reader
)
: any
{
return {
"direction": mod_direction.export_(reader.direction),
"symbol_links": mod_symbol.export_(reader.symbol_links),
"symbol_rechts": mod_symbol.export_(reader.symbol_rechts),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function import_
(
raw : any
)
: type_reader
{
return (
create
(
mod_direction.import_(raw["direction"]),
mod_symbol.import_(raw["symbol_links"]),
mod_symbol.import_(raw["symbol_rechts"])
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_actuator>
(
trait_actuator,
kind,
{
"example": () => lib_call.wrap(kind, example()),
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment),
"use": (actuator, token) => use(lib_call.unwrap(actuator), token),
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}),
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])),
}
)
;
}
}
}
}

View file

@ -1,442 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_model
{
export namespace mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_game =
{
world : mod_world.type_world;
token : lib_errormonade.type_errormonade<mod_token.type_token>;
task : mod_task.type_task;
testindex : lib_errormonade.type_errormonade<int>;
mode : mod_mode.type_mode;
listeners : {[event : string] : Array<(data ?: any)=>void>};
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create
(
task : mod_task.type_task
)
: type_game
{
let game : type_game =
{
"world": undefined,
"token": undefined,
"task": task,
"testindex": undefined,
"mode": undefined,
"listeners":
{
"change_task": [],
"change_world": [],
"change_token": [],
"change_mode": [],
}
,
}
;
world_clear(game, false);
reset(game, false);
return game;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function listen
(
game : type_game,
event : string,
procedure : (data ?: any)=>void
)
: void
{
if (event in game.listeners)
{
game.listeners[event].push(procedure);
}
else
{
const message : string = "kein Ereignis mit diesem Name";
throw (new Error(message));
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function notify
(
game : type_game,
event : string,
data : any = {}
) : void
{
if (game.listeners.hasOwnProperty(event))
{
game.listeners[event]
.forEach
(
(procedure) =>
{
procedure(data);
}
)
;
}
else
{
const message : string = "kein Ereignis mit diesem Name";
throw (new Error(message));
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function reset
(
game : type_game,
inform : boolean = true
)
: void
{
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(game, "change_token", {});
notify(game, "change_mode", {});
}
else
{
// nothing tun
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function task_read
(
game : type_game
)
: mod_task.type_task
{
return game.task;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function task_set
(
game : type_game,
task : mod_task.type_task
) : void
{
game.task = task;
// game.world_clear();
notify(game, "change_task", {});
reset(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function world_read
(
game : type_game
)
: mod_world.type_world
{
return game.world;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function world_set
(
game : type_game,
world : mod_world.type_world,
inform : boolean = true
)
: void
{
game.world = world;
if (inform)
{
notify(game, "change_world", {});
}
else
{
// nothing tun
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function world_clear
(
game : type_game,
inform : boolean = true
)
: void
{
game.world = mod_world.blanko();
if (inform)
{
notify(game, "change_world", {});
}
else
{
// nothing tun
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function token_read
(
game : type_game
)
: lib_errormonade.type_errormonade<mod_token.type_token>
{
return game.token;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function mode_read
(
game : type_game
)
: mod_mode.type_mode
{
return game.mode;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function world_tile_change
(
game : type_game,
spot : mod_spot.type_spot,
inverted : boolean = false
)
: void
{
if (! (game.mode === mod_mode.initial))
{
const message : string = "gesperrt";
}
else
{
mod_world.tile_change(game.world, spot, inverted);
notify
(
game,
"change_world",
{
"kind": "tile_change",
"data":
{
"spot": spot,
"inverted": inverted,
"tile": mod_world.tile_get(game.world, spot),
}
}
)
;
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function world_tile_rotate
(
game : type_game,
spot : mod_spot.type_spot,
increment : int = +1
)
: void
{
if (! (game.mode === mod_mode.initial))
{
const message : string = "gesperrt";
}
else
{
mod_world.tile_rotate(game.world, spot, increment);
notify(game, "change_world", {});
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function resume
(
game : type_game
)
: void
{
switch (game.mode)
{
case mod_mode.initial:
{
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>(game.token))
{
const test : mod_test.type_test = mod_task.tests(game.task)[lib_errormonade.read<int>(game.testindex)];
const tape : Array<mod_symbol.type_symbol> = lib_list.copy<mod_symbol.type_symbol>(mod_test.input(test));
const spot : mod_spot.type_spot = mod_world.generator_finden(game.world);
game.token = (
lib_errormonade.create_just<mod_token.type_token>
(
mod_token.create
(
tape,
spot
)
)
);
}
else
{
const token : mod_token.type_token = lib_errormonade.read<mod_token.type_token>(game.token);
const spot : mod_spot.type_spot = mod_token.spot_read(token);
const actuator_ : lib_errormonade.type_errormonade<mod_actuator.type_actuator> = mod_world.tile_get(game.world, spot);
const actuator : mod_actuator.type_actuator = (
lib_errormonade.filled<mod_actuator.type_actuator>(actuator_)
? lib_errormonade.read<mod_actuator.type_actuator>(actuator_)
: mod_actuator.mod_rejector.create_extended()
);
mod_actuator.use(actuator, token);
const state : mod_state.type_state = mod_token.state_read(token);
if (state === mod_state.running)
{
// nothing tun
}
else if ((state === mod_state.accepted) || (state === mod_state.rejected))
{
const accepted : boolean = (state === mod_state.accepted);
const output : Array<mod_symbol.type_symbol> = mod_token.tape_read(token);
game.token = (lib_errormonade.create_nothing<mod_token.type_token>());
let testindex : int = lib_errormonade.read<int>(game.testindex);
const tests : Array<mod_test.type_test> = mod_task.tests(game.task);
const test : mod_test.type_test = tests[testindex];
if (! mod_test.pruefen(test, accepted, output))
{
game.mode = mod_mode.wrong;
notify(game, "change_mode", {});
}
else
{
testindex += 1;
if (testindex < tests.length)
{
// nächsten Test auswählen
game.testindex = (lib_errormonade.create_just<int>(testindex));
}
else
{
// auf Modus "correct" change
game.testindex = (lib_errormonade.create_nothing<int>());
game.mode = mod_mode.correct;
notify(game, "change_mode", {});
}
}
}
else
{
const message : string = "unbehandelter Zustand";
throw (new Error(message));
}
}
notify(game, "change_token", {});
break;
}
case mod_mode.wrong:
{
// do nothing
break;
}
case mod_mode.correct:
{
// do nothing
break;
}
default:
{
const message : string = "unbehandelter Modus";
throw (new Error(message));
break;
}
}
}
}
}
}

View file

@ -1,223 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_model
{
export namespace mod_task
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_task = lib_call.type_complex<Object>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _liste : Array<type_task> = [];
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function id
(
task : type_task
)
: string
{
return (
lib_call.distinguish<string>
(
task,
{
"acceptortask": (data) => mod_acceptortask.id(data),
"transducertask": (data) => mod_transducertask.id(data),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function title
(
task : type_task
)
: string
{
return (
lib_call.distinguish<string>
(
task,
{
"acceptortask": (data) => mod_acceptortask.title(data),
"transducertask": (data) => mod_transducertask.title(data),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function text
(
task : type_task
)
: string
{
return (
lib_call.distinguish<string>
(
task,
{
"acceptortask": (data) => mod_acceptortask.text(data),
"transducertask": (data) => mod_transducertask.text(data),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tests
(
task : type_task
)
: Array<mod_test.type_test>
{
return (
lib_call.distinguish<Array<mod_test.type_test>>
(
task,
{
"acceptortask": (data) => (
mod_acceptortask.tests(data)
.map(data_ => ({"kind": "acceptortest", "data": data_}))
),
"transducertask": (data) => (
mod_transducertask.tests(data)
.map(data_ => ({"kind": "transducertest", "data": data_}))
),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function import_(task_raw : any) : type_task
{
switch (task_raw["kind"])
{
case "acceptor":
{
return {
"kind": "acceptortask",
"data": (
mod_acceptortask.create
(
task_raw["id"],
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_acceptortest.create
(
test_raw["input"],
test_raw["accept"]
)
)
)
)
)
};
break;
}
case "transducer":
{
return {
"kind": "transducertask",
"data": (
mod_transducertask.create
(
task_raw["id"],
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_transducertest.create
(
test_raw["input"],
test_raw["output"]
)
)
)
)
)
};
break;
}
default:
{
const message : string = "unbehandelte Art '" + task_raw["kind"] + "'";
throw (new Error(message));
break;
}
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function registrieren(task : type_task) : void
{
_liste.push(task);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function get(index : int) : type_task
{
return _liste[index];
}
}
}
}

View file

@ -1,403 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016-2018 kcf <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/>.
*/
namespace mod_vtm
{
export namespace mod_model
{
export namespace mod_world
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_world =
{
tiles : lib_hashmap.type_hashmap<mod_spot.type_spot, mod_actuator.type_actuator>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create
(
tiles : lib_hashmap.type_hashmap<mod_spot.type_spot, mod_actuator.type_actuator> = lib_hashmap.create<mod_spot.type_spot, mod_actuator.type_actuator>(mod_spot.hash)
)
: type_world
{
return {
"tiles": tiles,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tiles_read
(
world : type_world
)
: Array<{spot : mod_spot.type_spot; actuator : mod_actuator.type_actuator;}>
{
let tiles : Array<{spot : mod_spot.type_spot; actuator : mod_actuator.type_actuator;}> = [];
lib_hashmap.iterate
(
world.tiles,
(spot, actuator) => {tiles.push({"spot": spot, "actuator": actuator});}
)
;
return tiles;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tile_get
(
world : type_world,
spot : mod_spot.type_spot
)
: lib_errormonade.type_errormonade<mod_actuator.type_actuator>
{
return lib_hashmap.get(world.tiles, spot);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tile_set
(
world : type_world,
spot : mod_spot.type_spot,
actuator : mod_actuator.type_actuator
)
: void
{
lib_hashmap.set(world.tiles, spot, actuator);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tile_change
(
world : type_world,
spot : mod_spot.type_spot,
inverted : boolean = false
)
: void
{
const extended : boolean = true;
const liste : Array<{pruefer : (actuator : mod_actuator.type_actuator)=>boolean; erspotr : ()=>mod_actuator.type_actuator;}> = (
[]
.concat
(
[
{
"pruefer": (actuator) => (actuator.kind === "conveyer"),
"erspotr": () => mod_actuator.mod_conveyer.create_extended(0),
},
]
)
.concat
(
lib_list.sequence(extended ? 4 : 2).map
(
symbol => (
{
"pruefer": (actuator) =>
{
if (actuator.kind === "writer")
{
return (mod_actuator.mod_writer.symbol_read(actuator.data) === symbol);
}
else
{
return false;
}
}
,
"erspotr": () => mod_actuator.mod_writer.create_extended(0, symbol)
}
)
)
)
.concat
(
lib_list.sequence(extended ? 2 : 1).map
(
index =>
{
let symbol_links : mod_symbol.type_symbol = (2*index+0);
let symbol_rechts : mod_symbol.type_symbol = (2*index+1);
return (
{
"pruefer": (actuator) =>
{
if (actuator.kind === "reader")
{
return (
(mod_actuator.mod_reader.symbol_links_read(actuator.data) === symbol_links)
&&
(mod_actuator.mod_reader.symbol_rechts_read(actuator.data) === symbol_rechts)
);
}
else
{
return false;
}
}
,
"erspotr": () => mod_actuator.mod_reader.create_extended(0, symbol_links, symbol_rechts)
}
);
}
)
)
.concat
(
[
{
"pruefer": (actuator) => (actuator.kind === "rejector"),
"erspotr": () => mod_actuator.mod_rejector.create_extended(),
},
]
)
);
let index_alt : lib_errormonade.type_errormonade<int>;
const actuator_alt_ : lib_errormonade.type_errormonade<mod_actuator.type_actuator> = lib_hashmap.get(world.tiles, spot);
if (lib_errormonade.filled<mod_actuator.type_actuator>(actuator_alt_))
{
const actuator_alt : mod_actuator.type_actuator = lib_errormonade.read(actuator_alt_);
const gefunden : boolean = (
liste
.some
(
(entry, index) =>
{
if (entry.pruefer(actuator_alt))
{
index_alt = (lib_errormonade.create_just<int>(index));
return true;
}
else
{
return false;
}
}
)
);
if (! gefunden)
{
index_alt = (lib_errormonade.create_nothing<int>());
}
else
{
// nothing tun
}
}
else
{
const message : string = "kein Aktor gesetzt";
// console.warn(message);
index_alt = (lib_errormonade.create_just<int>(0));
}
if (lib_errormonade.filled<int>(index_alt))
{
const index_neu : int = lib_math.mod(lib_errormonade.read<int>(index_alt) + (inverted ? -1 : +1), liste.length);
const actuator_neu : mod_actuator.type_actuator = liste[index_neu].erspotr();
tile_set(world, spot, actuator_neu);
}
else
{
const message : string = ("Aktor nicht gefunden");
// throw (new Error(message));
console.warn(message);
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function tile_rotate
(
world : type_world,
spot : mod_spot.type_spot,
increment : int = +1
)
: void
{
let actuator_ : lib_errormonade.type_errormonade<mod_actuator.type_actuator> = lib_hashmap.get(world.tiles, spot);
if (lib_errormonade.filled<mod_actuator.type_actuator>(actuator_))
{
mod_actuator.rotate(lib_errormonade.read<mod_actuator.type_actuator>(actuator_), increment);
}
else
{
console.warn("kein Aktor gesetzt");
}
}
/**
* @author kcf <vidofnir@folksprak.org>
* @throws {Error}
*/
export function generator_finden
(
world : type_world
)
: mod_spot.type_spot
{
let spot : lib_errormonade.type_errormonade<mod_spot.type_spot> = (lib_errormonade.create_nothing<mod_spot.type_spot>());
lib_hashmap.iterate
(
world.tiles,
(spot_, actuator) =>
{
if (actuator.kind === "generator")
{
if (lib_errormonade.filled<mod_spot.type_spot>(spot))
{
const message : string = "mehrere Erzeuger gefunden";
throw (new Error(message));
}
else
{
spot = (lib_errormonade.create_just<mod_spot.type_spot>(spot_));
}
}
}
)
;
if (lib_errormonade.filled<mod_spot.type_spot>(spot))
{
return lib_errormonade.read<mod_spot.type_spot>(spot);
}
else
{
const message : string = "kein Erzeuger gefunden";
throw (new Error(message));
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function blanko
(
groesse : int = 3
)
: type_world
{
let world : type_world = create();
for (let u : int = -groesse; u <= +groesse; u += 1)
{
for (let v : int = -groesse; v <= +groesse; v += 1)
{
if (Math.abs(u-v) <= groesse)
{
const spot : mod_spot.type_spot = {"u": u, "v": v};
let actuator : mod_actuator.type_actuator;
if ((u === -groesse) && (v === 0))
{
actuator = mod_actuator.mod_generator.create_extended(0);
}
else if ((u === +groesse) && (v === 0))
{
actuator = mod_actuator.mod_acceptor.create_extended();
}
else
{
actuator = mod_actuator.mod_rejector.create_extended();
}
lib_hashmap.set(world.tiles, spot, actuator);
}
}
}
return world;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function export_
(
world : type_world
)
: any
{
let raw : any = {};
raw["tiles"] = {};
lib_hashmap.iterate
(
world.tiles,
(spot, actuator) =>
{
const spot_ : string = mod_spot.export_(spot);
const actuator_ : any = mod_actuator.export_(actuator);
raw["tiles"][spot_] = actuator_;
}
)
;
return raw;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function import_
(
raw : any
)
: type_world
{
let tiles : lib_hashmap.type_hashmap<mod_spot.type_spot, mod_actuator.type_actuator> = (lib_hashmap.create<mod_spot.type_spot, mod_actuator.type_actuator>(mod_spot.hash));
for (let spot_ in raw["tiles"])
{
const spot : mod_spot.type_spot = mod_spot.import_(spot_);
const actuator_ : mod_actuator.type_actuator = raw["tiles"][spot_];
const actuator : mod_actuator.type_actuator = mod_actuator.import_(actuator_);
lib_hashmap.set(tiles, spot, actuator);
}
return (
create
(
tiles
)
);
}
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -2,5 +2,4 @@
- Tests anzeigen? - Tests anzeigen?
- zufällige Tests? - zufällige Tests?
- Drehung beibehalten? - Drehung beibehalten?
- bessere Musik-Steuerung

View file

@ -1,4 +0,0 @@
#!/usr/bin/env sh
make --file=tools/makefile all

View file

@ -1,103 +0,0 @@
cmd_md := mkdir -p
cmd_rm := rm -rf
cmd_echo := echo # -e
cmd_cp := cp -r -u -v
cmd_cat := cat
cmd_tsc := tsc --target ES5 --allowUnreachableCode
cmd_sass := sassc
dir_source := source
dir_build := build
all: \
${dir_build}/vtm.html \
${dir_build}/vtm.css \
${dir_build}/vtm.dat.js \
${dir_build}/vtm.js \
music
.PHONY: all
clear:
@ ${cmd_echo} "-- clearing …"
@ ${cmd_rm} ${dir_build}
.PHONY: clear
${dir_build}/vtm.html: \
${dir_source}/main.html
@ ${cmd_echo} "-- structure …"
@ ${cmd_md} ${dir_build}
@ ${cmd_cp} $^ $@
${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_build}/vtm.dat.js: \
${dir_source}/data/strings/de.dat.js \
${dir_source}/data/strings/en.dat.js \
${dir_source}/data/strings/eo.dat.js \
${dir_source}/data/tasks.dat.js
@ ${cmd_echo} "-- data …"
@ ${cmd_md} ${dir_build}
@ ${cmd_cat} $^ > $@
${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/list.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 $@
music:
@ ${cmd_md} ${dir_build}/music
@ ${cmd_cp} ${dir_source}/music/* ${dir_build}/music/
.PHONY: music

View file

@ -1,13 +0,0 @@
#!/usr/bin/env sh
target=/tmp/vtm.tar.xz
tar \
--directory=.. \
--create \
--exclude='.git*' \
--exclude='tools*' \
vtm \
| xz \
> ${target}
echo "-- written to ${target}"

View file

@ -1 +0,0 @@
0.5.1

View file

@ -2,9 +2,10 @@
rsync \ rsync \
--verbose \ --verbose \
--archive \
--compress \
--recursive \ --recursive \
--delete \
--rsh=ssh \ --rsh=ssh \
build/* \ erzeugnis/* \
mehl:~/websites/folksprak.org/htdocs/vtm/ mehl:~/websites/folksprak.org/htdocs/vtm/

4
werkzeuge/bauen.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env sh
make all