Beispiel #1
0
    bool ValidMove(AICellData start, AICellData end, Player player)
    {
        bool positionCheck = false;

        if (start.player != player || start.faceup == false)
        {
            return(false);
        }

        if (start.position.x == end.position.x && Math.Abs(start.position.y - end.position.y) == 1)
        {
            positionCheck = true;
        }

        else if (start.position.y == end.position.y && Math.Abs(start.position.x - end.position.x) == 1)
        {
            positionCheck = true;
        }

        if (!positionCheck)
        {
            return(false);
        }

        else if (end.faceup == false || end.player == player)
        {
            return(false);
        }

        else
        {
            return(true);
        }
    }
Beispiel #2
0
    public AIBoardData CreateTestBoard1()
    {
        //| 0   | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
        //| 0   | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
        //| 0   | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
        //| 1r^ | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
        AICellData[] boardData = new AICellData[32];
        boardData[0] = new AICellData {
            value = CellValue.One, player = Player.Red, faceup = true
        };
        AIBoardData board = new AIBoardData(boardData, false);

        return(board);
    }
Beispiel #3
0
 AIBoardData ScanBoard()
 //scans current board and flattens cell data into an array
 {
     AICellData[] flattenedCellArray = new AICellData[32];
     for (int y = 0; y < boardY; y++)
     {
         for (int x = 0; x < boardX; x++)
         {
             int  index = y * boardX + x;
             Cell cell  = board.cells[x, y];
             flattenedCellArray[index].value    = cell.GetValue();
             flattenedCellArray[index].player   = cell.GetColor();
             flattenedCellArray[index].faceup   = cell.GetFlipState();
             flattenedCellArray[index].position = cell.GetCoordinate();
         }
     }
     return(new AIBoardData(flattenedCellArray, false));
 }
Beispiel #4
0
    public AIBoardData CreateTestBoardFaceDownOnly1()
    {
        //| 0   | 0   | 0 | 0 | 0 | 0 | 0 | 0 |
        //| 1r. | 1r. | 0 | 0 | 0 | 0 | 0 | 0 |
        //| 1r. | 0   | 0 | 0 | 0 | 0 | 0 | 0 |
        //| 1r. | 0   | 0 | 0 | 0 | 0 | 0 | 0 |
        AICellData[] boardData = new AICellData[32];
        boardData[0] = new AICellData {
            value = CellValue.One, player = Player.Red, faceup = false
        };
        boardData[8] = new AICellData {
            value = CellValue.One, player = Player.Red, faceup = false
        };
        boardData[16] = new AICellData {
            value = CellValue.One, player = Player.Red, faceup = false
        };
        boardData[17] = new AICellData {
            value = CellValue.One, player = Player.Red, faceup = false
        };
        AIBoardData board = new AIBoardData(boardData, false);

        return(board);
    }