Game Board Algorithm
<p>I get a dictionary of a bunch of game pieces with the three properties:</p>

<p>Address = Location in a game piece <br>
Offset = Offset from the left of where the game piece is connected<br>
Width = Width of the game piece (One, Two or Three wide)</p>

<p>The gameboard itself is 6 wide and 5 high (A total of 30 possible positions)</p>

<p>25 26 27 28 29 30<br>
19 20 21 22 23 24<br>
13 14 15 16 17 18<br>
07 08 09 10 11 12<br>
01 02 03 04 05 06<br> </p>

<p>Each number is the corresponding address on the board.</p>

<p>I would like to be able to add all these pieces to a collection like           <code>ObservableCollection&lt;GameRow&gt; GameRows</code> where</p>

<pre><code>public class GameRow
{
    public ObservableCollection&lt;GamePiece&gt; Row { get; set; }

    public GameRow(ArrayList&lt;GamePiece&gt; gamePieces)
    {
        Row = new ObservableCollection&lt;GamePiece&gt;();

        foreach (GamePiece gamePiece in gamePieces)
        {
            Row.Add(gamePiece);
        }
    }
}
</code></pre>

<p>and </p>

<pre><code>public class GamePiece
{
    public string Width { get; set; }  
    public string Color { get; set; }
    public int Address {get; set}
}
</code></pre>

<p>I also need to create a gamepiece for any unused area on the board that is a single width and a color gray (the other game pieces should have a color of yellow).</p>

<p>Here is what the game pieces look like:</p>

<p>One wide: <br>
X  (offset = 0)          </p>

<p>Two Wide: <br>
0X (offset = 1) </p>

<p>Three Wide <br>
0X0 (offset = 1)</p>

<p>X = What is reported as the address for that piece<br>
0 = The empty space it occupies.</p>

<p>I'm trying to come up with a way to parse that dictionary of game pieces I receive into GameRows.</p>

<p>Example:</p>

<p>Lets say I get three pieces. {Address=2, Width = 1, Offset = 0},{Address=12, Width = 2, Offset = 1}, {Address=23, Width = 3, Offset = 1}</p>

<p>I know the address 2 piece will be on the first row and take position 02 and the rest of the game pieces for that board should be blank gamepieces with a width of 1.  The piece that is address 12 will be in the second row and take positions 11 and 12.  The piece that is address 23 will be in the 4th row and take positions 22, 23, 24.  The ObservableCollection GameRows will have five GameRow objects in it.  The GameRow object for row 4 will contain 4 objects in the Row collection.  The first 3 being blank pieces will be {Width = 1, Color = Gray} and the last piece will be a {Width = 3, Color = Yellow}</p>
