<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Valles Blog</title>
	<atom:link href="http://www.valentinvoigt.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.valentinvoigt.info</link>
	<description>Über das Leben eines Freaks...</description>
	<pubDate>Wed, 26 Nov 2008 22:39:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP-Klasse zum Lesen und Schreiben von INIs</title>
		<link>http://www.valentinvoigt.info/2008/11/php-klasse-zum-lesen-und-schreiben-von-inis/</link>
		<comments>http://www.valentinvoigt.info/2008/11/php-klasse-zum-lesen-und-schreiben-von-inis/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 22:22:12 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=140</guid>
		<description><![CDATA[Hello World. Braucht jemand eine PHP-Klasse zum Lesen und Schreiben von Ini-Dateien? Habe heute mal eine geschrieben, da ich diese wahrscheinlich demnächst mal benötigen werde. Die Datei hat knapp über 300 Zeilen und ist gut Dokumentiert. Ich habe sie mal hochgeladen, vielleicht braucht das jemand.  Read/write PHP Ini-class (3.19 KB)
]]></description>
			<content:encoded><![CDATA[<p>Hello World. Braucht jemand eine PHP-Klasse zum Lesen und Schreiben von Ini-Dateien? Habe heute mal eine geschrieben, da ich diese wahrscheinlich demnächst mal benötigen werde. Die Datei hat knapp über 300 Zeilen und ist gut Dokumentiert. Ich habe sie mal hochgeladen, vielleicht braucht das jemand. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <a href="http://www.valentinvoigt.info/wp-content/plugins/download-monitor/download.php?id=3" title="Version 1.0 downloaded 37 times" >Read/write PHP Ini-class (3.19 KB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/11/php-klasse-zum-lesen-und-schreiben-von-inis/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gentoo, Server und Updates</title>
		<link>http://www.valentinvoigt.info/2008/11/gentoo-server-und-updates/</link>
		<comments>http://www.valentinvoigt.info/2008/11/gentoo-server-und-updates/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 19:42:50 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=135</guid>
		<description><![CDATA[Ich denke jeder kann mich verstehen, dass ich mich lieber gerne selbst davon überzeuge, was das Richtige ist und was nicht. Das gilt natürlich auch für Gentoo auf Servern. Ich zitiere da mal einen kleinen Satz aus dem Chat, der erst vor wenigen Tagen von Marcel geschrieben wurde.
marcel: Bei Gentoo ist nach einem Update erstmal [...]]]></description>
			<content:encoded><![CDATA[<p>Ich denke jeder kann mich verstehen, dass ich mich lieber gerne selbst davon überzeuge, was das Richtige ist und was nicht. Das gilt natürlich auch für Gentoo auf Servern. Ich zitiere da mal einen kleinen Satz aus dem Chat, der erst vor wenigen Tagen von <a href="http://www.marcel-noe.de/">Marcel</a> geschrieben wurde.</p>
<blockquote><p>marcel: Bei Gentoo ist nach einem Update erstmal das halbe System kaputt</p></blockquote>
<p>Gestern Abend habe ich dann das erste Gentoo-Update auf meinem Root-Server gemacht. Jetzt mal ganz davon abgesehen, dass ich wirklich überrascht war, dass das Update auf diesem nichtmal einem Monat altem Server über 3 Stunden gedauert hat, war es doch fast ein Update, wie es im Buche steht. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> Gut, es kann schlimmer kommen, aber immerhin gehen alle meine Python-Scripte nicht mehr. Das kann schon ganzschön ärgerlich sein, denn das waren nicht wenige. Jetzt schlage ich mich gerade mit dem Programm &#8220;python-updater&#8221; rum, welches mir hier wegen irgendwelchen amd64-Keywords ein Ohr kaut.</p>
<p>Tja, was lernen wir wohl daraus? Nächstes mal auf jeden Fall wieder Debian. apt-get update &amp;&amp; apt-get upgrade, 20 Sekunden warten und alle Updates sind gemacht. Wenn ich es mir da recht überlege, sind mir die Vorteile von Gentoo dann doch egal. Ich denke allerdings auch, dass ich es mal probiert haben muss. Auch wenn jeder sagt, dass Gentoo nicht das Richtige sei, ist es doch besser für mich, es mal am eigenen Leib erlebt zu haben. Aus Fehlern lernt man eben doch am besten. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><strong>Update:</strong> So, Problem behoben. Einfach entsprechendes Paket in /etc/portage/package.keywords eintragen. Trifft sich gut, denn jetzt kommt Dr. House auf RTL. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/11/gentoo-server-und-updates/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tag der offenen Tür</title>
		<link>http://www.valentinvoigt.info/2008/11/tag-der-offenen-tur/</link>
		<comments>http://www.valentinvoigt.info/2008/11/tag-der-offenen-tur/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 12:54:52 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Reallife]]></category>

		<category><![CDATA[Schule]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=129</guid>
		<description><![CDATA[Ich komme gerade aus der Schule (Ja richtig, es ist Samstag)&#8230; Heute war Tag der offenen Tür bei uns. Da ist für jeden Schüler jeder Klassenstufe Unterricht. Zwar haben wir nur 4 Stunden und auch nur verkürzte Stunden mit wesentlich längeren Pausen, aber trotzdem beginnt die Schule wie normal um 7:40 Uhr. Grausam sowas; das [...]]]></description>
			<content:encoded><![CDATA[<p>Ich komme gerade aus der Schule (Ja richtig, es ist Samstag)&#8230; Heute war Tag der offenen Tür bei uns. Da ist für jeden Schüler jeder Klassenstufe Unterricht. Zwar haben wir nur 4 Stunden und auch nur verkürzte Stunden mit wesentlich längeren Pausen, aber trotzdem beginnt die Schule wie normal um 7:40 Uhr. Grausam sowas; das hat mir das ganze Wochenende verdorben. Und das Schlimmste ist ja, dass der Ausgleichstag (Der Wochentag an dem wir dann frei haben, weil wir ja heute in der Schule waren) während meines Praktikums sein wird. Das heißt dann natürlich, dass wir trotzdem zum Praktikum gehen müssen. Ehrlich gesagt will ich ja auch keinen Tag des Praktikums versäumen. Aber trotzdem sollten wir wie jede andere Klassenstufe einen Ausgleichstag haben. Sowas ist doch dämlich. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_confused.gif' alt=':-?' class='wp-smiley' /> Da frage ich mich doch, wo das Problem dabei liegt, diesen Ausgleichstag einfach mal zu verschieben. Das kann doch nicht sein, dass die gesamte 9. Klassenstufe um einen Tag verarscht wird - und das schon seit Jahren! Ich habe mich mal als Klassensprecher bei unserem Schulsprecher beschwert. Vielleicht kann er ja ein Wort beim Schulleiter einlegen. Sowas ist doch nicht ok, oder?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/11/tag-der-offenen-tur/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dr. House Spielkarten</title>
		<link>http://www.valentinvoigt.info/2008/11/dr-house-spielkarten/</link>
		<comments>http://www.valentinvoigt.info/2008/11/dr-house-spielkarten/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 21:12:22 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Reallife]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=124</guid>
		<description><![CDATA[Auch wenn ich die Themen, die meine Kunstlehrerin bisher behandelte nicht besonders prickelnd fand, muss ich doch ausnahmsweise mal gestehen, dass unser aktuelles Thema cool ist.  Unsere Aufgabe ist es, Spielkarten zu einem uns beliebigen Thema zu gestalten. Eigentlich sollten wir zu unseren Idolen Spielkarten machen, aber wer hat heutzutage schon Idole, gibt diese [...]]]></description>
			<content:encoded><![CDATA[<p>Auch wenn ich die Themen, die meine Kunstlehrerin bisher behandelte nicht besonders prickelnd fand, muss ich doch ausnahmsweise mal gestehen, dass unser aktuelles Thema cool ist. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Unsere Aufgabe ist es, Spielkarten zu einem uns beliebigen Thema zu gestalten. Eigentlich sollten wir zu unseren Idolen Spielkarten machen, aber wer hat heutzutage schon Idole, gibt diese offen zu und bringt sie auf eine Spielkarte? Letztlich ist es ja egal, ich habe auf jeden Fall Dr. House ausgesucht. Ob das jetzt mein Idol ist oder nicht, kann man bestreiten. Es gibt auf jeden Fall einige Dinge, auf die ich bei ihm nicht neidisch bin. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Ok, jetzt mal zu dem, was ich eigentlich sagen wollte. Habe heute den ganzen Abend daran gesessen, mal einen Prototyp an Karten zu entwerfen. Ist noch nicht so toll, wie ich das vielleicht erwartet habe, aber auf jeden Fall mal ein Anfang. Wir haben für den Buben ein Bild von Foremen, für die Dame ein Bild von Cameron, für den König natürlich House und für das Ass Cuddy genommen. Die habe ich aus einigen Bildern ausgeschnitten, gespiegelt und *zack* - schon sah das aus wie Spielkarten. Da wir nur eine Farbe (Bekannt als Pik, Herz, Karo und Kreuz) machen müssen, haben wir einen Gehstock genommen. Auch eine Rückseite für die Karten ist schon fertig. Da waren wir wohl aber weniger kreativ, da wir einfach aus einer Folge aus dem Intro  ein Bild genommen haben. Was jetzt noch fehlt ist ein Hintergrund auf der Vorderseite. Also der Teil hinter dem Bild von z.B. Dr. House und den Gehstöcken. Eine Idee haben wir aber auch da schon. Wieder ein Teil aus dem Intro. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Tja, mal sehen was die nächsten Tage dabei so rauskommt. Ich werde dann bei Gelegenheit natürlich auch ein paar Fotos vom Fertigen und auch dazugehörige PNGs veröffentlichen. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/11/dr-house-spielkarten/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Collectd und rrdtool</title>
		<link>http://www.valentinvoigt.info/2008/11/collectd-und-rrdtool/</link>
		<comments>http://www.valentinvoigt.info/2008/11/collectd-und-rrdtool/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 20:03:16 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Netzwerk]]></category>

		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=118</guid>
		<description><![CDATA[Endlich habe ich mal ein schönes Programm zum Überwachen der Performance eines Computers gefunden. Das Programm nennt sich collectd. Der Collectd selbst, speichert nur die Daten in regelmäßigen Abständen (Ich glabe es sind 15 Sekunden per default) in mehrere Dateien. Diese Dateien sind im so genannten Round Robin Database-Format. Mit Hilfe des Prorgamms rrdtool kannn [...]]]></description>
			<content:encoded><![CDATA[<p>Endlich habe ich mal ein schönes Programm zum Überwachen der Performance eines Computers gefunden. Das Programm nennt sich <em>collectd</em>. Der Collectd selbst, speichert nur die Daten in regelmäßigen Abständen (Ich glabe es sind 15 Sekunden per default) in mehrere Dateien. Diese Dateien sind im so genannten <em>Round Robin Database</em>-Format. Mit Hilfe des Prorgamms <em>rrdtool</em> kannn man dann relativ einfach eine graphische Darstellung dieser Daten erstellen. Das <a title="collectd and rrdtool graph" href="http://dev.ibitlive.eu/dev/rrd/" target="_blank">rrdtool in Aktion</a> kann man hier sehen. Dazu mal ein kleiner Beispiel-Code, der mir einen Graphen über den Verlauf des Load-Averages der letzten 24 Stunden erstellt.</p>
<div class="geshi no bash">
<div class="head">Graph eines Load-Average der letzten 24h</div>
<ol>
<li class="li1">
<div class="de1">rrdtool graph <span class="st0">&quot;/var/www/user/de/dev/htdocs/dev/rrd/load.png&quot;</span> &#8211;start -24h &#8211;en</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &#8211;title <span class="st0">&quot;load average - last 24h&quot;</span> \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; DEF:<span class="re2">shortterm=</span><span class="sy0">/</span>var<span class="sy0">/</span>lib<span class="sy0">/</span>collectd<span class="sy0">/</span>load.rrd:shortterm:AVERAGE \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; DEF:<span class="re2">midterm=</span><span class="sy0">/</span>var<span class="sy0">/</span>lib<span class="sy0">/</span>collectd<span class="sy0">/</span>load.rrd:midterm:AVERAGE \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; DEF:<span class="re2">longterm=</span><span class="sy0">/</span>var<span class="sy0">/</span>lib<span class="sy0">/</span>collectd<span class="sy0">/</span>load.rrd:longterm:AVERAGE \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; LINE1:shortterm<span class="co0">#00CC00:&quot;last minute&quot; \</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; LINE1:midterm<span class="co0">#FF0000:&quot;last five minutes&quot; \</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; LINE1:longterm<span class="co0">#0000FF:&quot;last fifteen minutes&quot;</span></div>
</li>
</ol>
</div>
<p>Man kann jetzt damit also recht detailiert seine Graphen erstellen lassen. Ich habe mir dazu gleich ein ganzes Shell-Script geschrieben, dem ich einen Parameter mitgebe, der angibt, von welchem Zeitpunkt an bis jetzt der Graph erstellt werden soll. Das Script könnt ihr euch (mit einer PHP-Datei zur Anzeige auf einem Webserver) nach Bedarf gerne einmal runterladen. <a href="http://www.valentinvoigt.info/wp-content/plugins/download-monitor/download.php?id=2" title="Version 1.0 downloaded 20 times" >Collectd And Rrdtool (1.54 KB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/11/collectd-und-rrdtool/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Die perfekte IDE?</title>
		<link>http://www.valentinvoigt.info/2008/11/die-perfekte-ide/</link>
		<comments>http://www.valentinvoigt.info/2008/11/die-perfekte-ide/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 20:46:30 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=115</guid>
		<description><![CDATA[Es war mal wieder Zeit, mir eine gescheite IDE zu suchen. Jetzt, wo meine Projekte größeren Umfang annehmen und ein normaler Editor nicht mehr reicht (zumindest wenn man trotzdem komfortabel arbeiten will). Die Suche war echt lang. Viele IDEs haben viele tolle Features, aber eben auch Bugs oder fehlende Features, auf die ich nicht verzichten [...]]]></description>
			<content:encoded><![CDATA[<p>Es war mal wieder Zeit, mir eine gescheite IDE zu suchen. Jetzt, wo meine Projekte größeren Umfang annehmen und ein normaler Editor nicht mehr reicht (zumindest wenn man trotzdem komfortabel arbeiten will). Die Suche war echt lang. Viele IDEs haben viele tolle Features, aber eben auch Bugs oder fehlende Features, auf die ich nicht verzichten kann. Jetzt habe ich mich aber vorerst mal entschieden.</p>
<p>And the winner is&#8230; Eclipse. Naja, wen wundert&#8217;s. Eclipse gehört wohl zu den größten, besten und bekanntesten IDEs. Alles, was ich mir so vorgestellt habe (Projekt Manager, SVN integration, Outline) ist da drin und wartet nun noch darauf von mir getestet zu werden. Ich habe mich den heutigen Nachmittag zwar schon recht gut eingearbeitet, aber Eclipse ist so groß, dass ich wohl nichtmal 10% aller Funktionen testen konnte. Ich will mal einen kleinen Screenshot zeigen, damit man sich unter Eclipse was vorstellen kann.</p>
<div id="attachment_116" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.valentinvoigt.info/wp-content/solaesstsichsarbeiten.png"><img class="size-medium wp-image-116" title="So lässt sich's arbeiten" src="http://www.valentinvoigt.info/wp-content/solaesstsichsarbeiten-300x224.png" alt="Eclipse IDE" width="300" height="224" /></a><p class="wp-caption-text">Eclipse IDE</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/11/die-perfekte-ide/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[III] The Game Of Life</title>
		<link>http://www.valentinvoigt.info/2008/10/iii-the-game-of-life/</link>
		<comments>http://www.valentinvoigt.info/2008/10/iii-the-game-of-life/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 11:42:37 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=99</guid>
		<description><![CDATA[Irgendwie geht mir das nicht aus dem Kopf. Jetzt war mit Python zu langsam und ich habe mich seit meinem letzten Eintrag mit C++ beschäftigt. Zumindest was die Geschwindigkeit angeht, kann ich mich jetzt überhaupt nicht mehr beschweren.  
Ich habe Borlands / Codegears Turbo C++ verwendet. Die grafische Oberfläche ist demnach auch mit der [...]]]></description>
			<content:encoded><![CDATA[<p>Irgendwie geht mir das nicht aus dem Kopf. Jetzt war mit Python zu langsam und ich habe mich seit meinem letzten Eintrag mit C++ beschäftigt. Zumindest was die Geschwindigkeit angeht, kann ich mich jetzt überhaupt nicht mehr beschweren. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Ich habe Borlands / Codegears Turbo C++ verwendet. Die grafische Oberfläche ist demnach auch mit der VCL gemacht. Irgendwie bereue ich diesen Schritt. Ich muss euch jetzt leider 2 DLLs mitliefern. Das gesamte Paket ist 1,38MB groß. ZIP-gepackt zum Glück nur noch 625kB. Ich werde wohl irgendwann mal eine andere Oberfläche benutzen. Kann doch nicht sein, dass ich für so ein bisschen Code gleich 1,38MB brauche.</p>
<p>Naja, mal zu den Dingen die das Teil momentan kann. Man kann das Spielfeld in Größe und Anzeige bearbeiten. Außerdem (im Gegensatz zur alten Konsolen Version) kann man die Felder des Spielfelds durch einfache Links- und Rechtsklicks bearbeiten. Man hat sogar die Möglichkeit das Spielfeld in eine Datei abzuspeichern und natürlich auch wieder zu laden. Außerdem sind noch ein paar Extras dabei, die einem die Bedienung erleichtern. Den Source-Code werde ich später einmal veröffentlichen.</p>
<p>Ihr könnt euch das Programm ja gerne mal anschauen. Ich denke ich werde daran noch weiter arbeiten, denn irgendwie macht mir das Spaß. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> Besonders das erwähnte Thema mit der Oberfläche will ich noch ändern. Vielleicht hinterlässt der ein oder andere ja mal ein wenig Kritik in Form eines Kommentars hier. Download: <a href="http://www.valentinvoigt.info/wp-content/plugins/download-monitor/download.php?id=1" title="Version 1.0 downloaded 75 times" >The Game Of Life (625.18 KB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/10/iii-the-game-of-life/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[II] The Game Of Life</title>
		<link>http://www.valentinvoigt.info/2008/10/ii-the-game-of-life/</link>
		<comments>http://www.valentinvoigt.info/2008/10/ii-the-game-of-life/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 21:04:30 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=74</guid>
		<description><![CDATA[So, ich habe das Ding jetzt von der Geschwindigkeit etwa verdreifacht. Außerdem noch ein wenig aufgeräumt und den Debug-Code entfernt. Noch ein paar Kommentare und eine Priese Dokumentation dazu und fertig ist&#8217;s. Wer sich mein Game Of Life gerne mal anschauen möchte hat hiermit die Gelegenheit. Downloadlink.  Oder einfach auf &#8220;more&#8221; klicken. 



#!/usr/bin/python


# Valentin Voigt [...]]]></description>
			<content:encoded><![CDATA[<p>So, ich habe das Ding jetzt von der Geschwindigkeit etwa verdreifacht. Außerdem noch ein wenig aufgeräumt und den Debug-Code entfernt. Noch ein paar Kommentare und eine Priese Dokumentation dazu und fertig ist&#8217;s. Wer sich mein Game Of Life gerne mal anschauen möchte hat hiermit die Gelegenheit. <a href="http://www.valentinvoigt.info/wp-content/gameoflife.py">Downloadlink</a>.  Oder einfach auf <em>&#8220;more&#8221;</em> klicken. <span id="more-74"></span></p>
<div class="geshi python">
<ol>
<li class="li1">
<div class="de1"><span class="co1">#!/usr/bin/python</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># Valentin Voigt &lt;ValentinVoigt@gmx.de&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">import</span> <span class="kw3">os</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">import</span> <span class="kw3">sys</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">F_DEAD &nbsp;= <span class="nu0">0</span> <span class="co1"># Dead cell</span></div>
</li>
<li class="li1">
<div class="de1">F_ALIVE = <span class="nu0">1</span> <span class="co1"># Living cell</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">class</span> GameOfLife:</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; field &nbsp; &nbsp; &nbsp;= <span class="br0">&#91;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; renderer &nbsp; = <span class="kw2">None</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; generation = <span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">def</span> <span class="kw4">__init__</span><span class="br0">&#40;</span><span class="kw2">self</span>, width, height, renderer<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Initializes the GameOfLife object.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;Width describes the number of cells on the x-axis, height describes</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;the number of cells on the y-axis. Renderer must be callable. It takes</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;one argument with the two-dimensional game field.&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">field</span> = <span class="br0">&#91;</span><span class="br0">&#91;</span>F_DEAD <span class="kw1">for</span> i <span class="kw1">in</span> <span class="kw2">range</span><span class="br0">&#40;</span>width<span class="br0">&#41;</span><span class="br0">&#93;</span> <span class="kw1">for</span> i <span class="kw1">in</span> <span class="kw2">range</span><span class="br0">&#40;</span>height<span class="br0">&#41;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">width</span> = width</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">height</span> = height</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">renderer</span> = renderer</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">def</span> alive_neighbours<span class="br0">&#40;</span><span class="kw2">self</span>, x, y<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Returns the number of living cells around the given cell.&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; count = <span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Some time ago I put that annoying &quot;if&quot;s into some functions called</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># &quot;cell_exists&quot; and &quot;if_alive_return_one&quot;. So the following part was</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># very easy with just 8 lines similar to this one:</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># &nbsp; &nbsp; count += if_alive_return_one(x+1, y+1)</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># But because this was to slowly I had to put these &quot;if&quot;s here. Now</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># the code works a bit faster, although it doesn&#39;t look very</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># professional anymore.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y<span class="nu0">-1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y<span class="nu0">-1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x<span class="nu0">-1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x<span class="nu0">-1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="nu0">-1</span><span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="nu0">-1</span><span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y<span class="nu0">-1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y<span class="nu0">-1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="nu0">-1</span><span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y<span class="nu0">-1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y<span class="nu0">-1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x<span class="nu0">+1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x<span class="nu0">+1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="nu0">-1</span><span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="nu0">+1</span><span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x<span class="nu0">-1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x<span class="nu0">-1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="nu0">-1</span><span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x<span class="nu0">+1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x<span class="nu0">+1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="nu0">+1</span><span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y<span class="nu0">+1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y<span class="nu0">+1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x<span class="nu0">-1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x<span class="nu0">-1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="nu0">+1</span><span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="nu0">-1</span><span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y<span class="nu0">+1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y<span class="nu0">+1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="nu0">+1</span><span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> y<span class="nu0">+1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">height</span> <span class="kw1">and</span> y<span class="nu0">+1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span> <span class="kw1">and</span> x<span class="nu0">+1</span> <span class="sy0">&lt;</span> <span class="kw2">self</span>.<span class="me1">width</span> <span class="kw1">and</span> x<span class="nu0">+1</span> <span class="sy0">&gt;</span>= <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="nu0">+1</span><span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="nu0">+1</span><span class="br0">&#93;</span> == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> count</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">def</span> activate<span class="br0">&#40;</span><span class="kw2">self</span>, x, y<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Marks the specified cells as alive&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> = F_ALIVE</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">def</span> activate_list<span class="br0">&#40;</span><span class="kw2">self</span>, cells<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Marks the specified list of cells as alive.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;Takes a list of lists with two elemts. Example:</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;activate_list([ (0,1), (2,3), &nbsp;(9,2) ])&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> cell <span class="kw1">in</span> cells:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">activate</span><span class="br0">&#40;</span>cell<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, cell<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">def</span> tick<span class="br0">&#40;</span><span class="kw2">self</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Calculate the next generation.&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Initialises a new field with only dead cells. They&#39;ll be</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># overwritten in the following lines. Before I used [].append to</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># create the new field. But this was too slowly, too&#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; new_field = <span class="br0">&#91;</span><span class="br0">&#91;</span>F_DEAD <span class="kw1">for</span> i <span class="kw1">in</span> <span class="kw2">range</span><span class="br0">&#40;</span><span class="kw2">self</span>.<span class="me1">width</span><span class="br0">&#41;</span><span class="br0">&#93;</span> <span class="kw1">for</span> j <span class="kw1">in</span> <span class="kw2">range</span><span class="br0">&#40;</span><span class="kw2">self</span>.<span class="me1">height</span><span class="br0">&#41;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; y = <span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> row <span class="kw1">in</span> <span class="kw2">self</span>.<span class="me1">field</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = <span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> cell <span class="kw1">in</span> row:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> cell == F_DEAD:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">self</span>.<span class="me1">alive_neighbours</span><span class="br0">&#40;</span>x, y<span class="br0">&#41;</span> == <span class="nu0">3</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_field<span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> = F_ALIVE</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_field<span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> = F_DEAD</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">elif</span> cell == F_ALIVE:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = <span class="kw2">self</span>.<span class="me1">alive_neighbours</span><span class="br0">&#40;</span>x, y<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> n <span class="sy0">&lt;</span> <span class="nu0">2</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_field<span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> = F_DEAD</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">elif</span> n <span class="sy0">&gt;</span> <span class="nu0">3</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_field<span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> = F_DEAD</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_field<span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span> = F_ALIVE</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">field</span> = new_field</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">generation</span> += <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">def</span> render<span class="br0">&#40;</span><span class="kw2">self</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Calls the render function.&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Reminds me on some of my friends.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># They often make others do their jobs. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">self</span>.<span class="me1">renderer</span><span class="br0">&#40;</span><span class="kw2">self</span>.<span class="me1">field</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">def</span> ConsoleRenderer<span class="br0">&#40;</span>field<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&quot;&quot;</span><span class="st0">&quot;Simplest way I found for drawing the game field.&quot;</span><span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1"># Clear screen</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">os</span>.<span class="me1">name</span> == <span class="st0">&quot;nt&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">os</span>.<span class="me1">system</span><span class="br0">&#40;</span><span class="st0">&quot;cls&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">elif</span> <span class="kw3">os</span>.<span class="me1">name</span> == <span class="st0">&quot;posix&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">os</span>.<span class="me1">system</span><span class="br0">&#40;</span><span class="st0">&quot;clear&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">else</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> i <span class="kw1">in</span> <span class="kw2">range</span><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">100</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">print</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1"># Print field</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">for</span> row <span class="kw1">in</span> field:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> cell <span class="kw1">in</span> row:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">sys</span>.<span class="me1">stdout</span>.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&quot;X&quot;</span> <span class="kw1">if</span> cell == F_ALIVE <span class="kw1">else</span> <span class="st0">&quot; &quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">print</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">print</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">def</span> start_example<span class="br0">&#40;</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; game = GameOfLife<span class="br0">&#40;</span><span class="nu0">79</span>, <span class="nu0">25</span>, ConsoleRenderer<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; game.<span class="me1">activate_list</span><span class="br0">&#40;</span><span class="br0">&#91;</span> <span class="br0">&#40;</span><span class="nu0">50</span>, <span class="nu0">16</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span><span class="nu0">51</span>, <span class="nu0">16</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span><span class="nu0">51</span>, <span class="nu0">17</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span><span class="nu0">51</span>, <span class="nu0">15</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span><span class="nu0">52</span>, <span class="nu0">15</span><span class="br0">&#41;</span> <span class="br0">&#93;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">try</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="kw2">True</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; game.<span class="me1">tick</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; game.<span class="me1">render</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">except</span> <span class="kw2">KeyboardInterrupt</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">pass</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> __name__ == <span class="st0">&quot;__main__&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; start_example<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/10/ii-the-game-of-life/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Game Of Life</title>
		<link>http://www.valentinvoigt.info/2008/10/the-game-of-life/</link>
		<comments>http://www.valentinvoigt.info/2008/10/the-game-of-life/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 19:42:53 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=66</guid>
		<description><![CDATA[Heute bin ich auf das &#8220;Game Of Life&#8221; gestoßen. Auf den ersten Blick langweilig, ist das eigentlich eine total lustige Spielerei. Das Spiel hat ganz einfache Regeln. Es ist aufgebaut wie eine Art Schachfeld. Also ein 2-dimensionales Array. Jedes dieser Felder kann entweder tot oder lebendig sein. Tote und lebendige Felder unterscheidet man ganz einfach [...]]]></description>
			<content:encoded><![CDATA[<p>Heute bin ich auf das <em><a title="Wikipedia - Game of Life" href="http://de.wikipedia.org/wiki/Game_of_Life" target="_blank">&#8220;Game Of Life&#8221;</a></em> gestoßen. Auf den ersten Blick langweilig, ist das eigentlich eine total lustige Spielerei. Das Spiel hat ganz einfache Regeln. Es ist aufgebaut wie eine Art Schachfeld. Also ein 2-dimensionales Array. Jedes dieser Felder kann entweder tot oder lebendig sein. Tote und lebendige Felder unterscheidet man ganz einfach durch ihr aussehen. Nun verändert sich bei jedem Durchgang (Generation genannt) das Spielfeld mit Hilfe von ganz einfachen Regeln. Hat eine tote zelle genau 3 lebende Nachbarn, so wird das tote zu einem lebendem Feld. Hat eine lebende Zelle weniger als 2 lebende Nachbarn, so stirbt sie. Hat eine lebende Zelle genau 2 oder 3 Nachbarn bleibt sie lebendig. Hat eine lebende Zelle mehr als 3 lebende Nachbarn, so stirbt sie.</p>
<p>Nun kann man bei diesem Spiel sehr lustige Figuren beobachten, wenn man einfach mal einige beliebige (möglichst nah beieinander liegende) Zellen belebt. So können dabei Animationen entstehen und so lange weitergehen, bis alle Zellen wieder tot sind. Es kann aber auch passieren, dass das ganze in ein totales Chaos verfällt und selbst mach 1000en von Generationen immer noch alles drunter und drüber geht.</p>
<p>Aus reiner Langeweile und aus Interesse wie leicht sowas denn zu programmieren sei, habe ich mal mein eigenes Game of Life programmiert. Es ist in Python geschrieben und gibt seine Zellen bisher leider nur über die Konsole aus. Dazu ist es momentan auch noch sehr langsam, kann also bei mir nur so ca. 88 Generationen in 5 Sekunden berechnen. Ich werde es die nächsten Tage mal ein wenig optmimieren und dann auch hier mal reinstellen. Jetzt erstmal ein wenig ASCII-Art.</p>
<pre><strong>                    XX                              X              X      XX
                   X  X                            X X            X X   X XX
                    XX                             XX             X X  XXXXX
                                                                   X       X X
                                        XX                                 X  X
                                       X  X                                 XX
                                        XX
                                    XX                X
                    X               X X              X X
                    X               X                 XX                  XXX
                    X                                                    X   X
                                                            XX  XXXXX    X   X
                                                              XXX    X   X   X
                                                                XX XX     XXX
                                                            X     XX
                                                             X   XX
                             XX       XX                      X   X
                             XX       XX</strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/10/the-game-of-life/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Happy Birthday!</title>
		<link>http://www.valentinvoigt.info/2008/10/happy-birthday/</link>
		<comments>http://www.valentinvoigt.info/2008/10/happy-birthday/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 21:33:59 +0000</pubDate>
		<dc:creator>Valle</dc:creator>
		
		<category><![CDATA[Allgemein]]></category>

		<guid isPermaLink="false">http://www.valentinvoigt.info/?p=63</guid>
		<description><![CDATA[Ich habe es jetzt geschafft: mein erstes Projekt hat sich ein Jahr lang gehalten. Ich rede von meinem Freehoster iBitLive, den ich zusammen mit einem Freund &#8220;benefix&#8221; Anfang letzen Jahres geplant hatte. Schnell fanden sich 3 Coder (&#8220;muffin&#8221;, &#8220;massai&#8221; und &#8220;ProggerHouse&#8220;), mit denen wir ruck-zuck das Projekt programmierten. Ja. Und nun hat es sich schon [...]]]></description>
			<content:encoded><![CDATA[<p>Ich habe es jetzt geschafft: mein erstes Projekt hat sich ein Jahr lang gehalten. Ich rede von meinem Freehoster <a title="iBitLive - Community and Freehoster" href="http://www.ibitlive.eu/" target="_blank">iBitLive</a>, den ich zusammen mit einem Freund &#8220;<em>benefix&#8221;</em> Anfang letzen Jahres geplant hatte. Schnell fanden sich 3 Coder (<em>&#8220;muffin&#8221;</em>, <em>&#8220;massai&#8221; </em>und <em>&#8220;ProggerHouse</em>&#8220;), mit denen wir ruck-zuck das Projekt programmierten. Ja. Und nun hat es sich schon ein Jahr lang gehalten. Hoffentlich hält es auch noch die nächsten Jahre. Ich für meinen Teil bin jedenfalls zuversichtlich. <img src='http://www.valentinvoigt.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.valentinvoigt.info/2008/10/happy-birthday/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
