Skip to main content
Removed from Network Questions by Mast
Rollback to Revision 2
Source Link
pacmaninbw
  • 24.8k
  • 11
  • 46
  • 109

Update based on Jesse C. Slicer feedback:

class Board
{
    public Tile[,] Tiles { get; private set; }
    private int Size { get; set; }

    public void StartGame()
    {
        Size = 3;
        Tiles = new Tile [Size,Size];

This part I am not sure if it is done correctly

private void FillTiles()
{
    Tile k = new Tile(0);
    int temp = 0;

    for (int i = 0; i < Size; i++)
    {
        for (int j = 0; j < Size; j++)
        {

            Tiles[i, j] = k;
            temp++;
            k = new Tile(temp);

        }
    }
}

Changed int temp = Tiles[i0, i1]; to Tile temp = Tiles[i0, i1];

Other changes such as var flattedList = Tiles.OfType<Tile>().ToList(); for the flatted list.

The code works like before with the changes made to it.

Update based on Jesse C. Slicer feedback:

class Board
{
    public Tile[,] Tiles { get; private set; }
    private int Size { get; set; }

    public void StartGame()
    {
        Size = 3;
        Tiles = new Tile [Size,Size];

This part I am not sure if it is done correctly

private void FillTiles()
{
    Tile k = new Tile(0);
    int temp = 0;

    for (int i = 0; i < Size; i++)
    {
        for (int j = 0; j < Size; j++)
        {

            Tiles[i, j] = k;
            temp++;
            k = new Tile(temp);

        }
    }
}

Changed int temp = Tiles[i0, i1]; to Tile temp = Tiles[i0, i1];

Other changes such as var flattedList = Tiles.OfType<Tile>().ToList(); for the flatted list.

The code works like before with the changes made to it.

Edits based on feedback
Source Link
Darke
  • 163
  • 8

Update based on Jesse C. Slicer feedback:

class Board
{
    public Tile[,] Tiles { get; private set; }
    private int Size { get; set; }

    public void StartGame()
    {
        Size = 3;
        Tiles = new Tile [Size,Size];

This part I am not sure if it is done correctly

private void FillTiles()
{
    Tile k = new Tile(0);
    int temp = 0;

    for (int i = 0; i < Size; i++)
    {
        for (int j = 0; j < Size; j++)
        {

            Tiles[i, j] = k;
            temp++;
            k = new Tile(temp);

        }
    }
}

Changed int temp = Tiles[i0, i1]; to Tile temp = Tiles[i0, i1];

Other changes such as var flattedList = Tiles.OfType<Tile>().ToList(); for the flatted list.

The code works like before with the changes made to it.

Update based on Jesse C. Slicer feedback:

class Board
{
    public Tile[,] Tiles { get; private set; }
    private int Size { get; set; }

    public void StartGame()
    {
        Size = 3;
        Tiles = new Tile [Size,Size];

This part I am not sure if it is done correctly

private void FillTiles()
{
    Tile k = new Tile(0);
    int temp = 0;

    for (int i = 0; i < Size; i++)
    {
        for (int j = 0; j < Size; j++)
        {

            Tiles[i, j] = k;
            temp++;
            k = new Tile(temp);

        }
    }
}

Changed int temp = Tiles[i0, i1]; to Tile temp = Tiles[i0, i1];

Other changes such as var flattedList = Tiles.OfType<Tile>().ToList(); for the flatted list.

The code works like before with the changes made to it.

Became Hot Network Question
Tweeted twitter.com/StackCodeReview/status/1601275498868473856
Confirmation that the code is complete
Source Link
Darke
  • 163
  • 8

The code above works, as in the user can move and it will complete when the puzzle is in this state 1 2 3 4 5 6 7 8 0. I have tested some puzzles that where generated with Puzzle solver From the testing it seems a lot of the puzzle states are not solvable which shouldn't be the case. My method IsSolvable seem flawed.

The code above works, as in the user can move and it will complete when the puzzle is in this state 1 2 3 4 5 6 7 8 0. I have tested some puzzles that where generated with Puzzle solver From the testing it seems a lot of the puzzle states are not solvable which shouldn't be the case. My method IsSolvable seem flawed.

Source Link
Darke
  • 163
  • 8
Loading