<?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[Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst]]]></title><description><![CDATA[<p>Abend,</p>
<p>hat einer ne Idee, wie ich <code>boost::multi_array&lt;...&gt;::array_type&lt;...&gt;</code> iterierbar machen kann?</p>
<p>Brauche es für <code>std::search_n</code> . :xmas2:</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312092/iterierbares-boost-multi_array-lt-gt-array_type-lt-gt-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Mon, 03 Aug 2026 16:18:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312092.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Dec 2012 19:48:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Mon, 24 Dec 2012 00:04:54 GMT]]></title><description><![CDATA[<p>Abend,</p>
<p>hat einer ne Idee, wie ich <code>boost::multi_array&lt;...&gt;::array_type&lt;...&gt;</code> iterierbar machen kann?</p>
<p>Brauche es für <code>std::search_n</code> . :xmas2:</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282792</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 24 Dec 2012 00:04:54 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 22:22:08 GMT]]></title><description><![CDATA[<p>Ich hab das ganze wohl ein wenig zu knapp beschrieben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Es geht darum, dass ich ein Zweidimensionales Spielfeld für 4-Gewinnt habe. Die einzelnen Feldelemente des Spielfelds sind einfache Objekte dieser Enumeration</p>
<pre><code>enum ConnectFourFigure
                {
                        NoPlayer,
                        Player1,
                        Player2,
                        CPU
                };
</code></pre>
<p>Ich muss jetzt einfach alle Sequenzen einer bestimmen Anzahl finden (momentan nur 3/4).<br />
Das Problem ist, dass ich die Positionen der einzelnen Elemente dieser Sequenzen in ein Set schieben muss.</p>
<p>Ich hab mir zuerst gedacht, das ganze mit <code>search_n</code> zu erledigen, denn in der Methode in der ich es brauche geht es erstmal nur um horizontale Gruppen die sich mit dem <code>multi_array</code> das ich verwende leicht finden lassen sollten, leider ist es nicht möglich über eine Subview - wenn ich sie erst erzeugt habe - zu iterieren.</p>
<p>Ich denke, ich lass es jetzt mit den Iteratoren und verwende ganz normale Indize.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282869</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 23 Dec 2012 22:22:08 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 22:28:42 GMT]]></title><description><![CDATA[<p>Warum schaust du jedesmal das ganze Spielfeld von neuem an? Du brauchst doch nur das eine geänderte Feld und seine Nachbarn anschauen, maximal sind das 12 Felder (und es geht sogar auf einem unendlichen Spielfeld).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282872</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282872</guid><dc:creator><![CDATA[leisi]]></dc:creator><pubDate>Sun, 23 Dec 2012 22:28:42 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 22:35:09 GMT]]></title><description><![CDATA[<p>Nö.</p>
<p>Ich brauche ja die Bedrohungen. Die können sich durch einen Stein völlig verändern.<br />
Ich zeig das mal.</p>
<p>+ ist eine Bedrohung,<br />
# ist ein Steinchen</p>
<pre><code>. . . . . . . .
 . . . . . . . .
 . . . . . . . .
 . . . . # . . .
 . . . . # . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> In der entsprechenden Spalte einen pushen führt zu</p>
<pre><code>. . . . . . . .
 . . . . + . . .
 . . . . # . . .
 . . . . # . . .
 . . . . # . . .
 . . . . + . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
<p>Oder</p>
<pre><code>. . . . . . . .
 . . # # . . . .
 . . . . . . . .
 . . . . # # . .
 . . . . # . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> In der fünften Zeile pushen führt zu</p>
<pre><code>. . + . . . . .
 . . # # + . . .
 . . . . # . . .
 . . . . # # . .
 . . . . # . + .
 . . . . + . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2282875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282875</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 23 Dec 2012 22:35:09 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 22:52:33 GMT]]></title><description><![CDATA[<p>Doch.</p>
<pre><code>. . . . . . . .
 . . . . . . . .
 . . . . N . . .
 . . . . # . . .
 . . . . # . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
<p>(N heisst neu)</p>
<p>Test auf Reihe horizontal von N aus: Negativ<br />
Test auf Reihe diagonal hoch von N aus: Negativ<br />
Test auf Reihe diagonal runter von N aus: Negativ<br />
Test auf Reihe vertikal von N aus: 2 Steine darunter, also Reihe von (2, 4) bis (5, 4) von Länge 3 =&gt; Bedrohung auf Start+(-1, 0) und auf Ende (sofern kein eigener Stein dort liegt)<br />
=&gt;</p>
<pre><code>. . . . . . . .
 . . . . + . . .
 . . . . # . . .
 . . . . # . . .
 . . . . # . . .
 . . . . + . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
<p>Zweites Beispiel:</p>
<pre><code>. . . . . . . .
 . . # # . . . .
 . . . . N . . .
 . . . . # # . .
 . . . . # . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
<p>Test auf Reihe horizontal von N aus: Negativ<br />
Test auf Reihe diagonal hoch von N aus: Negativ<br />
Test auf Reihe diagonal runter von N aus: Reihe von (3, 1) bis (6, 4) von Länge 3 =&gt; Bedrohung auf Start+(-1, -1) und Ende<br />
Test auf Reihe vertikal von N aus: Reihe von (4, 2) bis (7, 2) von Länge 3 =&gt; Bedrohung auf Start+(0, -1) und Ende<br />
=&gt;</p>
<pre><code>. . + . . . . .
 . . # # + . . .
 . . . . # . . .
 . . . . # # . .
 . . . . # . + .
 . . . . + . . .
 . . . . . . . .
 . . . . . . . .
 . . . . . . . .
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2282881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282881</guid><dc:creator><![CDATA[leisi]]></dc:creator><pubDate>Sun, 23 Dec 2012 22:52:33 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 22:54:36 GMT]]></title><description><![CDATA[<p>Und das ist wirklich (jetzt nur vom Code her) einfacher umzusetzen?</p>
<p>Locker nicht.</p>
<p>Die Performance macht sowieso keinen Unterschied.<br />
Und vom Code her ist es vorausichtlich nach meiner Variante einfacher. :xmas2:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282883</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 23 Dec 2012 22:54:36 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 22:58:38 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>Und vom Code her ist es vorausichtlich nach meiner Variante einfacher. :xmas2:</p>
</blockquote>
<p>Zeig mir mal, wie du die Suche nach diagonalen Bedrohungen aufs ganze Spielfeld umgesetzt hast :xmas2:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282886</guid><dc:creator><![CDATA[leisi]]></dc:creator><pubDate>Sun, 23 Dec 2012 22:58:38 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 23:11:46 GMT]]></title><description><![CDATA[<p>leisi schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<p>Und vom Code her ist es vorausichtlich nach meiner Variante einfacher. :xmas2:</p>
</blockquote>
<p>Zeig mir mal, wie du die Suche nach diagonalen Bedrohungen aufs ganze Spielfeld umgesetzt hast :xmas2:</p>
</blockquote>
<p>Das willst du nicht sehen, glaub mir.<br />
Das ist erstmal nur die Suche nach diagonalen Sequenzen:</p>
<pre><code>ConnectFourField::PlayerPositionSets ConnectFourField::checkDiagonal(uint8_t n) const
                {
                        ConnectFourFigure checkVal{mNullval};

                        PlayerPositionSets rval;

                        for(uint8_t globalX(0);globalX &lt; mMatrix.shape()[0];++globalX)
                                for(uint8_t globalY(0);globalY &lt; mMatrix.shape()[1];++globalY)
                                {
                                        uint8_t FigureCounter = 0;

                                        boost::circular_buffer&lt; Position&lt;&gt; &gt; lastPositions(n);

                                        for(uint8_t x(globalX), y(globalY) ; x &lt; mMatrix.shape()[0] &amp;&amp; y &lt; mMatrix.shape()[1] ;)
                                        {
                                                lastPositions.push_back({x, y});

                                                if( ConnectFourFigure f = checkHelper( mMatrix[x][y], checkVal, FigureCounter, n ) )
                                                        ( f == Player1 ? rval.first : rval.second ).insert( PositionSet{ lastPositions.begin(), lastPositions.end() } );

                                                ++y, ++x;
                                        }

                                        checkVal = mNullval;//reset checkVal
                                        FigureCounter = 0;//reset the counter
                                        lastPositions.clear();

                                        for(int8_t x(globalX), y(globalY) ; x &gt;= 0 &amp;&amp; y &lt; mMatrix.shape()[1];)
                                        {
                                                lastPositions.push_back( {x, y} );

                                                if( ConnectFourFigure f = checkHelper(mMatrix[x][y], checkVal, FigureCounter, n) )
                                                        (f == Player1 ? rval.first : rval.second ).insert( PositionSet{ lastPositions.begin(), lastPositions.end() } );

                                                 ++y, --x;
                                        }
                                }

                        return rval;
                }
</code></pre>
<p>(Kommis rausgenommen)<br />
:xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282889</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 23 Dec 2012 23:11:46 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Sun, 23 Dec 2012 23:23:08 GMT]]></title><description><![CDATA[<p>Die Idee war jetzt, dass man ja die Positionen der in den Sequenzen enthaltenen Steinchen hat, man einfach das ganze abprüfen kann.<br />
Aber der Code zum Abprüfen einer Bedrohung anhand der Sequenzen ist nochmal lang.</p>
<p><strong>Edit:</strong> Der Code oben wird natürlich noch ggf. umgeschrieben, jetzt wo ich auf <code>multi_array</code> umgestiegen bin dürfte es mit slicing etwas einfacher sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282890</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 23 Dec 2012 23:23:08 GMT</pubDate></item><item><title><![CDATA[Reply to Iterierbares boost::multi_array&amp;lt;...&amp;gt;::array_type&amp;lt;...&amp;gt; [gelöst] on Mon, 24 Dec 2012 00:04:43 GMT]]></title><description><![CDATA[<p>Gute nachrichten: Habe alles gefixed und hat beim ersten Durchlauf im Test keinen einzigen Fehler gehabt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
Sehr zufrieden :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282897</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 24 Dec 2012 00:04:43 GMT</pubDate></item></channel></rss>