{"id":229,"date":"2012-05-28T14:22:18","date_gmt":"2012-05-28T12:22:18","guid":{"rendered":"https:\/\/herr-rau.de\/blogs\/inform\/?page_id=229"},"modified":"2012-06-09T11:02:10","modified_gmt":"2012-06-09T09:02:10","slug":"aktionen-3-neue-aktionen-erzeugen-ein-wuerfel","status":"publish","type":"page","link":"https:\/\/herr-rau.de\/blogs\/inform\/?page_id=229","title":{"rendered":"Aktionen 3 &#8211; Neue Aktionen (Ein W\u00fcrfel)"},"content":{"rendered":"<p>Neue Aktionen muss man selten erzeugen, f\u00fcr viele W\u00fcnsche reichen die etwa 80 eingebauten Aktionen in Inform aus. Am h\u00e4ufigsten braucht man neue Aktionen, wenn man neue Gegenstand-Klassen einf\u00fchrt. Nehmen wir an, wir wollen W\u00fcrfel in unserer Spielwelt haben &#8211; dazu brauchen wir eine neue Klasse. Au\u00dferdem, aber das ist reiner Luxus, soll der Spieler &#8220;dice&#8221; eintippen k\u00f6nnen, wenn er gleich mehrere W\u00fcrfel auf einmal meint.<\/p>\n<p>Jeder W\u00fcrfel soll eine Zahl von Seiten haben (standardm\u00e4\u00dfig 6) und eine Zahl, die oben liegt (standardm\u00e4\u00dfig 1).<\/p>\n<pre class=\"brush: inform7; title: ; notranslate\" title=\"\">A die is a kind of thing.\r\nIt has a number called side number. The side number is usually 6.\r\nIt has a number called face. The face is usually 1.\r\nUnderstand &quot;dice&quot; as the plural of die.<\/pre>\n<p>Jetzt zu dem, was man mit dem W\u00fcrfel machen k\u00f6nnen soll: vorest soll man ihn nur w\u00fcrfeln k\u00f6nnen, danach liegt der W\u00fcrfel am Boden und eine zuf\u00e4llige Zahl liegt oben.<\/p>\n<p><strong>Als Erstes<\/strong> legen wir die Aktion an und legen ihre Valenz &#8211; das ist die Anzahl der grammatischen Objekte &#8211; und ein paar grundlegende Bedingungen fest:<\/p>\n<pre class=\"brush: inform7; title: ; notranslate\" title=\"\">Rolling is an action applying to one carried thing and requiring light.\r\n<\/pre>\n<p>&#8220;Carried&#8221; ist optional, macht hier aber Sinn: man kann nur etwas w\u00fcrfeln, was man bereits hat. Alternativ k\u00f6nnte man auch schreiben &#8220;visible&#8221;, wenn es um etwas geht, das man lediglich sehen muss, ein Fisch im geschlossenen Aquarium etwa, oder &#8220;touchable&#8221;, wenn es um etwas geht, das man sehen und ber\u00fchren kann, aber nicht bereits notwendigerweise mit sich f\u00fchrt. Die Erg\u00e4nzung &#8220;and requiring light&#8221; gibt an, dass die Aktion in einem dunklen Raum ohne Lichtquelle nicht m\u00f6glich ist &#8211; das spielte fr\u00fcher f\u00fcr Spiele eine gr\u00f6\u00dfere Rolle als heute.<br \/>\nStatt &#8220;one thing&#8221; k\u00f6nnte auch &#8220;nothing&#8221; oder &#8220;two things&#8221; stehen (ein direktes und ein indirektes Objekt), mehr sind aber nicht so einfach m\u00f6glich.<\/p>\n<p><strong>Zweitens<\/strong> brauchen wir mindestens ein Verb, dass der Parser als der Aktion zugeh\u00f6rig erkennen soll:<\/p>\n<pre class=\"brush: inform7; title: ; notranslate\" title=\"\">Understand &quot;roll &#x5B;something]&quot; as rolling.\r\nUnderstand &quot;shake &#x5B;something]&quot; as rolling.\r\n<\/pre>\n<p>Das [something] sagt dem Parser, dass alles nach dem Verb das gemeinte Objekt sein muss.<\/p>\n<p><strong>Drittens<\/strong> brauchen wir in den meisten F\u00e4llen auch Check-, Carry-out- und Report-Regeln. Eine Check-Regel soll sicherstellen, dass man nur W\u00fcrfel w\u00fcrfeln kann und nichts anderes; eine Carry-out-Regel bestimmt, was sich an der Welt \u00e4ndert (der W\u00fcrfel liegt danach auf dem Boden und eine neue Zahl liegt oben); eine Report-Regel sagt dem Spieler, was passiert ist:<\/p>\n<pre class=\"brush: inform7; title: ; notranslate\" title=\"\">Check rolling:\r\n\tIf the noun is not a die, say &quot;You can do that with dice only.&quot; instead.\r\nCarry out rolling:\r\n\tNow the face of the noun is a random number from 1 to the side number of the noun;\r\n\tnow the noun is in the location of the player.\r\nReport rolling:\r\n\tSay &quot;You roll &#x5B;the noun]. When it comes to rest on the ground, it shows a &#x5B;face].&quot;\r\n<\/pre>\n<p>Bei der Check-Regel muss man das <code>instead<\/code> beachten; es f\u00fchrt dazu, dass die Bearbeitung abgebrochen wird und die folgenden Regeln nicht mehr angewendet werden. Insbesondere werden so die Carry-out-Regeln daran gehindert, irgendetwas an der Welt zu \u00e4ndern.<br \/>\nDer Text in Anf\u00fchrungszeichen nach dem &#8220;say&#8221; ist jeweils Text, der an den Spieler ausgegeben wird. Eckige Klammern innerhalb von Anf\u00fchrungszeichen bedeuten <em>immer<\/em>, dass der String hier verlassen wird und stattdessen eine Kontrollstruktur oder ein Variablenbezeichner gemeint ist. Man k\u00f6nnte auch umst\u00e4ndlicher schreiben:<\/p>\n<pre class=\"brush: inform7; title: ; notranslate\" title=\"\">Say &quot;You roll &#x5B;the noun]. When it comes to rest on the ground, it shows a &quot;;  say face; say &quot;.&quot;<\/pre>\n<p>Dabei ist <code>the noun<\/code> immer eine lokale Variable f\u00fcr das direkte Objekt der aktuellen Aktion (also den W\u00fcrfel), <code>face<\/code> in unserem Fall ein Attribut des Objekts; wir h\u00e4tten auch korrekter und umst\u00e4ndlicher Schreiben k\u00f6nnen <code>face of the noun<\/code>.<\/p>\n<p>Das gesamte Programm auf einmal (kopieren, kompilieren und &#8220;test me&#8221; eintippen):<\/p>\n<pre class=\"brush: inform7; title: ; notranslate\" title=\"\">&quot;Dice 1&quot; by Herr Rau\r\n\r\nChapter 1 - New Kinds\r\n\r\nA die is a kind of thing.\r\nIt has a number called side number. The side number is usually 6.\r\nIt has a number called face. The face is usually 1.\r\nUnderstand &quot;dice&quot; as the plural of die.\r\n\r\nChapter 2 - New Actions\r\n\r\nRolling is an action applying to one carried thing and requiring light.\r\n\r\nUnderstand &quot;roll &#x5B;something]&quot; as rolling.\r\nUnderstand &quot;shake &#x5B;something]&quot; as rolling.\r\n\r\nCheck rolling:\r\n\tIf the noun is not a die, say &quot;You can do that with dice only.&quot; instead.\r\nCarry out rolling:\r\n\tNow the face of the noun is a random number from 1 to the side number of the noun;\r\n\tnow the noun is in the location of the player.\r\nReport rolling:\r\n\tSay &quot;You roll &#x5B;the noun]. When it comes to rest on the ground, it shows a &#x5B;face].&quot;\r\n\r\nChapter 3 - The World\r\n\r\nThe Casino is a room.\r\nThe green die is a die in the Casino.\r\nThe red die is a die in the Casino.\r\nThe basket is a container in the Casino.\r\n\r\nTest me with &quot;Take dice \/ roll green die \/ roll red die.&quot;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Neue Aktionen muss man selten erzeugen, f\u00fcr viele W\u00fcnsche reichen die etwa 80 eingebauten Aktionen in Inform aus. Am h\u00e4ufigsten braucht man neue Aktionen, wenn man neue Gegenstand-Klassen einf\u00fchrt. Nehmen wir an, wir wollen W\u00fcrfel in unserer Spielwelt haben &#8211; &hellip; <a href=\"https:\/\/herr-rau.de\/blogs\/inform\/?page_id=229\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":148,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-229","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=\/wp\/v2\/pages\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=229"}],"version-history":[{"count":0,"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=\/wp\/v2\/pages\/229\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=\/wp\/v2\/pages\/148"}],"wp:attachment":[{"href":"https:\/\/herr-rau.de\/blogs\/inform\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}