<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Forum Bauen und Umwelt - Autopilot</title>
<link>https://bauforum.wirklichewelt.de/</link>
<description>Das Bauforum</description>
<language>de</language>
<item>
<title>Autopilot (Antwort)</title>
<content:encoded><![CDATA[<p>Da Menschen wohl nicht in der Lage sind, so ein perfektes Spiel hinzubekommen …</p>
<p><img src="https://bauforum.wirklichewelt.de/images/uploaded/Bild_7XMA3Q0L1.gif" alt="[image]"  /></p>
<p>… habe ich mal einen Autopiloten in das Hamster-vs-Python-Spiel eingebaut, der mit Pos1 (Home) gestartet werden kann. Er reicht allerdings bei Weitem nicht an den Algorithmus aus dem GIF oben heran. </p>
<p><img src="https://bauforum.wirklichewelt.de/images/uploaded/Bild_1XGJZADW1.png" alt="[image]"  /></p>
<p>Verbesserungsvorschläge sind willkommen.</p>
<p>Download: <a href="images/uploaded/ZIP-Archiv_DTN3OFPF1.zip" target="_blank"><img src="img/zip.png" alt="[image]"  />ZIP-Archiv_DTN3OFPF1.zip</a></p>
<pre class="python" style="font-family:monospace;"><ol><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#! /usr/bin/python3</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> tkinter <span style="color: #ff7700;">import</span> Tk<span style="color: #000;">,</span> Canvas<span style="color: #000;">,</span> PhotoImage</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> tkinter.<span style="color: black;">messagebox</span> <span style="color: #ff7700;">import</span> showinfo<span style="color: #000;">,</span> askyesno</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> tkinter.<span style="color: black;">simpledialog</span> <span style="color: #ff7700;">import</span> askstring</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">random</span> <span style="color: #ff7700;">import</span> randint<span style="color: #000;">,</span> choice<span style="color: #000;">,</span> sample</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">getpass</span> <span style="color: #ff7700;">import</span> getuser</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">webbrowser</span> <span style="color: #ff7700;">import</span> <span style="color: #808;">open</span> <span style="color: #ff7700;">as</span> showpage</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">urllib</span>.<span style="color: black;">parse</span> <span style="color: #ff7700;">import</span> urlencode</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;">import</span> sleep<span style="color: #000;">,</span> strftime</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Python vs. Hamster</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># ~~~~~~~~~~~~~~~~~~</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Ein Beispielprogramm zur Auswertung der Daten von Eventhandlern für</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Tastendrücke und zur simplen Datenübermittlung an eine Webseite</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Version vom 1. Juli 2017</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Autor: Dipl.-Ing. Martin Vogel, Hochschule Bochum</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Lizenz: cc-by-3.0 https://creativecommons.org/licenses/by/3.0/de/</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Diese Abwandlung des klassischen Snake-Spiels lässt eine Schlange</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># kleine blaue Java-Hamster fressen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Das Spielfeld ist 29×29 Felder groß und wird auf einer Canvas in 24-facher</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Größe wiedergegeben.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Die Schlange wird mit den Cursortasten gesteuert.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Jeder Hamster lässt die Schlange um 5 Segmente wachsen und 5% schneller</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># werden. Für den ersten Hamster gibt es 100 Punkte, für den zweiten 200</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># und so weiter. Für jeden Bewegungsschritt wird wieder ein Punkt abgezogen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Das Spiel endet, wenn die Schlange gegen die Wand stößt oder mit sich</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># selbst kollidiert.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Auf einer Webseite lässt sich durch das Programm ein Highscorewert eintragen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">url <span style="color: #000;">=</span> <span style="color: #080;">&quot;http://ruhrhochschule.de/hamsterscore.py&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Diese Version des Spiels verfügt über einen Autopiloten, der mit &quot;Pos1&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># gestartet, mit &quot;End&quot; in den Turbomodus geschaltet und mit den Cursortasten</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># wieder beendet wird.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">Algorithmusname <span style="color: #000;">=</span> <span style="color: #080;">&quot;Große Welle 5&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Vorlage für den Hamsterkopf war das bekannte Motiv von Daniel Jasper und</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Dietrich Boles aus ihrem freien Programmierlernprogramm Hamster-Simulator.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">class</span> countdown:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;Zählt von 3 bis 1 rückwärts.&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Jede anfangs riesige bildfüllende Ziffer wird innerhalb einer Sekunde</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># immer kleiner.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> event<span style="color: #000;">=</span><span style="color: #808;">None</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Mauszeiger für die Canvas abschalten</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">config</span><span style="color: black;">&#40;</span>cursor<span style="color: #000;">=</span><span style="color: #080;">&quot;none&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Bildschirm aufräumen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">delete</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Hamster.<span style="color: black;">verstecken</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Anfangswert</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">counter</span> <span style="color: #000;">=</span> <span style="color: #008;">3</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ziffer rot und mittig anzeigen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">text</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_text</span><span style="color: black;">&#40;</span><span style="color: #008;">360</span><span style="color: #000;">,</span> <span style="color: #008;">360</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;red&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zähler starten</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">count</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> count<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Animationsschritt des Countdowns&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Attribut counter zählt Sekundenbruchteile; angezeigt werden nur</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># die ganzen Sekunden.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        n <span style="color: #000;">=</span> <span style="color: #808;">int</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">counter</span><span style="color: black;">&#41;</span> + <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Zifferngröße in Pixeln entspricht dem Nachkommawert mal 1000</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        s <span style="color: #000;">=</span> <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">counter</span>*<span style="color: #008;">1000</span><span style="color: black;">&#41;</span> % <span style="color: #008;">1000</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Neue Größe setzen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">text</span><span style="color: #000;">,</span> text<span style="color: #000;">=</span>n<span style="color: #000;">,</span> font<span style="color: #000;">=</span><span style="color: #080;">&quot;helvetica -%i bold&quot;</span> % s<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Alle 17 ms soll ein Animationsschritt erfolgen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">counter</span> -<span style="color: #000;">=</span> <span style="color: #008;">0.017</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">counter</span> <span style="color: #000;">&gt;</span> <span style="color: #008;">0</span> <span style="color: #ff7700;">and</span> <span style="color: #ff7700;">not</span> Schlange.<span style="color: black;">Turbo</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">after</span><span style="color: black;">&#40;</span><span style="color: #008;">17</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">count</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">delete</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">text</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Schlange.<span style="color: black;">Start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">def</span> username<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;Gibt den Spielernamen zurück&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Wurde der schon eingegeben?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">if</span> <span style="color: #808;">hasattr</span><span style="color: black;">&#40;</span>Hamster<span style="color: #000;">,</span> <span style="color: #080;">&quot;username&quot;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> Hamster.<span style="color: black;">username</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Fragen wir doch mal das Betriebssystem nach dem Anmeldenamen:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> getuser<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Dieser kann übernommen oder geändert werden.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> askstring<span style="color: black;">&#40;</span><span style="color: #080;">&quot;Hallo, äh … &quot;</span>+un+<span style="color: #080;">&quot;?&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                       <span style="color: #080;">&quot;Gib Deinen Namen ein:&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                       initialvalue<span style="color: #000;">=</span>un<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wurde die Eingabe mit &quot;OK&quot; bestätigt?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> un:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">username</span> <span style="color: #000;">=</span> un</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Oder wurde der Eingabedialog abgebrochen?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            un <span style="color: #000;">=</span> <span style="color: #080;">&quot;&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">return</span> un</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">class</span> C_Hamster:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;&quot;&quot;Der Hamster weiß, wo er ist, wie er aussieht und alles wichtige</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #080;">       über den Spieler.&quot;&quot;&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Hamsterbild (24×24 Pixel, GIF) muss im Verzeichnis des</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Pythonprogramms liegen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">try</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wenn es da ist, merkt sich der Hamster sein Aussehen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">bilddatei</span> <span style="color: #000;">=</span> PhotoImage<span style="color: black;">&#40;</span><span style="color: #808;">file</span><span style="color: #000;">=</span><span style="color: #080;">&quot;Hamster24.gif&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">bild_ID</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_image</span><span style="color: black;">&#40;</span>-<span style="color: #008;">24</span><span style="color: #000;">,</span> -<span style="color: #008;">24</span><span style="color: #000;">,</span> image<span style="color: #000;">=</span><span style="color: #808;">self</span>.<span style="color: black;">bilddatei</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">except</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Falls nicht, gibt's 'nen schnöden Ersatzhamster: ⬤ u2b24</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">bild_ID</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_text</span><span style="color: black;">&#40;</span>-<span style="color: #008;">24</span><span style="color: #000;">,</span> -<span style="color: #008;">24</span><span style="color: #000;">,</span> text<span style="color: #000;">=</span><span style="color: #080;">&quot;⬤&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                         font<span style="color: #000;">=</span><span style="color: #080;">&quot;courier -24 bold&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                         fill<span style="color: #000;">=</span><span style="color: #080;">&quot;blue&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Immer, wenn die persönliche Bestleistung übertroffen wird,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># gibt es das Angebot, es in die Highscoreliste einzutragen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">highscore</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zu Beginn jeder Runde:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> reset<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Anzahl der Wiederbelebungen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">z</span>ähler <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Aktuell erreichte Punktzahl</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">punkte</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Philosophischer Einschub:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># F: „Wieso bekommt eigentlich der Hamster die Punkte und nicht die</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Schlange?“</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># A: „Nun, wer glaubt, dass es in diesem Spiel darum geht, Hamster zu</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    besiegen, hat die Fabel vom Hasen und Igel nicht verstanden.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    In Wirklichkeit gewinnt nämlich immer der Hamster die Spielrunden</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    und die Schlange stirbt.“</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># F: „…“</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># A: „Schockierend. Ich weiß.“</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># F: „Mooment! Wieso gibt es dann umso mehr Punkte für den Hamster, je</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    häufiger die Schlange gefüttert wird?“</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># A: „*seufz* OK, das war vorhin doch nicht die ganze Wahrheit über das</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Spiel; in wirklicher Wirklichkeit gibt es die Punkte für die</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    heimliche, weil illegale, Entsorgung der ganzen veganen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Biodinkelriegel, die der Hamster versehentlich gehortet hat und</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    die er nun an die Schlange verfüttert.“</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Jetzt aber weiter im Quelltext:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> umsetzen<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;&quot;&quot;Setzt den Hamster auf ein zufälliges Feld, das noch nicht von</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #080;">        der Schlange belegt ist.&quot;&quot;&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Liste der freien Koordinaten, die mindestens 2 Felder vom Rand</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># entfernt sind (der Hamster soll nicht am Rand oder in einer</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ecke hocken):</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Frei <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>x<span style="color: #000;">,</span> y<span style="color: black;">&#41;</span> <span style="color: #ff7700;">for</span> x <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">3</span><span style="color: #000;">,</span> <span style="color: #008;">28</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;">for</span> y <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">3</span><span style="color: #000;">,</span> <span style="color: #008;">28</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">if</span> <span style="color: black;">&#40;</span>x<span style="color: #000;">,</span> y<span style="color: black;">&#41;</span> <span style="color: #ff7700;">not</span> <span style="color: #ff7700;">in</span> Schlange.<span style="color: black;">Felder</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> Versuch <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">100</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> -<span style="color: #008;">1</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># irgendein freies Feld auswürfeln</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">xy</span> <span style="color: #000;">=</span> choice<span style="color: black;">&#40;</span>Frei<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># gewünschter Abstand</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Abstand <span style="color: #000;">=</span> Versuch//<span style="color: #008;">10</span> + <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wenn die Schlange zu dicht ist, ist das Feld tabu</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Tabu <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Nachbarschaft scannen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">for</span> x <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">xy</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span>-Abstand<span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">xy</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span>+Abstand+<span style="color: #008;">1</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">for</span> y <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">xy</span><span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span>-Abstand<span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">xy</span><span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span>+Abstand+<span style="color: #008;">1</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    <span style="color: #ff7700;">if</span> <span style="color: black;">&#40;</span>x<span style="color: #000;">,</span>y<span style="color: black;">&#41;</span> <span style="color: #ff7700;">in</span> Schlange.<span style="color: black;">Felder</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        Tabu <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        <span style="color: #ff7700;">break</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">if</span> Tabu: <span style="color: #ff7700;">break</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> Tabu: </div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># Freies Feld gefunden. Schleife abbrechen!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">break</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Hamsterbild auf die neue Canvas-Position verschieben:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        x<span style="color: #000;">,</span> y <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">xy</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span>Hamster.<span style="color: black;">bild_ID</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*x<span style="color: #000;">,</span> <span style="color: #008;">24</span>*y<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Titelzeile des Fensters aktualisieren</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> Schlange.<span style="color: black;">benutzeAutopilot</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            s <span style="color: #000;">=</span> Algorithmusname+<span style="color: #080;">&quot; sucht den&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            s <span style="color: #000;">=</span> <span style="color: #080;">&quot;Füttere den Python mit dem&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span>s+<span style="color: #080;">&quot; %i. Java-Hamster!&quot;</span> %</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">z</span>ähler+<span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> verstecken<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Hamster auf eine nicht sichtbare Koordinate&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span>Hamster.<span style="color: black;">bild_ID</span><span style="color: #000;">,</span> -<span style="color: #008;">100</span><span style="color: #000;">,</span> -<span style="color: #008;">100</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">def</span> Highscore<span style="color: black;">&#40;</span>Grund<span style="color: #000;">,</span> Punkte<span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;Zeigt den Highscore-Dialog an&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Mauszeiger für die Canvas wieder einschalten</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    C.<span style="color: black;">config</span><span style="color: black;">&#40;</span>cursor<span style="color: #000;">=</span><span style="color: #080;">&quot;arrow&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Kennen wir uns?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">try</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> <span style="color: #080;">&quot;, &quot;</span>+Hamster.<span style="color: black;">username</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># nö.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">except</span> <span style="color: #808;">AttributeError</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> <span style="color: #080;">&quot;&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Wie laut müssen wir jubeln?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">if</span> Punkte <span style="color: #000;">&gt;</span> Hamster.<span style="color: black;">highscore</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Konfetti, Sekt, Fanfaren!</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Jubel <span style="color: #000;">=</span> <span style="color: #080;">&quot;Bravo&quot;</span>+un+<span style="color: #080;">&quot;, das ist Deine neue persönliche &quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #080;">&quot;Bestleistung!&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das wird der neue Highscore</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Hamster.<span style="color: black;">highscore</span> <span style="color: #000;">=</span> Punkte</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">elif</span> Punkte:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schlechter geworden?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Jubel <span style="color: #000;">=</span> <span style="color: #080;">&quot;Beim nächsten Mal schaffst Du wieder mehr&quot;</span>+un+<span style="color: #080;">&quot;!&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 0 Punkte? Sei trotzdem nett zu dem N00b:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Jubel <span style="color: #000;">=</span> <span style="color: #080;">&quot;Tipp: Steuere den Python mit den Pfeiltasten!&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Bei menschlichen Spielern Dialog anzeigen, bei Autopilot</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># nur protokollieren.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">if</span> Schlange.<span style="color: black;">benutzeAutopilot</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Datum und Uhrzeit für die Logdatei</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        jetzt <span style="color: #000;">=</span> strftime<span style="color: black;">&#40;</span><span style="color: #080;">&quot;%F %T&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Jedes einzelne Ergebnis wird in der großen Logdatei protokolliert</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">with</span> <span style="color: #808;">open</span><span style="color: black;">&#40;</span>Algorithmusname+<span style="color: #080;">&quot;.log&quot;</span><span style="color: #000;">,</span><span style="color: #080;">&quot;a&quot;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;">as</span> log:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">print</span><span style="color: black;">&#40;</span>jetzt<span style="color: #000;">,</span>Punkte<span style="color: #000;">,</span>sep<span style="color: #000;">=</span><span style="color: #080;">&quot;t&quot;</span><span style="color: #000;">,</span><span style="color: #808;">file</span><span style="color: #000;">=</span>log<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Neuer Highscore?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> Hamster.<span style="color: black;">highscore</span> <span style="color: #000;">==</span> Punkte:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Kleine Logdatei nur für neue Highscores</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">with</span> <span style="color: #808;">open</span><span style="color: black;">&#40;</span>Algorithmusname+<span style="color: #080;">&quot;_highscore.log&quot;</span><span style="color: #000;">,</span><span style="color: #080;">&quot;a&quot;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;">as</span> log:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">print</span><span style="color: black;">&#40;</span>jetzt<span style="color: #000;">,</span>Punkte<span style="color: #000;">,</span>sep<span style="color: #000;">=</span><span style="color: #080;">&quot;t&quot;</span><span style="color: #000;">,</span><span style="color: #808;">file</span><span style="color: #000;">=</span>log<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Canvas als Bilddatei speichern    </span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">postscript</span><span style="color: black;">&#40;</span><span style="color: #808;">file</span><span style="color: #000;">=</span>Algorithmusname+strftime<span style="color: black;">&#40;</span><span style="color: #080;">&quot; %F %T &quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         +<span style="color: #808;">str</span><span style="color: black;">&#40;</span>Punkte<span style="color: black;">&#41;</span>+<span style="color: #080;">&quot;.eps&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         colormode<span style="color: #000;">=</span><span style="color: #080;">'color'</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Highscore auf der Website eintragen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            showpage<span style="color: black;">&#40;</span>url+<span style="color: #080;">&quot;?&quot;</span>+urlencode<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;n&quot;</span><span style="color: #000;">,</span> Algorithmusname<span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                        <span style="color: black;">&#40;</span><span style="color: #080;">&quot;p&quot;</span><span style="color: #000;">,</span> Punkte<span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                        <span style="color: black;">&#40;</span><span style="color: #080;">&quot;b&quot;</span><span style="color: #000;">,</span> <span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Algorithmus &quot;</span><span style="color: #080;">&quot;+Algorithmusname+</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #080;">                &quot;</span><span style="color: #080;">&quot; wird fortgesetzt.&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        countdown<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">elif</span> askyesno<span style="color: black;">&#40;</span>Grund<span style="color: #000;">,</span> <span style="color: #080;">&quot;Du hast %i Hamsterpunkte!nn%s&quot;</span> % <span style="color: black;">&#40;</span>Punkte<span style="color: #000;">,</span> Jubel<span style="color: black;">&#41;</span> +</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                  <span style="color: #080;">&quot;nnMöchtest Du Dich in die Highscoreliste eintragen?&quot;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Highscore auf der Website eintragen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> Schlange.<span style="color: black;">AutopilotWurdeVerwendet</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            showinfo<span style="color: black;">&#40;</span>title<span style="color: #000;">=</span><span style="color: #080;">&quot;Problem&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                     message<span style="color: #000;">=</span><span style="color: #080;">&quot;Du hast den Autopiloten verwendet&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                     detail<span style="color: #000;">=</span><span style="color: #080;">&quot;Einträge in die Highscoreliste sind nur möglich, &quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                     <span style="color: #080;">&quot;wenn die Schlange während der ganzen Runde von Hand &quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                     <span style="color: #080;">&quot;gesteuert wurde.&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            showpage<span style="color: black;">&#40;</span>url+<span style="color: #080;">&quot;?&quot;</span>+urlencode<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;n&quot;</span><span style="color: #000;">,</span> username<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                        <span style="color: black;">&#40;</span><span style="color: #080;">&quot;p&quot;</span><span style="color: #000;">,</span> Punkte<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Neustart mit der Eingabetaste!&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Mache Dich bereit!&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        countdown<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">class</span> C_Schlange:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;&quot;&quot;Die Schlange merkt sich die durch sie belegten Felder und deren</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #080;">    Canvas-Objekte sowie die letzte Hamstermahlzeit.&quot;&quot;&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Die Schlange schlüpft.&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Sie bewegt sich noch nicht vom Fleck.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span> <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Turbo</span> <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> reset<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Startwerte der Schlange werden gesetzt.&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zufällige Startpostition 10 Felder vom Rand entfernt</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">x</span> <span style="color: #000;">=</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">10</span><span style="color: #000;">,</span> <span style="color: #008;">20</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">y</span> <span style="color: #000;">=</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">10</span><span style="color: #000;">,</span> <span style="color: #008;">20</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zufällige Richtung: nach rechts, links, oben oder unten.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Setzt dx und dy entsprechend auf -1, 0 oder +1.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Richtung</span><span style="color: black;">&#40;</span>choice<span style="color: black;">&#40;</span><span style="color: #080;">&quot;rlou&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Elemente der Liste &quot;Felder&quot; bestehen aus (x,y)-Tupeln.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der Kopf der Schlange ist auf (self.x, self.y).</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Felder</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Fünf Rumpfsegmente entgegen der Bewegungsrichtung anhängen:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">1</span><span style="color: #000;">,</span> <span style="color: #008;">6</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Felder</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span>-i*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span>-i*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wartezeit zwischen zwei Schritten: anfangs 100 Millisekunden,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># später wird die Schlange immer schneller.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">ms</span> <span style="color: #000;">=</span> <span style="color: #008;">100</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Schlange braucht 5 Schritte, um eine Mahlzeit zu verdauen und</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># dabei zu wachsen. Jetzt ist der Magen gerade leer.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Falls pro Bewegungsschritt mehrere Tasten gedrückt werden,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># kommen die in einen Puffer, sodass pro Schritt nur eine</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Richtungsänderung vorgenommen wird.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Highscoreeinträge der Kategorie &quot;menschlicher Spieler&quot; sollen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># nur möglich sein, wenn zwischendurch nicht nachgeholfen wurde.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">AutopilotWurdeVerwendet</span> <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Richtung<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> rlou<span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Delta-x- bzw. -y-Wert für die nächsten Bewegungsschritte&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Unmittelbar tödliche 180°-Kehren werden nicht zugelassen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;l&quot;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dx</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> -<span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">elif</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;r&quot;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dx</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;u&quot;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">elif</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;o&quot;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> -<span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Taste<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> key<span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Hängt einen Tastendruck an den Eingabepuffer an.&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Autopilot ausgeschaltet! Manuelle Steuerung aktiv.&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span> <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Turbo</span> <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> zeichneKopf<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Kopf in richtiger Orientierung auf sein neues Feld.&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        x<span style="color: #000;">,</span> y <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Trapezförmigen Kopf je nach Bewegungsrichtung drehen:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x+<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x+<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Augenlinie (gestrichelt) von links nach rechts:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span>-<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span>-<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span>+<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span>+<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Start<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> event<span style="color: #000;">=</span><span style="color: #808;">None</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Hamster um und baut die Schlange neu auf&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die tatsächlichen Koordinaten einiger Elemente werden</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># erst bei Bewegung der Schlange gesetzt. Sie werden außerhalb</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># der Canvas zwischengelagert.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        außerhalb <span style="color: #000;">=</span> -<span style="color: #008;">99</span><span style="color: #000;">,</span> -<span style="color: #008;">99</span><span style="color: #000;">,</span> -<span style="color: #008;">99</span><span style="color: #000;">,</span> -<span style="color: #008;">99</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schlange zeichnen: zuunterst liegt eine dicke blaue Linie.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Gleich kommt noch eine zweite Linie hinzu, für sie ist hier der</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Platzhalter &quot;None&quot;.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">K</span>örper <span style="color: #000;">=</span> <span style="color: black;">&#91;</span>C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     fill<span style="color: #000;">=</span><span style="color: #080;">&quot;blue&quot;</span><span style="color: #000;">,</span> smooth<span style="color: #000;">=</span><span style="color: #008;">1</span><span style="color: #000;">,</span> tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     joinstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span> capstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     width<span style="color: #000;">=</span><span style="color: #008;">24</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                       <span style="color: #808;">None</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der Kopf der Schlange wird ein Trapez, dessen kurze Seite stets in</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Bewegungsrichtung zeigen wird.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Kopf</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_polygon</span><span style="color: black;">&#40;</span>außerhalb<span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">4</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;yellow&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     outline<span style="color: #000;">=</span><span style="color: #080;">&quot;blue&quot;</span><span style="color: #000;">,</span> joinstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;bevel&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Auflösung des None-Rätsels von oben: Die gelbe Füllung des Körpers</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># liegt in der Zeichenreihefolge über dem Kopf, damit die &quot;Nackenlinie&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># nicht zu sehen ist. Beide Körperlinien werden in einer Liste</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># gespeichert, damit sie mittels einer Schleife modifiziert werden</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># können.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">K</span>örper<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                       fill<span style="color: #000;">=</span><span style="color: #080;">&quot;yellow&quot;</span><span style="color: #000;">,</span> smooth<span style="color: #000;">=</span><span style="color: #008;">1</span><span style="color: #000;">,</span> tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                       joinstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span> capstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                       width<span style="color: #000;">=</span><span style="color: #008;">16</span><span style="color: #000;">,</span> dash<span style="color: #000;">=</span><span style="color: black;">&#40;</span><span style="color: #008;">1</span><span style="color: #000;">,</span><span style="color: #008;">15</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Strichelung der gelben Körperlinie kann dazu führen, dass</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># ein großes Stück des Schwanzes blau bleibt. Hier tupfen wir ein</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># wenig Make-Up in Form einer Kreisscheibe nach.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Schwanzspitze</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_oval</span><span style="color: black;">&#40;</span>außerhalb<span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;yellow&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                           outline<span style="color: #000;">=</span><span style="color: #080;">&quot;yellow&quot;</span><span style="color: #000;">,</span> tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Augen liegen zuoberst und bestehen aus einer einzigen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># geschickt gestrichelten Linie: &quot;*  *&quot;.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Augen</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span>außerhalb<span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">8</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;black&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                   tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: #000;">,</span> capstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                   dash<span style="color: #000;">=</span><span style="color: black;">&#40;</span><span style="color: #008;">5</span><span style="color: #000;">,</span><span style="color: #008;">11</span><span style="color: #000;">,</span><span style="color: #008;">5</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Hamster umsetzen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># (In Wahrheit wird der nämlich gar nicht gefressen, sondern immer</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#  rechtzeitig weggebeamt. Die arme Schlange erhält stattdessen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#  einen veganen Biodinkelriegel.)</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># (Ja, sowas erfährt man nur, wenn man Quelltextkommentare liest.)</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Hamster.<span style="color: black;">umsetzen</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Go!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">after</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">ms</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">Bewege</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Stirb<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> innenFarbe<span style="color: #000;">,</span> außenFarbe<span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Animation zeigt durch Farbveränderung das Ende der Spielrunde an.&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Schlange verändert innerhalb einer Sekunde ihre</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Farbe vom Kopf bis zur Schwanzspitze. Der nach jedem Abschnitt</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># erfolgende Aufruf von „update_idletasks“ sorgt dafür, dass die</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Änderung sofort angezeigt wird und nicht erst, wenn das Programm</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># wieder in der Mainloop ist.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Im Turbomodus entfällt diese hübsche Animation.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">Turbo</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">return</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopf heben und Augen weit aufreißen!</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">tag_raise</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">tag_raise</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">20</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Augenfarbe ändern</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>außenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopfinneres umfärben</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>innenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopfrand umfärben</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: #000;">,</span> outline<span style="color: #000;">=</span>außenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Körperinneres umfärben</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">K</span>örper<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>innenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Schwanzspitze</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>innenFarbe<span style="color: #000;">,</span> outline<span style="color: #000;">=</span>innenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Augen schließen …</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">K</span>örper<span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>außenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">20</span><span style="color: #000;">,</span><span style="color: #008;">1</span><span style="color: #000;">,</span>-<span style="color: #008;">1</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span>i<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.02</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># R.I.P.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">pass</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> starteAutopilot<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Die Steuerung der Schlange wird von einem Algorithmus übernommen.&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span> <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">AutopilotWurdeVerwendet</span> <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Turbo</span> <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Autopilot aktiviert. &quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #080;">&quot;Algorithmus &quot;</span>%s<span style="color: #080;">&quot; arbeitet.&quot;</span> % Algorithmusname<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> starteTurbo<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Alle bremsenden Warteschleifen und Animationen deaktivieren&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Turbo</span> <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Turbomodus aktiviert! Ende mit Pos1 oder Cursortasten&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Autopilot<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt self.dx und self.dy auf Basis eines Algorithmus.&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Algorithmus: &quot;Große Welle 5&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Strategie: Kürzesten Weg zum Hamster markieren, Inseln vermeiden</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ausgehend vom Hamsterfeld werden wellenförmig Ringe aus den im</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># jeweils nächsten Schritt erreichbaren Feldern gebaut.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># In die Felder wird die Anzahl der Schritte bis zum Hamster</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># eingetragen. Die Schlange muss nun nur noch in Richtung des Feldes</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># mit der niedrigsten Nummer gleiten.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#       </span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 1. Matrix in Spielfeldgröße (29×29) anlegen, mit dem Wert 999 füllen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Schlangenfelder erhalten den Wert 1000+s, wobei s die Entfernung</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    zum Kopf in Schlangensegmenten ist.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Das Hamsterfeld erhält den Wert 0.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Ringsum wird noch ein Rand mit Wert 9999 angeordnet, dadurch</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    vermeiden wir Indexfehler beim Untersuchen der Nachbarfelder.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 2. Vom Hamsterfeld beginnend erhalten alle noch nicht bewerteten</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Nachbarfelder, die kein Schlangenfeld sind, den Wert n+1, wobei n</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    die Entfernung des aktuellen Feldes zum Hamster ist.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 3. Schritt 2 wird für alle gefundenen Nachbarfelder wiederholt.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 4. Sobald die &quot;Welle&quot; den Schlangenkopf erreicht, ist der kürzeste</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Pfad gefunden.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 5. Die Schlange bewegt sich nun immer in Richtung des Feldes mit dem</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    geringsten Wert. Falls die Möglichkeit besteht, durch</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Richtungswechsel zu einem gleichwertigen Feld am eigenen Körper</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    entlang zu gleiten, wird das zur Vermeidung von Inseln ausgeführt.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    Stehen mehrere dieser Felder zur Auswahl, wird das mit den</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    wenigsten Segmenten vom Schwanz entfernte Schlangensegment</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#    bevorzugt.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zu verbessern: Selbstmord durch Kurzsichtigkeit vermeiden!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Es fehlt derzeit jede Rückzugstrategie. Die Schlange gleitet</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># gnadenlos in Sackgassen und verbaut sich selbst den Rückweg.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die maximale Punktzahl dieser Strategie liegt bei etwa 450_000.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># So könnte eine optimale Lösung aussehen:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># The Perfect Snake</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   Mike James, 2013</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   http://www.i-programmer.info/news/144-graphics-and-games/</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#          5754-the-perfect-snake.html</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Etwas simpler:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   https://www.youtube.com/watch?v=kTIPpbIbkos</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Sterbenslangweilig, aber deprimierend erfolgreich:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   http://www.datagenetics.com/blog/april42013/</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Literatur:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Snake: Artificial Intelligence Controller</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   Patrick Merrill, 2011</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   http://www.cs.unh.edu/~ruml/cs730/paper-examples/merrill-2011.pdf</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Gaming is a hard job, but someone has to do it!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   Giovanni Viglietta, 2013</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   https://arxiv.org/abs/1201.4995</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># A Knowledge-based Approach of Connect-Four</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   The Game is Solved: White Wins</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   Victor Allis, 1988</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#   http://www.informatik.uni-trier.de/~fernau/DSL0607/</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#          Masterthesis-Viergewinnt.pdf</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Bewertungsmatrix</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">A</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#91;</span><span style="color: #008;">999</span> <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">31</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">31</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Randfelder</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">31</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span> <span style="color: #000;">=</span> <span style="color: #008;">9999</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span><span style="color: #008;">30</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span> <span style="color: #000;">=</span> <span style="color: #008;">9999</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span> <span style="color: #000;">=</span> <span style="color: #008;">9999</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #008;">30</span><span style="color: black;">&#93;</span> <span style="color: #000;">=</span> <span style="color: #008;">9999</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Startfeld            </span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        xh<span style="color: #000;">,</span> yh <span style="color: #000;">=</span> Hamster.<span style="color: black;">xy</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>xh<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>yh<span style="color: black;">&#93;</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Segmente der Schlange, die vom Kopf nicht erreicht werden</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># können, müssen nicht eingetragen werden.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopfposition der Schlange</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        xs<span style="color: #000;">,</span> ys <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Alle Felder untersuchen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> n<span style="color: #000;">,</span> Feld <span style="color: #ff7700;">in</span> <span style="color: #808;">enumerate</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            x<span style="color: #000;">,</span> y <span style="color: #000;">=</span> Feld</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wenn der Kopf dieses Körpersegment in n Schritten</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># erreichen kann (unter der äußerst vereinfachenden Annahme,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># dass der Weg dorthin frei sei):</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #808;">abs</span><span style="color: black;">&#40;</span>x-xs<span style="color: black;">&#41;</span>+<span style="color: #808;">abs</span><span style="color: black;">&#40;</span>y-ys<span style="color: black;">&#41;</span> <span style="color: #000;">&lt;=</span> n + <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #000;">=</span> <span style="color: #008;">1000</span> + n</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Liste &quot;Aktuell&quot; wird in jedem Schleifendurchlauf auf</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># neu zu untersuchende Nachbarn hin ausgewertet.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Diese landen zunächst in der Liste &quot;Neu&quot;.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Neu <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>xh<span style="color: #000;">,</span>yh<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Strecke bis zum Hamsterfeld</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        n <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wenn ein Pfad vom Schlangenkopf zum Hamster gefunden wurde,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># ist der Suchalgorithmus fertig.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        fertig <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">while</span> <span style="color: #ff7700;">not</span> fertig:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Ein Schritt mehr zum Hamster</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            n +<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die neue hinzugekommenen Felder aus dem letzten Durchlauf</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># werden zu den aktuell zu untersuchenden Feldern.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Aktuell <span style="color: #000;">=</span> Neu<span style="color: black;">&#91;</span>:<span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die Liste &quot;Neu&quot; sammelt die Kandidaten für den nächsten</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Schleifendurchlauf.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Neu <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Für alle Felder, die in diesem Durchlauf dran sind:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">for</span> Ak <span style="color: #ff7700;">in</span> Aktuell:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># Alle vier Nachbarfelder durchgehen:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">for</span> x<span style="color: #000;">,</span> y <span style="color: #ff7700;">in</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span>-<span style="color: #008;">1</span><span style="color: #000;">,</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span><span style="color: black;">&#40;</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span>+<span style="color: #008;">1</span><span style="color: #000;">,</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                             <span style="color: black;">&#40;</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: #000;">,</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span>-<span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span><span style="color: black;">&#40;</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: #000;">,</span>Ak<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span>+<span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    <span style="color: #800; font-style: italic;"># Ein freies Feld?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #000;">==</span> <span style="color: #008;">999</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        <span style="color: #800; font-style: italic;"># Schrittzahl zum Hamster eintragen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #000;">=</span> n</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        <span style="color: #800; font-style: italic;"># Feld für den nächsten Durchlauf merken</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        Neu.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>x<span style="color: #000;">,</span>y<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    <span style="color: #800; font-style: italic;"># Ein Schlangenfeld?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    <span style="color: #ff7700;">elif</span> <span style="color: #008;">9999</span> <span style="color: #000;">&gt;</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #000;">&gt;=</span> <span style="color: #008;">1000</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        <span style="color: #800; font-style: italic;"># Der Kopf?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                        <span style="color: #ff7700;">if</span> <span style="color: black;">&#40;</span>x<span style="color: #000;">,</span> y<span style="color: black;">&#41;</span> <span style="color: #000;">==</span> <span style="color: black;">&#40;</span>xs<span style="color: #000;">,</span> ys<span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                            <span style="color: #800; font-style: italic;"># Der Pfad vom Kopf zum Hamster ist gefunden!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                            fertig <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                            <span style="color: #ff7700;">break</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">if</span> fertig:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    <span style="color: #ff7700;">break</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wenn keine leeren Felder mehr erreichbar sind:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> Neu:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># Suche ist abgeschlossen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                fertig <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># &quot;Impulserhaltung&quot;: die Schlange behält zunächst einmal ihre</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Richtung bei.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Zielwert <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span>+<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #808;">self</span>.<span style="color: black;">y</span>+<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Falls jedoch eines der in zufälliger Reihenfolge untersuchten</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Nachbarfelder attraktiver ist oder gleichwertig, aber dem</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># schwanznächsten Schlangensegment benachbart ist …</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        snSS <span style="color: #000;">=</span> <span style="color: #008;">1000</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> x<span style="color: #000;">,</span> y <span style="color: #ff7700;">in</span> sample<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span>-<span style="color: #008;">1</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                            <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span>+<span style="color: #008;">1</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                            <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span>-<span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                            <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span>+<span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span><span style="color: #008;">4</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># … weil es eine Abkürzung ist oder weil die Möglichkeit</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># besteht, am eigenen Körper entlangzugleiten und so Hohlräume</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># zu vermeiden …</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #000;">&lt;</span> Zielwert <span style="color: #ff7700;">or</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">               <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span> <span style="color: #000;">==</span> Zielwert <span style="color: #ff7700;">and</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">               <span style="color: #008;">9999</span> <span style="color: #000;">&gt;</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x-<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y-<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: black;">&#93;</span> <span style="color: #000;">&gt;=</span> snSS:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># … dann wenden wir uns dem zu.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                Zielwert <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y<span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> x-<span style="color: #808;">self</span>.<span style="color: black;">x</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> y-<span style="color: #808;">self</span>.<span style="color: black;">y</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># War das Nachbarfeld ein attraktiveres Schlangensegment?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">if</span> <span style="color: #008;">9999</span> <span style="color: #000;">&gt;</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x-<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y-<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: black;">&#93;</span> <span style="color: #000;">&gt;</span> snSS:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                    snSS <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">A</span><span style="color: black;">&#91;</span>x-<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>y-<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Bewege<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Alle paar Millisekunden bewegt sich die Schlange ein Feld weiter&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wurden zwischendurch eine oder mehrere Cursortasten gedrückt?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Hole den ältesten Tastendruck ab,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># setze dx und dy entsprechend.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Richtung</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span>.<span style="color: black;">pop</span><span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">benutzeAutopilot</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Lasse dx, dy automatisch setzen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Autopilot</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Neue Kopfposition: Nächstes Feld in Bewegungsrichtung</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">x</span> +<span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">dx</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">y</span> +<span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ist da der Hamster?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span> <span style="color: #000;">==</span> Hamster.<span style="color: black;">xy</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Punktzahl erhöhen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Ja, der Hamster bekommt die Punkte!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wer sagt, das Leben sei fair?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Zahl der Hamster (-umsetzungen …)</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">z</span>ähler +<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die zu addierende Punktzahl erhöht sich pro Hamster um 100.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">punkte</span> +<span style="color: #000;">=</span> <span style="color: #008;">100</span> * Hamster.<span style="color: black;">z</span>ähler</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Ein Hamster verlängert die Schlange um 5 Felder.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span> <span style="color: #000;">=</span> <span style="color: #008;">5</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die Schlange wird 5% schneller.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">ms</span> <span style="color: #000;">=</span> <span style="color: #808;">int</span><span style="color: black;">&#40;</span><span style="color: #008;">0.95</span>*<span style="color: #808;">self</span>.<span style="color: black;">ms</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die nächste Mahlzeit materialisiert sich irgendwo.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">umsetzen</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Spielfeldende erreicht?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">x</span> <span style="color: #000;">&lt;</span> <span style="color: #008;">1</span> <span style="color: #ff7700;">or</span> <span style="color: #808;">self</span>.<span style="color: black;">x</span> <span style="color: #000;">&gt;</span> <span style="color: #008;">29</span> <span style="color: #ff7700;">or</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span> <span style="color: #000;">&lt;</span> <span style="color: #008;">1</span> <span style="color: #ff7700;">or</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span> <span style="color: #000;">&gt;</span> <span style="color: #008;">29</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Farbveränderung</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Stirb</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;black&quot;</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;grey&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Auswertungsdialog</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Highscore<span style="color: black;">&#40;</span><span style="color: #080;">&quot;Der Python ist vor die Wand geprallt.&quot;</span><span style="color: #000;">,</span> Hamster.<span style="color: black;">punkte</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># DER Python! Meine Güte, schau' in den Duden!</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Schlange und Hamster zurücksetzen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">return</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ist noch etwas vom letzten Hamster übrig?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># bisschen verdauen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span> -<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die Schlange wächst nun. Weil gleich das letzte</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Feld abgeschnitten wird, hängen wir ein Dummy-Feld an.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Felder</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span>-<span style="color: #008;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Am Kopf ein neues Feld anfügen, Schwanzfeld entfernen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Polygon wird als Trapez gezeichnet, dessen kurze Seite</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># in Bewegungsrichtung &quot;schaut&quot;.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Felder</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> + <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span>:-<span style="color: #008;">1</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">zeichneKopf</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Schlange gleitet weiter. Die Schleife ist nötig, weil</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># der gelbe Schlangenkörper und der blaue Rand zwei eigene</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Canvas-Objekte mit denselben Koordinaten sind.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> K <span style="color: #ff7700;">in</span> <span style="color: #808;">self</span>.<span style="color: black;">K</span>örper:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span>K<span style="color: #000;">,</span> <span style="color: black;">&#91;</span>xy*<span style="color: #008;">24</span> <span style="color: #ff7700;">for</span> Feld <span style="color: #ff7700;">in</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span> <span style="color: #ff7700;">for</span> xy <span style="color: #ff7700;">in</span> Feld<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Was da gerade zwischen den eckigen Klammern geschah:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Das Tupel &quot;Feld&quot; nahm nacheinander alle Werte der Tupel in</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># &quot;self.Felder&quot; an und jedesmal wurde die Variable &quot;xy&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># nacheinander auf den x- und den y-Wert dieses Tupels gesetzt,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># mit 24 multipliziert und an eine Liste angehängt. Mit dieser</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Liste von Koordinaten [x0, y0, x1, y1, … xn, yn] wurden dann</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># die beiden dicken Linien des Schlangenkörpers modifiziert.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der gelbe Make-Up-Punkt für die Schwanzspitze:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        x<span style="color: #000;">,</span> y <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span>-<span style="color: #008;">1</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Schwanzspitze</span><span style="color: #000;">,</span> x*<span style="color: #008;">24</span>-<span style="color: #008;">7</span><span style="color: #000;">,</span> y*<span style="color: #008;">24</span>-<span style="color: #008;">7</span><span style="color: #000;">,</span> x*<span style="color: #008;">24</span>+<span style="color: #008;">7</span><span style="color: #000;">,</span> y*<span style="color: #008;">24</span>+<span style="color: #008;">7</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ist gerade etwas furchtbar dummes passiert?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;">in</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">1</span>:<span style="color: black;">&#93;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wenn an der neuen Kopfposition schon ein Schlangensegment ist,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># dann ist die Runde ist zu Ende, weil die Schlange sich selbst</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># gebissen hat.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Farbveränderung</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Stirb</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;red&quot;</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;darkred&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Auswertungsdialog</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Highscore<span style="color: black;">&#40;</span><span style="color: #080;">&quot;Der Python hat sich selbst gebissen.&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                      Hamster.<span style="color: black;">punkte</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Schlange und Hamster zurücksetzen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">return</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Punkteabzug wegen Trödelns:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> Hamster.<span style="color: black;">punkte</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">punkte</span> -<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Anzeige der Punktzahl aktualisieren</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span>C.<span style="color: black;">z</span>ähler<span style="color: #000;">,</span> text<span style="color: #000;">=</span><span style="color: #080;">&quot;%05i&quot;</span> % Hamster.<span style="color: black;">punkte</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># I'll be back</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">Turbo</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">update_idletasks</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">after</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">ms</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">Bewege</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">after_idle</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Bewege</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Programmfenster</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T <span style="color: #000;">=</span> Tk<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Python-Hamster: Steuerung mit Pfeiltasten&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Leinwand</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C <span style="color: #000;">=</span> Canvas<span style="color: black;">&#40;</span>width<span style="color: #000;">=</span><span style="color: #008;">720</span><span style="color: #000;">,</span> height<span style="color: #000;">=</span><span style="color: #008;">720</span><span style="color: #000;">,</span> bg<span style="color: #000;">=</span><span style="color: #080;">&quot;#e0ffe0&quot;</span><span style="color: #000;">,</span> highlightthickness<span style="color: #000;">=</span><span style="color: #008;">0</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Spielfeldrand</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C.<span style="color: black;">create_rectangle</span><span style="color: black;">&#40;</span><span style="color: #008;">6</span><span style="color: #000;">,</span> <span style="color: #008;">6</span><span style="color: #000;">,</span> <span style="color: #008;">714</span><span style="color: #000;">,</span> <span style="color: #008;">714</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">12</span><span style="color: #000;">,</span> outline<span style="color: #000;">=</span><span style="color: #080;">&quot;#703030&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Fugen im Spielfeldrand</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">for</span> a <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">61</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">for</span> b<span style="color: #000;">,</span> c <span style="color: #ff7700;">in</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>-<span style="color: #008;">1</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;#501000&quot;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span> <span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;#905030&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span>b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">719</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>c<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: #000;">,</span> b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">719</span><span style="color: #000;">,</span> b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>c<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Bodenkacheln</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">for</span> x <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">29</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">for</span> y <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">29</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der Rot- und Blauanteil der Kachelfarbe ist veränderlich,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># jedoch pro Kachel gleich.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der Grünanteil hat immer den Wert 255.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        rb <span style="color: #000;">=</span> <span style="color: #080;">&quot;%02x&quot;</span> % randint<span style="color: black;">&#40;</span><span style="color: #008;">210</span><span style="color: #000;">,</span> <span style="color: #008;">230</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        farbe <span style="color: #000;">=</span> <span style="color: #080;">&quot;#&quot;</span>+rb+<span style="color: #080;">&quot;ff&quot;</span>+rb</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">create_rectangle</span><span style="color: black;">&#40;</span><span style="color: #008;">24</span>*x+<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">12</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                           <span style="color: #008;">24</span>*x+<span style="color: #008;">35</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">35</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                           fill<span style="color: #000;">=</span>farbe<span style="color: #000;">,</span> outline<span style="color: #000;">=</span>farbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Punktezähler</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C.<span style="color: black;">z</span>ähler <span style="color: #000;">=</span> C.<span style="color: black;">create_text</span><span style="color: black;">&#40;</span><span style="color: #008;">360</span><span style="color: #000;">,</span> <span style="color: #008;">360</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         text<span style="color: #000;">=</span><span style="color: #080;">&quot;00000&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         font<span style="color: #000;">=</span><span style="color: #080;">&quot;courier 96 bold&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         fill<span style="color: #000;">=</span><span style="color: #080;">&quot;#d0efd0&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Der Hamster ist ein Objekt der Klasse C_Hamster</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">Hamster <span style="color: #000;">=</span> C_Hamster<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Die Schlange ist ein Objekt der Klasse C_Schlange</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">Schlange <span style="color: #000;">=</span> C_Schlange<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Return&gt;&quot;</span><span style="color: #000;">,</span> countdown<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Pfeiltasten an zugehörige Funktionen binden</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Left&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;l&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>         <span style="color: #800; font-style: italic;"># ←</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Right&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;r&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>        <span style="color: #800; font-style: italic;"># →</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Up&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;o&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>           <span style="color: #800; font-style: italic;"># ↑ </span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Down&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;u&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>         <span style="color: #800; font-style: italic;"># ↓</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Home&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">starteAutopilot</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>  <span style="color: #800; font-style: italic;"># Pos1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;End&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">starteTurbo</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>       <span style="color: #800; font-style: italic;"># Ende</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Los geht’s</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">countdown<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">mainloop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li></ol></pre>]]></content:encoded>
<link>https://bauforum.wirklichewelt.de/index.php?id=11513</link>
<guid>https://bauforum.wirklichewelt.de/index.php?id=11513</guid>
<pubDate>Mon, 03 Jul 2017 21:28:39 +0000</pubDate>
<category>Software</category><dc:creator>Martin Vogel</dc:creator>
</item>
<item>
<title>Python-3-Spieletester gesucht :-)</title>
<content:encoded><![CDATA[<p>Für einen kleinen Softwaretest, bei dem ich die Kommunikation eines lokalen Pythonprogramms mit einem serverbasierten Programm testen möchte, brauche ich mal eben ein paar Freiwillige. </p>
<p>Damit der Test nicht allzu langweilig abläuft, ist er mit einem kleinen Spiel verbunden, das mit einer Online-Highscoreliste gekoppelt ist. Wer es schafft, eine ansehnliche Punktzahl zu erreichen, ist herzlich eingeladen, seinen Spielernamen in die <a href="http://ruhrhochschule.de/hamsterscore.py" target="_blank">Highscoreliste</a> einzutragen.</p>
<p>Das Programm benötigt eine existierende Python-3-Installation unter Windows, Linux oder Mac OS.</p>
<p><img src="https://bauforum.wirklichewelt.de/images/uploaded/Bild_6CF9INJO1.png" alt="[image]"  /></p>
<p>Zum Spielen einfach die ZIP-Datei herunterladen, auspacken und das Pythonprogramm ausführen.<br />
Gestartet wird es mit der Eingabetaste, gesteuert mit den Pfeiltasten.</p>
<p>[<strong>Update: Neue Version</strong>]</p>
<p>Jetzt mit noch besserer Grafik, viel mehr erreichbaren Punkten und einer Belohnung für schnelle Auffassungsgabe!</p>
<p>Jeder Hamster lässt die Schlange um 5 Segmente wachsen und 5% schneller werden. Für den ersten Hamster gibt es 100 Punkte, für den zweiten 200 und so weiter. Für jeden Bewegungsschritt wird jedoch wieder ein Punkt abgezogen. Umwege lohnen sich hier also nicht.</p>
<p>Das Spiel endet, wenn die Schlange gegen die Wand stößt oder mit sich selbst kollidiert.</p>
<p>Download: <a href="images/uploaded/ZIP-Archiv_48FZMD6Q1.zip" target="_blank"><img src="img/zip.png" alt="[image]"  />ZIP-Archiv_48FZMD6Q1.zip</a></p>
<pre class="python" style="font-family:monospace;"><ol><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#! /usr/bin/python3</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> tkinter <span style="color: #ff7700;">import</span> Tk<span style="color: #000;">,</span> Canvas<span style="color: #000;">,</span> PhotoImage</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> tkinter.<span style="color: black;">messagebox</span> <span style="color: #ff7700;">import</span> askyesno <span style="color: #ff7700;">as</span> frage</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> tkinter.<span style="color: black;">simpledialog</span> <span style="color: #ff7700;">import</span> askstring <span style="color: #ff7700;">as</span> eingabe</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">random</span> <span style="color: #ff7700;">import</span> randint<span style="color: #000;">,</span> choice</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">getpass</span> <span style="color: #ff7700;">import</span> getuser</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">webbrowser</span> <span style="color: #ff7700;">import</span> <span style="color: #808;">open</span> <span style="color: #ff7700;">as</span> showpage</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">urllib</span>.<span style="color: black;">parse</span> <span style="color: #ff7700;">import</span> urlencode</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;">import</span> sleep</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Python vs. Hamster</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Ein Beispielprogramm zur Auswertung der Daten von Eventhandlern für</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Tastendrücke und zur simplen Datenübermittlung an eine Webseite</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Version vom 16. Januar 2017</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Autor: Dipl.-Ing. Martin Vogel, Hochschule Bochum</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Lizenz: cc-by-3.0 https://creativecommons.org/licenses/by/3.0/de/</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Diese Abwandlung des klassischen Snake-Spiels lässt eine Schlange</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># kleine blaue Java-Hamster fressen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Das Spielfeld ist 29×29 Felder groß und wird auf einer Canvas in 24-facher</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Größe wiedergegeben.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Die Schlange wird mit den Cursortasten gesteuert.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Jeder Hamster lässt die Schlange um 5 Segmente wachsen und 5% schneller</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># werden. Für den ersten Hamster gibt es 100 Punkte, für den zweiten 200</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># und so weiter. Für jeden Bewegungsschritt wird wieder ein Punkt abgezogen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Das Spiel endet, wenn die Schlange gegen die Wand stößt oder mit sich</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># selbst kollidiert.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Auf einer Webseite lässt sich durch das Programm ein Highscorewert eintragen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">url <span style="color: #000;">=</span> <span style="color: #080;">&quot;http://ruhrhochschule.de/hamsterscore.py&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Vorlage für den Hamsterkopf war das bekannte Motiv von Daniel Jasper und</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Dietrich Boles aus ihrem freien Programmierlernprogramm Hamster-Simulator.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">class</span> countdown:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Zählt von 3 bis 1 rückwärts.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Jede anfangs riesige bildfüllende Ziffer wird innerhalb einer Sekunde</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># immer kleiner.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">counter</span> <span style="color: #000;">=</span> <span style="color: #008;">3</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ziffer rot und mittig anzeigen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">text</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_text</span><span style="color: black;">&#40;</span><span style="color: #008;">360</span><span style="color: #000;">,</span> <span style="color: #008;">360</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;red&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">count</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">config</span><span style="color: black;">&#40;</span>cursor<span style="color: #000;">=</span><span style="color: #080;">&quot;none&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> count<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der counter zählt Sekundenbruchteile, angezeigt werden nur</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># die ganzen Sekunden.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        n <span style="color: #000;">=</span> <span style="color: #808;">int</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">counter</span><span style="color: black;">&#41;</span> + <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zifferngröße in Pixeln entspricht dem Nachkommawert mal 1000</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        s <span style="color: #000;">=</span> <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">counter</span>*<span style="color: #008;">1000</span><span style="color: black;">&#41;</span> % <span style="color: #008;">1000</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Neue Größe setzen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">text</span><span style="color: #000;">,</span> text<span style="color: #000;">=</span>n<span style="color: #000;">,</span> font<span style="color: #000;">=</span><span style="color: #080;">&quot;helvetica -%i bold&quot;</span> % s<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Alle 17 ms soll ein Animationsschritt erfolgen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">counter</span> -<span style="color: #000;">=</span> <span style="color: #008;">0.017</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">counter</span> <span style="color: #000;">&gt;</span> <span style="color: #008;">0</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">after</span><span style="color: black;">&#40;</span><span style="color: #008;">17</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">count</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">delete</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">text</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Schlange.<span style="color: black;">Start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">def</span> newcountdown<span style="color: black;">&#40;</span>event<span style="color: #000;">=</span><span style="color: #808;">None</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Erzeugt ein neues countdown-Objekt der Canvas</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    C.<span style="color: black;">delete</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    Hamster.<span style="color: black;">verstecken</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    C.<span style="color: black;">countdown</span> <span style="color: #000;">=</span> countdown<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">def</span> username<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;Gibt den Spielernamen zurück&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Wurde der schon eingegeben?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">if</span> <span style="color: #808;">hasattr</span><span style="color: black;">&#40;</span>Hamster<span style="color: #000;">,</span> <span style="color: #080;">&quot;username&quot;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> Hamster.<span style="color: black;">username</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Fragen wir mal das Betriebssystem nach dem</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Anmeldenamen.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> getuser<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der kann übernommen oder geändert werden.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> eingabe<span style="color: black;">&#40;</span><span style="color: #080;">&quot;Hallo, äh … &quot;</span>+un+<span style="color: #080;">&quot;?&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                     <span style="color: #080;">&quot;Gib Deinen Namen ein:&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                     initialvalue<span style="color: #000;">=</span>un<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Eingabe mit &quot;OK&quot; bestätigt?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> un:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">username</span> <span style="color: #000;">=</span> un</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Oder Eingabedialog abgebrochen?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            un <span style="color: #000;">=</span> <span style="color: #080;">&quot;&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">return</span> un</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">class</span> C_Hamster:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;Der Hamster weiß, wo er ist, wie er aussieht und alles über den Spieler.&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Hamsterbild muss im Verzeichnis des Pythonprogramms liegen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">try</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">bilddatei</span> <span style="color: #000;">=</span> PhotoImage<span style="color: black;">&#40;</span><span style="color: #808;">file</span><span style="color: #000;">=</span><span style="color: #080;">&quot;Hamster24.gif&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">bild_ID</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_image</span><span style="color: black;">&#40;</span>-<span style="color: #008;">24</span><span style="color: #000;">,</span> -<span style="color: #008;">24</span><span style="color: #000;">,</span> image<span style="color: #000;">=</span><span style="color: #808;">self</span>.<span style="color: black;">bilddatei</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">except</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Falls nicht, gibt's 'nen schnöden Ersatzhamster: ⬤ u2b24</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">bild_ID</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_text</span><span style="color: black;">&#40;</span>-<span style="color: #008;">24</span><span style="color: #000;">,</span> -<span style="color: #008;">24</span><span style="color: #000;">,</span> text<span style="color: #000;">=</span><span style="color: #080;">&quot;⬤&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                         font<span style="color: #000;">=</span><span style="color: #080;">&quot;courier -24 bold&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                         fill<span style="color: #000;">=</span><span style="color: #080;">&quot;blue&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># persönliche Bestleistung</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">highscore</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> reset<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Anzahl der Wiederbelebungen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">z</span>ähler <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Aktuell erreichte Punktzahl</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">punkte</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Philosophischer Einschub:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wieso bekommt eigentlich der Hamster die Punkte und nicht die</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schlange?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wer glaubt, dass es in diesem Spiel darum geht, Hamster zu</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># besiegen, hat die Fabel vom Hasen und Igel nicht verstanden.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># In Wirklichkeit gewinnt nämlich immer der Hamster und die</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schlange stirbt.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schockierend. Ich weiß.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Mooment! Wieso gibt es dann umso mehr Punkte für den Hamster, je</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># häufiger die Schlange gefüttert wird?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># OK, das war vorhin doch nicht die ganze Wahrheit über das Spiel,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># in wirklicher Wirklichkeit gibt es die Punkte für die heimliche</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># illegale Entsorgung der ganzen veganen Biodinkelriegel, die der</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Hamster versehentlich gehortet hat.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Jetzt aber weiter im Quelltext:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> umsetzen<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;&quot;&quot;Setzt den Hamster auf ein zufälliges Feld, das noch nicht von</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #080;">        der Schlange belegt ist.&quot;&quot;&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">while</span> <span style="color: #808;">True</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Irgendwelche Koordinaten 3 Felder vom Rand entfernt auswürfeln</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">xy</span> <span style="color: #000;">=</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">3</span><span style="color: #000;">,</span> <span style="color: #008;">27</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">3</span><span style="color: #000;">,</span> <span style="color: #008;">27</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die Felder rings um den Schlangenkopf sind tabu:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            umKopf <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>Schlange.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span>+x<span style="color: #000;">,</span> Schlange.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span>+y<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                      <span style="color: #ff7700;">for</span> x <span style="color: #ff7700;">in</span> <span style="color: black;">&#91;</span>-<span style="color: #008;">1</span><span style="color: #000;">,</span><span style="color: #008;">0</span><span style="color: #000;">,</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;">for</span> y <span style="color: #ff7700;">in</span> <span style="color: black;">&#91;</span>-<span style="color: #008;">1</span><span style="color: #000;">,</span><span style="color: #008;">0</span><span style="color: #000;">,</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Ist das außerhalb der Schlange?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">xy</span> <span style="color: #ff7700;">not</span> <span style="color: #ff7700;">in</span> umKopf+Schlange.<span style="color: black;">Felder</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># Freies Feld gefunden, Endlosschleife abbrechen!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">break</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Bild auf die neue Canvas-Position verschieben</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        x<span style="color: #000;">,</span> y <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">xy</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span>Hamster.<span style="color: black;">bild_ID</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*x<span style="color: #000;">,</span> <span style="color: #008;">24</span>*y<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Füttere den Python mit dem %i. Java-Hamster!&quot;</span> %</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">z</span>ähler+<span style="color: #008;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> verstecken<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Hamster auf eine nicht sichtbare Koordinate&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span>Hamster.<span style="color: black;">bild_ID</span><span style="color: #000;">,</span> -<span style="color: #008;">100</span><span style="color: #000;">,</span> -<span style="color: #008;">100</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">def</span> Highscore<span style="color: black;">&#40;</span>Grund<span style="color: #000;">,</span> Punkte<span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;Zeigt den Highscore-Dialog an&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Kennen wir uns?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">try</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> <span style="color: #080;">&quot;, &quot;</span>+Hamster.<span style="color: black;">username</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># nö.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">except</span> <span style="color: #808;">AttributeError</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        un <span style="color: #000;">=</span> <span style="color: #080;">&quot;&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Wie laut müssen wir jubeln?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">if</span> Punkte <span style="color: #000;">&gt;</span> Hamster.<span style="color: black;">highscore</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Konfetti, Sekt, Fanfaren!</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Jubel <span style="color: #000;">=</span> <span style="color: #080;">&quot;Bravo&quot;</span>+un+<span style="color: #080;">&quot;, das ist eine neue persönliche &quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #080;">&quot;Bestleistung!nn&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das wird der neue Highscore</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Hamster.<span style="color: black;">highscore</span> <span style="color: #000;">=</span> Punkte</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">elif</span> Punkte:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schlechter geworden?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Jubel <span style="color: #000;">=</span> <span style="color: #080;">&quot;Beim nächsten Mal schaffst Du wieder mehr&quot;</span>+un+<span style="color: #080;">&quot;!nn&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># 0 Punkte?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Jubel <span style="color: #000;">=</span> <span style="color: #080;">&quot;Tipp: Steuere den Python mit den Pfeiltasten!nn&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Mauszeiger wieder anzeigen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    C.<span style="color: black;">config</span><span style="color: black;">&#40;</span>cursor<span style="color: #000;">=</span><span style="color: #080;">&quot;arrow&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #800; font-style: italic;"># Dialog anzeigen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">if</span> frage<span style="color: black;">&#40;</span>Grund<span style="color: #000;">,</span> <span style="color: #080;">&quot;Du hast %i Hamsterpunkte!nn&quot;</span> % Punkte + Jubel +</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">             <span style="color: #080;">&quot;Möchtest Du Dich in die Highscoreliste eintragen?&quot;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        showpage<span style="color: black;">&#40;</span>url+<span style="color: #080;">&quot;?&quot;</span>+urlencode<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;n&quot;</span><span style="color: #000;">,</span> username<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span> <span style="color: black;">&#40;</span><span style="color: #080;">&quot;p&quot;</span><span style="color: #000;">,</span> Punkte<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Neustart mit der Eingabetaste!&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Mache Dich bereit!&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        newcountdown<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">class</span> C_Schlange:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #080;">&quot;&quot;&quot;Die Schlange merkt sich die durch sie belegten Felder und deren</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #080;">    Canvas-Objekte sowie die letzte Hamstermahlzeit.&quot;&quot;&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> reset<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Startwerte der Schlange&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zufällige Startpostition 10 Felder vom Rand entfernt</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">x</span> <span style="color: #000;">=</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">10</span><span style="color: #000;">,</span> <span style="color: #008;">20</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">y</span> <span style="color: #000;">=</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">10</span><span style="color: #000;">,</span> <span style="color: #008;">20</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zufällige Richtung: nach rechts, links, oben oder unten</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Richtung</span><span style="color: black;">&#40;</span>choice<span style="color: black;">&#40;</span><span style="color: #080;">&quot;rlou&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Elemente der Liste &quot;Felder&quot; bestehen aus Tupeln</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># (x-Position, y-Position).</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der Kopf der Schlange ist auf (self.x, self.y)</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Felder</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Vier Rumpfsegmente entgegen der Bewegungsrichtung anhängen:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">1</span><span style="color: #000;">,</span> <span style="color: #008;">5</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Felder</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span>-i*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span>-i*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Wartezeit zwischen zwei Schritten: anfangs 100 Millisekunden,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># später wird die Schlange immer schneller.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">ms</span> <span style="color: #000;">=</span> <span style="color: #008;">100</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Schlange braucht 5 Schritte, um eine Mahlzeit zu verdauen und</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># dabei zu wachsen. Jetzt ist der Magen gerade leer.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Falls pro Bewegungsschritt mehrere Tasten gedrückt werden,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># kommen die in einen Puffer, sodass pro Schritt nur eine</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Richtungsänderung vorgenommen wird.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Richtung<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> rlou<span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Delta-x- bzw. -y-Wert für die nächsten Bewegungsschritte&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Unmittelbar tödliche 180°-Kehren werden nicht zugelassen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;l&quot;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dx</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> -<span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">elif</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;r&quot;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dx</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">dx</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;u&quot;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">elif</span> rlou <span style="color: #000;">==</span> <span style="color: #080;">&quot;o&quot;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: #ff7700;">not</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> -<span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">else</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">dy</span> <span style="color: #000;">=</span> <span style="color: #008;">0</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Taste<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> key<span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Hängt einen Tastendruck an den Eingabepuffer an.&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> zeichneKopf<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Kopf in richtiger Orientierung auf sein neues Feld.&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        x<span style="color: #000;">,</span> y <span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Trapezförmigen Kopf je nach Bewegungsrichtung drehen:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x+<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x+<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">10</span>-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">10</span>+<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Augenlinie (gestrichelt) von links nach rechts:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span>-<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span>-<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                 <span style="color: #008;">24</span>*x-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span>+<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y-<span style="color: #008;">2</span>*<span style="color: #808;">self</span>.<span style="color: black;">dy</span>+<span style="color: #008;">10</span>*<span style="color: #808;">self</span>.<span style="color: black;">dx</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Start<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> event<span style="color: #000;">=</span><span style="color: #808;">None</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Setzt den Hamster um und baut die Schlange neu auf&quot;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Schlange zeichnen: zuunterst liegt eine dicke blaue Linie.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">K</span>örper <span style="color: #000;">=</span> <span style="color: black;">&#91;</span>C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     fill<span style="color: #000;">=</span><span style="color: #080;">&quot;blue&quot;</span><span style="color: #000;">,</span> smooth<span style="color: #000;">=</span><span style="color: #008;">1</span><span style="color: #000;">,</span> tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     joinstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span> capstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     width<span style="color: #000;">=</span><span style="color: #008;">24</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span> <span style="color: #808;">None</span><span style="color: black;">&#93;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Der Kopf – und später die Augen – werden hier nur vorbereitet, um die</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Zeichenreihenfolge festzulegen; ihre Koordinaten erhalten die beiden</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Canvas-Objekte erst in der Methode &quot;zeichneKopf&quot;.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Kopf</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_polygon</span><span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">4</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;yellow&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     outline<span style="color: #000;">=</span><span style="color: #080;">&quot;blue&quot;</span><span style="color: #000;">,</span> joinstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;bevel&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die gelbe Füllung des Körpers liegt in der Zeichenreihefolge über dem</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopf, damit die &quot;Nackenlinie&quot; nicht zu sehen ist. Beide Körperlinien</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># werden in einer Liste gespeichert, damit sie mittels einer Schleife</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># modifiziert werden können.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">K</span>örper<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     fill<span style="color: #000;">=</span><span style="color: #080;">&quot;yellow&quot;</span><span style="color: #000;">,</span> smooth<span style="color: #000;">=</span><span style="color: #008;">1</span><span style="color: #000;">,</span> tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     joinstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span> capstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                     width<span style="color: #000;">=</span><span style="color: #008;">16</span><span style="color: #000;">,</span> dash<span style="color: #000;">=</span><span style="color: black;">&#40;</span><span style="color: #008;">6</span><span style="color: #000;">,</span><span style="color: #008;">13</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Augen liegen zuoberst und bestehen aus einer einzigen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># geschickt gestrichelten Linie: &quot;*  *&quot;.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Augen</span> <span style="color: #000;">=</span> C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">8</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span><span style="color: #080;">&quot;black&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                   tag<span style="color: #000;">=</span><span style="color: #080;">&quot;Schlange&quot;</span><span style="color: #000;">,</span> capstyle<span style="color: #000;">=</span><span style="color: #080;">&quot;round&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                                   dash<span style="color: #000;">=</span><span style="color: black;">&#40;</span><span style="color: #008;">5</span><span style="color: #000;">,</span><span style="color: #008;">11</span><span style="color: #000;">,</span><span style="color: #008;">5</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Hamster umsetzen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># (In Wahrheit wird der nämlich gar nicht gefressen, sondern</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#  immer rechtzeitig weggebeamt. Die Schlange erhält stattdessen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;">#  einen veganen Biodinkelriegel.)</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        Hamster.<span style="color: black;">umsetzen</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Go!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">after</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">ms</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">Bewege</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Stirb<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: #000;">,</span> innenFarbe<span style="color: #000;">,</span> außenFarbe<span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Animation zeigt durch Farbveränderung das Ende der Spielrunde an.&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Schlange verändert innerhalb einer Sekunde ihre</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Farbe vom Kopf bis zur Schwanzspitze.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopf heben und Augen weit aufreißen!</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">tag_raise</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">tag_raise</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">20</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Augenfarbe ändern</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>außenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopfinneres umfärben</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>innenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Kopfrand umfärben</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Kopf</span><span style="color: #000;">,</span> outline<span style="color: #000;">=</span>außenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Körperinneres umfärben</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">K</span>örper<span style="color: black;">&#91;</span><span style="color: #008;">1</span><span style="color: black;">&#93;</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>innenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.1</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Augen schließen …</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">K</span>örper<span style="color: black;">&#91;</span><span style="color: #008;">0</span><span style="color: black;">&#93;</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>außenFarbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> i <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">20</span><span style="color: #000;">,</span><span style="color: #008;">1</span><span style="color: #000;">,</span>-<span style="color: #008;">1</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Augen</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span>i<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            sleep<span style="color: black;">&#40;</span><span style="color: #008;">0.02</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">def</span> Bewege<span style="color: black;">&#40;</span><span style="color: #808;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #080;">&quot;Alle paar Millisekunden bewegt sich die Schlange ein Feld weiter&quot;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Taste gedrückt?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Richtung</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">Tastenpuffer</span>.<span style="color: black;">pop</span><span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Neue Kopfposition</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">x</span> +<span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">dx</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">y</span> +<span style="color: #000;">=</span> <span style="color: #808;">self</span>.<span style="color: black;">dy</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ist da der Hamster?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span> <span style="color: #000;">==</span> Hamster.<span style="color: black;">xy</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Punktzahl erhöhen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">z</span>ähler +<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">punkte</span> +<span style="color: #000;">=</span> <span style="color: #008;">100</span> * Hamster.<span style="color: black;">z</span>ähler</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Ein Hamster verlängert die Schlange um 5 Felder</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span> <span style="color: #000;">=</span> <span style="color: #008;">5</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die Schlange wird 5% schneller</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">ms</span> <span style="color: #000;">=</span> <span style="color: #808;">int</span><span style="color: black;">&#40;</span><span style="color: #008;">0.95</span>*<span style="color: #808;">self</span>.<span style="color: black;">ms</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die nächste Mahlzeit materialisiert sich irgendwo</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">umsetzen</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Spielfeldende erreicht?</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">x</span> <span style="color: #000;">&lt;</span> <span style="color: #008;">1</span> <span style="color: #ff7700;">or</span> <span style="color: #808;">self</span>.<span style="color: black;">x</span> <span style="color: #000;">&gt;</span> <span style="color: #008;">29</span> <span style="color: #ff7700;">or</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span> <span style="color: #000;">&lt;</span> <span style="color: #008;">1</span> <span style="color: #ff7700;">or</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span> <span style="color: #000;">&gt;</span> <span style="color: #008;">29</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Farbveränderung</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Stirb</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;black&quot;</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;grey&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Auswertungsdialog</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Highscore<span style="color: black;">&#40;</span><span style="color: #080;">&quot;Der Python ist vor die Wand geprallt.&quot;</span><span style="color: #000;">,</span> Hamster.<span style="color: black;">punkte</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Schlange und Hamster zurücksetzen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">return</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ist gerade etwas furchtbar dummes passiert?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        selbstgebissen <span style="color: #000;">=</span> <span style="color: #808;">False</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> Feld <span style="color: #ff7700;">in</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span>:-<span style="color: #008;">1</span><span style="color: black;">&#93;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Wenn an der neuen Kopfposition schon ein Schlangensegment ist:</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">if</span> <span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span> <span style="color: #000;">==</span> Feld:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                selbstgebissen <span style="color: #000;">=</span> <span style="color: #808;">True</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># Die Runde ist zu Ende, aber wir melden das erst gleich, wenn</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #800; font-style: italic;"># die Schlange sich noch einen Schritt bewegt hat.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                <span style="color: #ff7700;">break</span>        </div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Ist noch etwas vom letzten Hamster übrig?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># bisschen verdauen</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Mageninhalt</span> -<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Die Schlange wächst nun. Weil gleich das letzte</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Feld abgeschnitten wird, hängen wir ein Dummy-Feld an.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Felder</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;dummy&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Am Kopf ein neues Feld anfügen, Schwanzfeld entfernen.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Das Polygon wird als Trapez gezeichnet, dessen kurze Seite</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># in Bewegungsrichtung &quot;schaut&quot;.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">Felder</span> <span style="color: #000;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">x</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">y</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> + <span style="color: #808;">self</span>.<span style="color: black;">Felder</span><span style="color: black;">&#91;</span>:-<span style="color: #008;">1</span><span style="color: black;">&#93;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #808;">self</span>.<span style="color: black;">zeichneKopf</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Die Schlange gleitet weiter. Die Schleife ist nötig, weil</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># der gelbe Schlangenkörper und der blaue Rand zwei eigene</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Canvas-Objekte sind.</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">for</span> K <span style="color: #ff7700;">in</span> <span style="color: #808;">self</span>.<span style="color: black;">K</span>örper:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            C.<span style="color: black;">coords</span><span style="color: black;">&#40;</span>K<span style="color: #000;">,</span> <span style="color: black;">&#91;</span>xy*<span style="color: #008;">24</span> <span style="color: #ff7700;">for</span> Feld <span style="color: #ff7700;">in</span> <span style="color: #808;">self</span>.<span style="color: black;">Felder</span> <span style="color: #ff7700;">for</span> xy <span style="color: #ff7700;">in</span> Feld<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># War vorhin eigentlich was?</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> selbstgebissen:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Farbveränderung</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">Stirb</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;red&quot;</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;darkred&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Auswertungsdialog</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Highscore<span style="color: black;">&#40;</span><span style="color: #080;">&quot;Der Python hat sich selbst gebissen.&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                      Hamster.<span style="color: black;">punkte</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #800; font-style: italic;"># Schlange und Hamster zurücksetzen</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #808;">self</span>.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">reset</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #ff7700;">return</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># Punkteabzug wegen Trödelns:</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #ff7700;">if</span> Hamster.<span style="color: black;">punkte</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            Hamster.<span style="color: black;">punkte</span> -<span style="color: #000;">=</span> <span style="color: #008;">1</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">itemconfig</span><span style="color: black;">&#40;</span>C.<span style="color: black;">z</span>ähler<span style="color: #000;">,</span> text<span style="color: #000;">=</span><span style="color: #080;">&quot;%05i&quot;</span> % Hamster.<span style="color: black;">punkte</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># I'll be back</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">after</span><span style="color: black;">&#40;</span><span style="color: #808;">self</span>.<span style="color: black;">ms</span><span style="color: #000;">,</span> <span style="color: #808;">self</span>.<span style="color: black;">Bewege</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Programmfenster</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T <span style="color: #000;">=</span> Tk<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;Python-Hamster: Steuerung mit Pfeiltasten&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Leinwand</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C <span style="color: #000;">=</span> Canvas<span style="color: black;">&#40;</span>width<span style="color: #000;">=</span><span style="color: #008;">720</span><span style="color: #000;">,</span> height<span style="color: #000;">=</span><span style="color: #008;">720</span><span style="color: #000;">,</span> bg<span style="color: #000;">=</span><span style="color: #080;">&quot;#e0ffe0&quot;</span><span style="color: #000;">,</span> highlightthickness<span style="color: #000;">=</span><span style="color: #008;">0</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Spielfeldrand</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C.<span style="color: black;">create_rectangle</span><span style="color: black;">&#40;</span><span style="color: #008;">6</span><span style="color: #000;">,</span> <span style="color: #008;">6</span><span style="color: #000;">,</span> <span style="color: #008;">714</span><span style="color: #000;">,</span> <span style="color: #008;">714</span><span style="color: #000;">,</span> width<span style="color: #000;">=</span><span style="color: #008;">12</span><span style="color: #000;">,</span> outline<span style="color: #000;">=</span><span style="color: #080;">&quot;#703030&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Fugen im Spielfeldrand</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">for</span> a <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">61</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">for</span> b<span style="color: #000;">,</span> c <span style="color: #ff7700;">in</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>-<span style="color: #008;">1</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;#501000&quot;</span><span style="color: black;">&#41;</span><span style="color: #000;">,</span> <span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: #000;">,</span> <span style="color: #080;">&quot;#905030&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span>b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">0</span><span style="color: #000;">,</span> b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">719</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>c<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">create_line</span><span style="color: black;">&#40;</span><span style="color: #008;">0</span><span style="color: #000;">,</span> b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">719</span><span style="color: #000;">,</span> b+a*<span style="color: #008;">12</span><span style="color: #000;">,</span> fill<span style="color: #000;">=</span>c<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Bodenkacheln</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff7700;">for</span> x <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">29</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #ff7700;">for</span> y <span style="color: #ff7700;">in</span> <span style="color: #808;">range</span><span style="color: black;">&#40;</span><span style="color: #008;">29</span><span style="color: black;">&#41;</span>:</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># rot- und blau-Anteil der Kachelfarbe sind veränderlich,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #800; font-style: italic;"># grün hat immer den Wert 0xff.</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        rb <span style="color: #000;">=</span> randint<span style="color: black;">&#40;</span><span style="color: #008;">210</span><span style="color: #000;">,</span> <span style="color: #008;">230</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        farbe <span style="color: #000;">=</span> <span style="color: #080;">&quot;#%0xff%0x&quot;</span> % <span style="color: black;">&#40;</span>rb<span style="color: #000;">,</span> rb<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        C.<span style="color: black;">create_rectangle</span><span style="color: black;">&#40;</span><span style="color: #008;">24</span>*x+<span style="color: #008;">12</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">12</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                           <span style="color: #008;">24</span>*x+<span style="color: #008;">35</span><span style="color: #000;">,</span> <span style="color: #008;">24</span>*y+<span style="color: #008;">35</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                           fill<span style="color: #000;">=</span>farbe<span style="color: #000;">,</span> outline<span style="color: #000;">=</span>farbe<span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Punktezähler</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">C.<span style="color: black;">z</span>ähler <span style="color: #000;">=</span> C.<span style="color: black;">create_text</span><span style="color: black;">&#40;</span><span style="color: #008;">360</span><span style="color: #000;">,</span> <span style="color: #008;">360</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         text<span style="color: #000;">=</span><span style="color: #080;">&quot;00000&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         font<span style="color: #000;">=</span><span style="color: #080;">&quot;courier 96 bold&quot;</span><span style="color: #000;">,</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">                         fill<span style="color: #000;">=</span><span style="color: #080;">&quot;#d0efd0&quot;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Der Hamster ist ein Objekt der Klasse C_Hamster</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">Hamster <span style="color: #000;">=</span> C_Hamster<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Die Schlange ist ein Objekt der Klasse C_Schlange</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">Schlange <span style="color: #000;">=</span> C_Schlange<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Return&gt;&quot;</span><span style="color: #000;">,</span> newcountdown<span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Pfeiltasten an zugehörige Funktionen binden</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Left&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;l&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Right&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;r&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Up&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;o&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">bind</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;&lt;Down&gt;&quot;</span><span style="color: #000;">,</span> <span style="color: #ff7700;">lambda</span> event: Schlange.<span style="color: black;">Taste</span><span style="color: black;">&#40;</span><span style="color: #080;">&quot;u&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #800; font-style: italic;"># Los geht’s</span></div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">countdown<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="background:#f9f9f9;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="background:#f5f5f5;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">T.<span style="color: black;">mainloop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li></ol></pre>]]></content:encoded>
<link>https://bauforum.wirklichewelt.de/index.php?id=11449</link>
<guid>https://bauforum.wirklichewelt.de/index.php?id=11449</guid>
<pubDate>Tue, 13 Dec 2016 13:50:06 +0000</pubDate>
<category>Software</category><dc:creator>Martin Vogel</dc:creator>
</item>
</channel>
</rss>
