<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Benötige einwenig Hilfe]]></title><description><![CDATA[<p>Hi ich programmier gerad Game of Life und habe ein kleines Problem, ich bin mir nicht sicher ob ich alles so richtig implementiert habe aber die eigentlichen Menthoden sollten richtig sein jedenfalls hänge ich an einem Fehler den ich nicht ganz einordnen kann würd mich über jede hilfe freuen Vielen Dank !</p>
<p>Hier ein paar Bilder / Code von dem Programm</p>
<p><a href="https://imgur.com/a/VehU2" rel="nofollow">https://imgur.com/a/VehU2</a></p>
<pre><code class="language-cpp">#include &quot;abstractgamelogic.h&quot;
#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;

	int const x = 0;
	int const y = 0;

	int const column = 30;
	int const row = 30;

	bool population[column][row][2];

	  void startGeneration() {
		 for(int i = 0; i &lt; column; i++){
			 for(int j = 0; j &lt; row; j++){
				 if((rand() % RAND_MAX) &lt;= (0.6*RAND_MAX))
					 population[i][j][0] = true;
			 }
		}
	}

	class Gamelogic{
	public:
		Gamelogic();
		~Gamelogic();

	 void nextFieldGeneration(){
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				if (isCellAlive(i, j)) {
					population[i][j][1] = true;
				} else if (isCellAlive(i, j) == false) {
					population[i][j][1] = false;
				}
			}

		}
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				population[i][j][0] = population[i][j][1];
			}
		}
	 }

		bool isCellAlive(int unsigned x, int unsigned y){

		int neighboursCells[8][2] = { { -1, -1 }, { -1, 0 }, { -1, 1 },
				{ 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int neighbour = 0;

		for(int i = 0; i &lt; 8; i++) {
			x = row + neighboursCells[i][0];
			y = column + neighboursCells[i][1];
			if (x == -1) {
				x = column - 1;
			} else if (x == column) {
				x = 0;
			}
			if (y == -1) {
				y = row - 1;
			} else if (y == row) {
				y = 0;
			}
			if (population[x][y][0]) {
				neighbour++;
			}
		}

		if ((neighbour == 2 | neighbour == 3)
				&amp;&amp; population[row][column][0] == true) {
			return true;
		} else if ((neighbour == 3)
				&amp;&amp; population[row][column][0] == false) {
			return true;
		} else if ((neighbour &gt; 3) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else if ((neighbour &lt; 2) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else {
			return false;
		}
	}

	};

	/**
	  * Ermittelt die Breite des Feldes in Anzahl Zellen.
	  * @return Breite des Feldes.
	  */
	   unsigned int AbstractGamelogic :: getFieldWidth(){
		return column;
	}
	/**
	  * Ermittelt die Hoehe des Feldes in Anzahl Zellen.
	  * @return Hoehe des Feldes.
	  */
	   unsigned int AbstractGamelogic :: getFieldHeight(){
		return row;
	}

	/**
	  * Stellt fest, ob die Zelle in der aktuellen Generation
	  * an der Position (x, y) noch lebt.
	  * @return &lt;code&gt;true&lt;/code&gt;, wenn die Zelle noch lebt,
	  *         &lt;code&gt;false&lt;/code&gt;, wenn die Zelle tot ist.
	  */
	 bool AbstractGamelogic :: isCellAlive(int unsigned x, int unsigned y){

		int neighboursCells[8][2] = { { -1, -1 }, { -1, 0 }, { -1, 1 },
				{ 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int neighbour = 0;

		for(int i = 0; i &lt; 8; i++) {
			x = row + neighboursCells[i][0];
			y = column + neighboursCells[i][1];
			if (x == -1) {
				x = column - 1;
			} else if (x == column) {
				x = 0;
			}
			if (y == -1) {
				y = row - 1;
			} else if (y == row) {
				y = 0;
			}
			if (population[x][y][0]) {
				neighbour++;
			}
		}

		if ((neighbour == 2 | neighbour == 3)
				&amp;&amp; population[row][column][0] == true) {
			return true;
		} else if ((neighbour == 3)
				&amp;&amp; population[row][column][0] == false) {
			return true;
		} else if ((neighbour &gt; 3) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else if ((neighbour &lt; 2) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else {
			return false;
		}
	}
	/**
	  * Berechnet die neue Generation anhand der Regeln
	  * des Game of Life.
	  */
	void AbstractGamelogic :: nextFieldGeneration(){
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				if (isCellAlive(i, j)) {
					population[i][j][1] = true;
				} else if (isCellAlive(i, j) == false) {
					population[i][j][1] = false;
				}
			}

		}
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				population[i][j][0] = population[i][j][1];
			}
		}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/303747/benötige-einwenig-hilfe</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 06:32:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/303747.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 May 2012 18:40:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 18:40:24 GMT]]></title><description><![CDATA[<p>Hi ich programmier gerad Game of Life und habe ein kleines Problem, ich bin mir nicht sicher ob ich alles so richtig implementiert habe aber die eigentlichen Menthoden sollten richtig sein jedenfalls hänge ich an einem Fehler den ich nicht ganz einordnen kann würd mich über jede hilfe freuen Vielen Dank !</p>
<p>Hier ein paar Bilder / Code von dem Programm</p>
<p><a href="https://imgur.com/a/VehU2" rel="nofollow">https://imgur.com/a/VehU2</a></p>
<pre><code class="language-cpp">#include &quot;abstractgamelogic.h&quot;
#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;

	int const x = 0;
	int const y = 0;

	int const column = 30;
	int const row = 30;

	bool population[column][row][2];

	  void startGeneration() {
		 for(int i = 0; i &lt; column; i++){
			 for(int j = 0; j &lt; row; j++){
				 if((rand() % RAND_MAX) &lt;= (0.6*RAND_MAX))
					 population[i][j][0] = true;
			 }
		}
	}

	class Gamelogic{
	public:
		Gamelogic();
		~Gamelogic();

	 void nextFieldGeneration(){
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				if (isCellAlive(i, j)) {
					population[i][j][1] = true;
				} else if (isCellAlive(i, j) == false) {
					population[i][j][1] = false;
				}
			}

		}
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				population[i][j][0] = population[i][j][1];
			}
		}
	 }

		bool isCellAlive(int unsigned x, int unsigned y){

		int neighboursCells[8][2] = { { -1, -1 }, { -1, 0 }, { -1, 1 },
				{ 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int neighbour = 0;

		for(int i = 0; i &lt; 8; i++) {
			x = row + neighboursCells[i][0];
			y = column + neighboursCells[i][1];
			if (x == -1) {
				x = column - 1;
			} else if (x == column) {
				x = 0;
			}
			if (y == -1) {
				y = row - 1;
			} else if (y == row) {
				y = 0;
			}
			if (population[x][y][0]) {
				neighbour++;
			}
		}

		if ((neighbour == 2 | neighbour == 3)
				&amp;&amp; population[row][column][0] == true) {
			return true;
		} else if ((neighbour == 3)
				&amp;&amp; population[row][column][0] == false) {
			return true;
		} else if ((neighbour &gt; 3) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else if ((neighbour &lt; 2) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else {
			return false;
		}
	}

	};

	/**
	  * Ermittelt die Breite des Feldes in Anzahl Zellen.
	  * @return Breite des Feldes.
	  */
	   unsigned int AbstractGamelogic :: getFieldWidth(){
		return column;
	}
	/**
	  * Ermittelt die Hoehe des Feldes in Anzahl Zellen.
	  * @return Hoehe des Feldes.
	  */
	   unsigned int AbstractGamelogic :: getFieldHeight(){
		return row;
	}

	/**
	  * Stellt fest, ob die Zelle in der aktuellen Generation
	  * an der Position (x, y) noch lebt.
	  * @return &lt;code&gt;true&lt;/code&gt;, wenn die Zelle noch lebt,
	  *         &lt;code&gt;false&lt;/code&gt;, wenn die Zelle tot ist.
	  */
	 bool AbstractGamelogic :: isCellAlive(int unsigned x, int unsigned y){

		int neighboursCells[8][2] = { { -1, -1 }, { -1, 0 }, { -1, 1 },
				{ 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int neighbour = 0;

		for(int i = 0; i &lt; 8; i++) {
			x = row + neighboursCells[i][0];
			y = column + neighboursCells[i][1];
			if (x == -1) {
				x = column - 1;
			} else if (x == column) {
				x = 0;
			}
			if (y == -1) {
				y = row - 1;
			} else if (y == row) {
				y = 0;
			}
			if (population[x][y][0]) {
				neighbour++;
			}
		}

		if ((neighbour == 2 | neighbour == 3)
				&amp;&amp; population[row][column][0] == true) {
			return true;
		} else if ((neighbour == 3)
				&amp;&amp; population[row][column][0] == false) {
			return true;
		} else if ((neighbour &gt; 3) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else if ((neighbour &lt; 2) &amp;&amp; population[row][column][0] == true) {
			return false;
		} else {
			return false;
		}
	}
	/**
	  * Berechnet die neue Generation anhand der Regeln
	  * des Game of Life.
	  */
	void AbstractGamelogic :: nextFieldGeneration(){
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				if (isCellAlive(i, j)) {
					population[i][j][1] = true;
				} else if (isCellAlive(i, j) == false) {
					population[i][j][1] = false;
				}
			}

		}
		for (int i = 0; i &lt; column; i++) {
			for (int j = 0; j &lt; row; j++) {
				population[i][j][0] = population[i][j][1];
			}
		}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2213907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213907</guid><dc:creator><![CDATA[Neuer_]]></dc:creator><pubDate>Mon, 21 May 2012 18:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 18:55:56 GMT]]></title><description><![CDATA[<p>Hilfreich wäre schon eine Fehlerbeschreibung.</p>
<p>Auf die Schnelle: ich bin mir sicher, dass Du beim testen der &quot;lebenden&quot; Nachbarn das logische-Oder &quot;||&quot;, statt dem bitweisen-Oder &quot;|&quot; meinst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2213915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213915</guid><dc:creator><![CDATA[| ||]]></dc:creator><pubDate>Mon, 21 May 2012 18:55:56 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 19:03:12 GMT]]></title><description><![CDATA[<p>Neuer_ schrieb:</p>
<blockquote>
<p>Hi ich programmier gerad Game of Life und habe ein kleines Problem, ich bin mir nicht sicher ob ich alles so richtig implementiert habe aber die eigentlichen Menthoden sollten richtig sein jedenfalls hänge ich an einem Fehler den ich nicht ganz einordnen kann würd mich über jede hilfe freuen Vielen Dank !</p>
</blockquote>
<p>Wenn du allen Ernstes glaubst, dass jemand den kompletten Code durchliest, nachvollzieht und dir eine Fehlerbeschreibung + Lösung liefert, dann liegste falsch. Versuch den Code zu reduzieren und dabei den Fehler zu erhalten (im Sinne von aufrechterhalten). Wenn es fünfzig Zeilen Code sind und du den Fehler nennen kannst, siehts anders aus.</p>
<p>Außerdem ist es in dem Fall egal, ob er den logischen oder den Bitweisen Operator nimmt (trotzdem meinte er den anderen und sollte den in dem Kontext nicht noch weiter benutzen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2213917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213917</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 21 May 2012 19:03:12 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 19:09:37 GMT]]></title><description><![CDATA[<p>Und noch ein Tipp: Ein besserer Titel wäre gut. &quot;Benötige einwenig Hilfe&quot; sagt nichts über das eigentliche Thema aus. Und dass Du Hilfe benötigst, erkennt man bereits daran, dass Du hier fragst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2213921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213921</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Mon, 21 May 2012 19:09:37 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 20:14:16 GMT]]></title><description><![CDATA[<p>Nun die fehler Meldung sieht man auf einen der Bilder und zum Fehler selbst wie gesagt er überfordert meine Kenntnisse und ich weiß nicht wirklich wie ich daran gehen sollte, entschuldigung wenn ich hier etwas zu forsch war aber ich weiß es nun nicht besser als c++ anfänger <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2213949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213949</guid><dc:creator><![CDATA[neuer_]]></dc:creator><pubDate>Mon, 21 May 2012 20:14:16 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 20:18:07 GMT]]></title><description><![CDATA[<p>Der Fehler sagt, dass GameLogic nicht von AbstractGameLogic abgeleitet ist, ist es ja auch nicht. Ich verstehe nicht, wie du sowas geschrieben haben kannst, ohne den Fehler zu verstehen. Man kommt doch nicht auf die Idee, Klassen AbstractGameLogic und GameLogic zu nennen, ohne zu wissen, was die Fehlermeldung beduetet. Da ist was faul <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2213950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213950</guid><dc:creator><![CDATA[Mechanics]]></dc:creator><pubDate>Mon, 21 May 2012 20:18:07 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Mon, 21 May 2012 20:21:10 GMT]]></title><description><![CDATA[<p>Chrm wie könnte ich es denn in richtig gestalten, wie gesagt ich hab nicht wirklich vieeeel Ahnung *hust</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2213952</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2213952</guid><dc:creator><![CDATA[Neuer_]]></dc:creator><pubDate>Mon, 21 May 2012 20:21:10 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Tue, 22 May 2012 06:39:43 GMT]]></title><description><![CDATA[<p>Neuer_ schrieb:</p>
<blockquote>
<p>Chrm wie könnte ich es denn in richtig gestalten</p>
</blockquote>
<p>Indem du Klassen, die du zum Ableiten designt hast, auch ableitest, wurde oben schon gesagt.</p>
<p>Vermutlich wäre der beste Ansatz, dass du die Klassen selbst designst, und nicht von irgendwoher Code zusammenkopierst, den Eindruck hat man zumindest vom Code und deinem Nichtverstehen des Fehlers.</p>
<p>Dass du nicht viel Ahnung hast ist keine Schande - nur solltest du dann klein anfangen mit einem guten Buch und nicht zu viel zu schnell wollen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2214017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2214017</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 22 May 2012 06:39:43 GMT</pubDate></item><item><title><![CDATA[Reply to Benötige einwenig Hilfe on Tue, 22 May 2012 06:43:02 GMT]]></title><description><![CDATA[<p>Neuer_ schrieb:</p>
<blockquote>
<p>Chrm wie könnte ich es denn in richtig gestalten, wie gesagt ich hab nicht wirklich vieeeel Ahnung *hust</p>
</blockquote>
<p>Ein Tipp, den ich mittlerweile in fast jedem Anfängerthread gebe: Kauf dir ein gutes Buch. Sonst wirste nicht viel von dem verstehen, was dir gleich 5 Leute um die Ohren programmieren werden (Ableitung, virtuelle Methoden, blablablla...). Einen guten Buchthread findest du in der <a href="http://www.c-plusplus.net/forum/251551" rel="nofollow">C++-FAQ</a>.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9960">@pumuckl</a>: Da war ich wohl zu langsam. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2214018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2214018</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 22 May 2012 06:43:02 GMT</pubDate></item></channel></rss>