<?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[[Erledigt]Tic-Tac-Toe und der Minimax-Algorithmus]]></title><description><![CDATA[<p>Hi Leute<br />
Ich will mich etwas in das Thema &quot;Künstliche Intelligenz&quot; einarbeiten und nun versuchte ich ein kleines Tic-Tac-Toe Programm zu entwerfen. Das Programm soll zunächst so einfach wie möglich sein, also Konsolenbasierte Ausgabe. Mein Problem besteht darin, dass ich es einfach nicht schaffe meiner &quot;KI&quot; auch nur einen Hauch von &quot;Intelligenz&quot; zu geben. Mein Ansatz war der Minimax-Algorithmus, jedoch gelingt es mir nicht diesen zu realisieren, mein Code:</p>
<pre><code class="language-cpp">class Computer
{
	private:
		int** field;
		int freieFelder;

	public:
		Computer( int** field );
		~Computer() {}

		int makeMoveMax( int** field, std::vector&lt;Coordinates&gt; pmoves );	// Computer
		int makeMoveMin( int** field, std::vector&lt;Coordinates&gt; pmoves ); // Spieler
		int bestMove();
		std::vector&lt;Coordinates&gt; possibleMoves( int ** );
};

Computer::Computer( int** field )
{
	this-&gt;field = field;
	freieFelder = countFreeFields(field);
}
</code></pre>
<p>Die Klasse &quot;Computer&quot; soll also alle Bestandteile des Algorithmus selbstständig durchführen, so, dass im Hauptprogramm lediglich ein Spielfeld erstellt und übergeben werden und eine Funktion geschrieben werden muss, die Computer und Spieler nacheinander ziehen lässt. Nun zum Hauptproblem, dem Algorithmus:</p>
<pre><code class="language-cpp">int Computer::bestMove()
{
	std::vector&lt;Coordinates&gt; coords = possibleMoves( field );	// anzahl der möglichen züge ermitteln
	for( int i=0; i&lt;coords.size(); i++ )	// computer zieht
	{
		int** arrcpy = copyArray( field, 3, 3 );	// derzeitiges Spielfeld kopieren
		arrcpy[coords.front().x][coords.front().y] = 0;

		std::vector&lt;Coordinates&gt; new_coords;
		for( int j=1; j&lt;coords.size(); j++ )	// vector bis auf das erste element kopieren
		{
			new_coords.push_back( coords[j] ); 
		}
		coords = new_coords;
		std::cout &lt;&lt; &quot;makeMoveMin = &quot; &lt;&lt; makeMoveMin( arrcpy, new_coords ) &lt;&lt; std::endl;
		if( makeMoveMin( arrcpy, new_coords ) == 1 )	// wenn möglichkeit gefunden, koordinaten zurückgeben
		{
			field[coords[i].x][coords[i].y] = 0;
			std::cout &lt;&lt; &quot;MOVE: X = &quot; &lt;&lt; coords[i].x &lt;&lt; &quot;, Y = &quot; &lt;&lt; coords[i].y &lt;&lt; std::endl;
			return 1;

		}
		//return coords[i];

	}
	return 0;	
}

int Computer::makeMoveMax( int** field, std::vector&lt;Coordinates&gt; pmoves )
{
	std::vector&lt;Coordinates&gt; coords = possibleMoves( field );
	if( checkWin( field ) == 0 ) return 1;	// wenn computer gewonnen hat
	int** arrcpy = copyArray( field, 3, 3 );
	for( int i=0; i&lt;pmoves.size(); i++ )
	{
		arrcpy[pmoves.front().x][pmoves.front().y] = 0;	// computer zieht
		std::vector&lt;Coordinates&gt; new_pmoves;
		for( int j=1; j&lt;pmoves.size(); j++ )	// vector bis auf das erste element kopieren
		{
			new_pmoves.push_back( pmoves[j] ); 
		}
		pmoves = new_pmoves;
		if( makeMoveMin( arrcpy, new_pmoves ) == 1 )	// wenn ein positives ergebnis erzielt wurde
			return makeMoveMin( arrcpy, new_pmoves );
	}

	return -1;	// wenn keine Lösung gefunden wurde
}

int Computer::makeMoveMin( int** field, std::vector&lt;Coordinates&gt; pmoves )
{
	std::vector&lt;Coordinates&gt; coords = possibleMoves( field );

	if( checkWin( field ) == 1 ) { showField(field); return 0; }	// wenn Spieler gewonnen hat
	int** arrcpy = copyArray( field, 3, 3 );
	for( int i=0; i&lt;pmoves.size(); i++ )
	{
		arrcpy[pmoves.front().x][pmoves.front().y] = 1;	// Spieler zieht
		std::vector&lt;Coordinates&gt; new_pmoves;
		for( int j=1; j&lt;pmoves.size(); j++ )	// vector bis auf das erste element kopieren
		{
			new_pmoves.push_back( pmoves[j] ); 
		}
		pmoves = new_pmoves;
		return makeMoveMax( arrcpy, new_pmoves );
	}

}

std::vector&lt;Coordinates&gt; Computer::possibleMoves( int** field )
{
	std::vector&lt;Coordinates&gt; pmoves;
	for( int i=0; i&lt;3; i++ )
		for( int j=0; j&lt;3; j++ )
	{
		if( field[i][j] == -1 )
		{
			Coordinates coords( i, j );
			pmoves.push_back( coords );
		}
	}
	return pmoves;
}
</code></pre>
<p>In einer weiteren Datei werden Funktionen definiert, die in der Klasse verwendet werden, die eventuell auch wichtig sind:</p>
<pre><code class="language-cpp">struct Coordinates
{
	Coordinates( int x_, int y_ )
	: x(x_), y(y_) {
	}
	int x;
	int y;
};

int checkWin( int** field )
{
	if( field[0][0] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[2][2] == 1 ||
		   field[2][0] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[0][2] == 1 ||
		   field[0][0] == 1 &amp;&amp; field[1][0] == 1 &amp;&amp; field[2][0] == 1 ||
		   field[0][1] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[2][1] == 1 ||
		   field[0][2] == 1 &amp;&amp; field[1][2] == 1 &amp;&amp; field[2][2] == 1 ||
		   field[0][0] == 1 &amp;&amp; field[0][1] == 1 &amp;&amp; field[0][2] == 1 ||
		   field[1][0] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[1][2] == 1 ||
		   field[2][0] == 1 &amp;&amp; field[2][1] == 1 &amp;&amp; field[2][2] == 1 ) 
		return 1;	// wenn der Spieler gewonnen hat
	else if( field[0][0] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[2][2] == 0 ||
				field[2][0] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[0][2] == 0 ||
				field[0][0] == 0 &amp;&amp; field[1][0] == 0 &amp;&amp; field[2][0] == 0 ||
				field[0][1] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[2][1] == 0 ||
				field[0][2] == 0 &amp;&amp; field[1][2] == 0 &amp;&amp; field[2][2] == 0 ||
				field[0][0] == 0 &amp;&amp; field[0][1] == 0 &amp;&amp; field[0][2] == 0 ||
				field[1][0] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[1][2] == 0 ||
				field[2][0] == 0 &amp;&amp; field[2][1] == 0 &amp;&amp; field[2][2] == 0 ) 	
		return 0;	// wenn der Computer gewonnen hat
	else return -1;	// wenn das Spiel noch nicht vorbei ist
}

int showField( int** field )
{
	std::cout &lt;&lt; &quot;-------------&quot; &lt;&lt;
			&quot;\n| &quot; &lt;&lt; field[0][0] &lt;&lt; &quot; | &quot; &lt;&lt; field[1][0] &lt;&lt; &quot; | &quot; &lt;&lt; field[2][0] &lt;&lt; &quot; |&quot; &lt;&lt; 
			&quot;\n-------------&quot; &lt;&lt;
			&quot;\n| &quot; &lt;&lt; field[0][1] &lt;&lt; &quot; | &quot; &lt;&lt; field[1][1] &lt;&lt; &quot; | &quot; &lt;&lt; field[2][1] &lt;&lt; &quot; |&quot; &lt;&lt;
			&quot;\n-------------&quot; &lt;&lt;
			&quot;\n| &quot; &lt;&lt; field[0][2] &lt;&lt; &quot; | &quot; &lt;&lt; field[1][2] &lt;&lt; &quot; | &quot; &lt;&lt; field[2][2] &lt;&lt; &quot; |&quot; &lt;&lt;  
			&quot;\n-------------&quot; &lt;&lt; std::endl;

}

int** copyArray( int** array, unsigned int size_a, unsigned int size_b )
{
	int** copyed_array = new int*[size_a];
	for( int i=0; i&lt;size_a; i++ )
		copyed_array[i] = new int[size_b];

	for( int a=0; a&lt;size_a; a++ )
		for( int b=0; b&lt;size_b; b++ )
			copyed_array[a][b] = array[a][b];

	return copyed_array;

}

int countFreeFields( int** field )
{
	int res = 0;
	for( int a = 0; a&lt;3; a++ )
		for( int b=0; b&lt;3; b++ )
	{
		if( field[a][b] == -1 ) ++ res;
	}
	return res;
}
</code></pre>
<p>Leider gibt mir die Ausgabe nur mist aus:</p>
<pre><code>-------------
| -1 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
makeMoveMin = 1
MOVE: X = 0, Y = 1
-------------
| -1 | -1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
Spieler am Zug
Feld X: 2
Feld Y: 1
-------------
| -1 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
makeMoveMin = 1
MOVE: X = 0, Y = 2
-------------
| -1 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
Spieler am Zug
Feld X: 2
Feld Y: 2
-------------
| -1 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
makeMoveMin = -1
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
makeMoveMin = -1
makeMoveMin = -1
-------------
| -1 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
Spieler am Zug
Feld X: //...
</code></pre>
<p>im letzten Abschnitt wird also kein möglicher Zug mehr gefunden. Nun meine Frage(n):<br />
- Ist mein Programmcode üerhaupt als Lösungsansatz tauglich?<br />
- Hat jemand ein Paar Tipps für mich wie ich meine KI dazu bringe &quot;intelligente&quot; Züge zu machen?</p>
<p>Mfg Auma</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/228790/erledigt-tic-tac-toe-und-der-minimax-algorithmus</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 10:24:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/228790.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 02 Dec 2008 21:22:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Erledigt]Tic-Tac-Toe und der Minimax-Algorithmus on Tue, 02 Dec 2008 21:56:11 GMT]]></title><description><![CDATA[<p>Hi Leute<br />
Ich will mich etwas in das Thema &quot;Künstliche Intelligenz&quot; einarbeiten und nun versuchte ich ein kleines Tic-Tac-Toe Programm zu entwerfen. Das Programm soll zunächst so einfach wie möglich sein, also Konsolenbasierte Ausgabe. Mein Problem besteht darin, dass ich es einfach nicht schaffe meiner &quot;KI&quot; auch nur einen Hauch von &quot;Intelligenz&quot; zu geben. Mein Ansatz war der Minimax-Algorithmus, jedoch gelingt es mir nicht diesen zu realisieren, mein Code:</p>
<pre><code class="language-cpp">class Computer
{
	private:
		int** field;
		int freieFelder;

	public:
		Computer( int** field );
		~Computer() {}

		int makeMoveMax( int** field, std::vector&lt;Coordinates&gt; pmoves );	// Computer
		int makeMoveMin( int** field, std::vector&lt;Coordinates&gt; pmoves ); // Spieler
		int bestMove();
		std::vector&lt;Coordinates&gt; possibleMoves( int ** );
};

Computer::Computer( int** field )
{
	this-&gt;field = field;
	freieFelder = countFreeFields(field);
}
</code></pre>
<p>Die Klasse &quot;Computer&quot; soll also alle Bestandteile des Algorithmus selbstständig durchführen, so, dass im Hauptprogramm lediglich ein Spielfeld erstellt und übergeben werden und eine Funktion geschrieben werden muss, die Computer und Spieler nacheinander ziehen lässt. Nun zum Hauptproblem, dem Algorithmus:</p>
<pre><code class="language-cpp">int Computer::bestMove()
{
	std::vector&lt;Coordinates&gt; coords = possibleMoves( field );	// anzahl der möglichen züge ermitteln
	for( int i=0; i&lt;coords.size(); i++ )	// computer zieht
	{
		int** arrcpy = copyArray( field, 3, 3 );	// derzeitiges Spielfeld kopieren
		arrcpy[coords.front().x][coords.front().y] = 0;

		std::vector&lt;Coordinates&gt; new_coords;
		for( int j=1; j&lt;coords.size(); j++ )	// vector bis auf das erste element kopieren
		{
			new_coords.push_back( coords[j] ); 
		}
		coords = new_coords;
		std::cout &lt;&lt; &quot;makeMoveMin = &quot; &lt;&lt; makeMoveMin( arrcpy, new_coords ) &lt;&lt; std::endl;
		if( makeMoveMin( arrcpy, new_coords ) == 1 )	// wenn möglichkeit gefunden, koordinaten zurückgeben
		{
			field[coords[i].x][coords[i].y] = 0;
			std::cout &lt;&lt; &quot;MOVE: X = &quot; &lt;&lt; coords[i].x &lt;&lt; &quot;, Y = &quot; &lt;&lt; coords[i].y &lt;&lt; std::endl;
			return 1;

		}
		//return coords[i];

	}
	return 0;	
}

int Computer::makeMoveMax( int** field, std::vector&lt;Coordinates&gt; pmoves )
{
	std::vector&lt;Coordinates&gt; coords = possibleMoves( field );
	if( checkWin( field ) == 0 ) return 1;	// wenn computer gewonnen hat
	int** arrcpy = copyArray( field, 3, 3 );
	for( int i=0; i&lt;pmoves.size(); i++ )
	{
		arrcpy[pmoves.front().x][pmoves.front().y] = 0;	// computer zieht
		std::vector&lt;Coordinates&gt; new_pmoves;
		for( int j=1; j&lt;pmoves.size(); j++ )	// vector bis auf das erste element kopieren
		{
			new_pmoves.push_back( pmoves[j] ); 
		}
		pmoves = new_pmoves;
		if( makeMoveMin( arrcpy, new_pmoves ) == 1 )	// wenn ein positives ergebnis erzielt wurde
			return makeMoveMin( arrcpy, new_pmoves );
	}

	return -1;	// wenn keine Lösung gefunden wurde
}

int Computer::makeMoveMin( int** field, std::vector&lt;Coordinates&gt; pmoves )
{
	std::vector&lt;Coordinates&gt; coords = possibleMoves( field );

	if( checkWin( field ) == 1 ) { showField(field); return 0; }	// wenn Spieler gewonnen hat
	int** arrcpy = copyArray( field, 3, 3 );
	for( int i=0; i&lt;pmoves.size(); i++ )
	{
		arrcpy[pmoves.front().x][pmoves.front().y] = 1;	// Spieler zieht
		std::vector&lt;Coordinates&gt; new_pmoves;
		for( int j=1; j&lt;pmoves.size(); j++ )	// vector bis auf das erste element kopieren
		{
			new_pmoves.push_back( pmoves[j] ); 
		}
		pmoves = new_pmoves;
		return makeMoveMax( arrcpy, new_pmoves );
	}

}

std::vector&lt;Coordinates&gt; Computer::possibleMoves( int** field )
{
	std::vector&lt;Coordinates&gt; pmoves;
	for( int i=0; i&lt;3; i++ )
		for( int j=0; j&lt;3; j++ )
	{
		if( field[i][j] == -1 )
		{
			Coordinates coords( i, j );
			pmoves.push_back( coords );
		}
	}
	return pmoves;
}
</code></pre>
<p>In einer weiteren Datei werden Funktionen definiert, die in der Klasse verwendet werden, die eventuell auch wichtig sind:</p>
<pre><code class="language-cpp">struct Coordinates
{
	Coordinates( int x_, int y_ )
	: x(x_), y(y_) {
	}
	int x;
	int y;
};

int checkWin( int** field )
{
	if( field[0][0] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[2][2] == 1 ||
		   field[2][0] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[0][2] == 1 ||
		   field[0][0] == 1 &amp;&amp; field[1][0] == 1 &amp;&amp; field[2][0] == 1 ||
		   field[0][1] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[2][1] == 1 ||
		   field[0][2] == 1 &amp;&amp; field[1][2] == 1 &amp;&amp; field[2][2] == 1 ||
		   field[0][0] == 1 &amp;&amp; field[0][1] == 1 &amp;&amp; field[0][2] == 1 ||
		   field[1][0] == 1 &amp;&amp; field[1][1] == 1 &amp;&amp; field[1][2] == 1 ||
		   field[2][0] == 1 &amp;&amp; field[2][1] == 1 &amp;&amp; field[2][2] == 1 ) 
		return 1;	// wenn der Spieler gewonnen hat
	else if( field[0][0] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[2][2] == 0 ||
				field[2][0] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[0][2] == 0 ||
				field[0][0] == 0 &amp;&amp; field[1][0] == 0 &amp;&amp; field[2][0] == 0 ||
				field[0][1] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[2][1] == 0 ||
				field[0][2] == 0 &amp;&amp; field[1][2] == 0 &amp;&amp; field[2][2] == 0 ||
				field[0][0] == 0 &amp;&amp; field[0][1] == 0 &amp;&amp; field[0][2] == 0 ||
				field[1][0] == 0 &amp;&amp; field[1][1] == 0 &amp;&amp; field[1][2] == 0 ||
				field[2][0] == 0 &amp;&amp; field[2][1] == 0 &amp;&amp; field[2][2] == 0 ) 	
		return 0;	// wenn der Computer gewonnen hat
	else return -1;	// wenn das Spiel noch nicht vorbei ist
}

int showField( int** field )
{
	std::cout &lt;&lt; &quot;-------------&quot; &lt;&lt;
			&quot;\n| &quot; &lt;&lt; field[0][0] &lt;&lt; &quot; | &quot; &lt;&lt; field[1][0] &lt;&lt; &quot; | &quot; &lt;&lt; field[2][0] &lt;&lt; &quot; |&quot; &lt;&lt; 
			&quot;\n-------------&quot; &lt;&lt;
			&quot;\n| &quot; &lt;&lt; field[0][1] &lt;&lt; &quot; | &quot; &lt;&lt; field[1][1] &lt;&lt; &quot; | &quot; &lt;&lt; field[2][1] &lt;&lt; &quot; |&quot; &lt;&lt;
			&quot;\n-------------&quot; &lt;&lt;
			&quot;\n| &quot; &lt;&lt; field[0][2] &lt;&lt; &quot; | &quot; &lt;&lt; field[1][2] &lt;&lt; &quot; | &quot; &lt;&lt; field[2][2] &lt;&lt; &quot; |&quot; &lt;&lt;  
			&quot;\n-------------&quot; &lt;&lt; std::endl;

}

int** copyArray( int** array, unsigned int size_a, unsigned int size_b )
{
	int** copyed_array = new int*[size_a];
	for( int i=0; i&lt;size_a; i++ )
		copyed_array[i] = new int[size_b];

	for( int a=0; a&lt;size_a; a++ )
		for( int b=0; b&lt;size_b; b++ )
			copyed_array[a][b] = array[a][b];

	return copyed_array;

}

int countFreeFields( int** field )
{
	int res = 0;
	for( int a = 0; a&lt;3; a++ )
		for( int b=0; b&lt;3; b++ )
	{
		if( field[a][b] == -1 ) ++ res;
	}
	return res;
}
</code></pre>
<p>Leider gibt mir die Ausgabe nur mist aus:</p>
<pre><code>-------------
| -1 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
makeMoveMin = 1
MOVE: X = 0, Y = 1
-------------
| -1 | -1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
Spieler am Zug
Feld X: 2
Feld Y: 1
-------------
| -1 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
| -1 | -1 | -1 |
-------------
makeMoveMin = 1
MOVE: X = 0, Y = 2
-------------
| -1 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
Spieler am Zug
Feld X: 2
Feld Y: 2
-------------
| -1 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
makeMoveMin = -1
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | 0 |
-------------
| 0 | 1 | -1 |
-------------
makeMoveMin = -1
makeMoveMin = -1
-------------
| -1 | 1 | -1 |
-------------
| 0 | 1 | -1 |
-------------
| 0 | -1 | -1 |
-------------
Spieler am Zug
Feld X: //...
</code></pre>
<p>im letzten Abschnitt wird also kein möglicher Zug mehr gefunden. Nun meine Frage(n):<br />
- Ist mein Programmcode üerhaupt als Lösungsansatz tauglich?<br />
- Hat jemand ein Paar Tipps für mich wie ich meine KI dazu bringe &quot;intelligente&quot; Züge zu machen?</p>
<p>Mfg Auma</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1624614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1624614</guid><dc:creator><![CDATA[Auma]]></dc:creator><pubDate>Tue, 02 Dec 2008 21:56:11 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt]Tic-Tac-Toe und der Minimax-Algorithmus on Tue, 02 Dec 2008 21:54:08 GMT]]></title><description><![CDATA[<p>Entschuldigt, Kann geschlossen werden habe es nun hinbekommen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1624627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1624627</guid><dc:creator><![CDATA[Auma]]></dc:creator><pubDate>Tue, 02 Dec 2008 21:54:08 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt]Tic-Tac-Toe und der Minimax-Algorithmus on Tue, 02 Dec 2008 21:58:38 GMT]]></title><description><![CDATA[<p>nun ja, ich kenn den minimax algorithmus nicht, aber ich würde so ran gehen:</p>
<p>das feld hat nur neun felder<br />
der erste zug hat also 9 möglichkeiten, der zweite 8, der dritte 7...<br />
das heist, es gibt 362880 mögliche wege zu einem vollen spielbrett zu kommen.<br />
Dann gehen noch vorzeitige enden, aufgrund dder unfähigkeit des spielers <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="😉"
    /> weg</p>
<p>Das heißt man kann am anfang (initialisierungsphase) eine Datenbank aufbauen, mit allen möglichen Spielzügen (Baum).<br />
Dann weist du jedem Knoten zu, bei wievielen Enden der Computer gewinnt/verliert, so hat man zu jedem Entscheidungsknoten die info über Gewinnchance für die möglichen züge.</p>
<p>Wärend des spiel geht man je nach spielerentscheidung dann im baum immer mit und wählt dann den Ast, mit der höchsten wahrscheinlichkeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1624630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1624630</guid><dc:creator><![CDATA[vlad_tepesch]]></dc:creator><pubDate>Tue, 02 Dec 2008 21:58:38 GMT</pubDate></item></channel></rss>