change to final_test

Dependencies:   4DGL-uLCD-SE EthernetInterface HTTPClient mbed-rtos mbed

Fork of Fianl_test by Hongyao Shi

Revision:
0:28f8ba171e86
Child:
3:b834ab4a53d1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/board.cpp	Mon Apr 20 23:05:36 2015 +0000
@@ -0,0 +1,69 @@
+#include "stdio.h"
+#include "stdlib.h"
+#include "board.h"
+
+
+
+Board::Board(void)
+{
+    board = new int*[3];
+    for(int i=0; i<3; i++)
+    {
+        board[i] = new int[3];
+        for(int j=0; j<3; j++)
+            board[i][j]=0;
+    }
+}
+
+int ** Board::get_board()
+{
+    return board;
+}
+
+void Board::set_board(int col, int row, int playerID)
+{
+    if(board[col][row]!=0 && turn == playerID)
+    {}
+    else
+    {
+        board[col][row] = playerID;
+    }
+}
+
+bool Board::updateBoard(int turn, int printout)
+{
+    int location_x = printout/3;
+    int location_y = printout%3;
+    if(board[location_x][location_y] == 0)
+    {
+        board[location_x][location_y] = turn;
+        return true;
+    }
+    else
+        return false;
+}
+
+int Board::updateBoard_output(int turn, int printout)
+{
+    int location_x = printout/3;
+    int location_y = printout%3;
+    return board[location_x][location_y];
+}
+
+
+int Board::check_victory(int playerID)
+{
+    if(board[0][0] == playerID && board[0][1] == playerID && board[0][2] == playerID
+    ||board[0][0] == playerID && board[1][1] == playerID && board[2][2] == playerID
+    ||board[0][0] == playerID && board[1][0] == playerID && board[2][0] == playerID
+    ||board[1][0] == playerID && board[1][1] == playerID && board[1][2] == playerID
+    ||board[2][0] == playerID && board[2][1] == playerID && board[2][2] == playerID
+    ||board[0][1] == playerID && board[1][1] == playerID && board[1][2] == playerID
+    ||board[0][1] == playerID && board[2][1] == playerID && board[2][2] == playerID
+    ||board[0][2] == playerID && board[1][1] == playerID && board[2][0] == playerID)
+        return playerID;
+    else
+        return 0;
+}
+    
+    
\ No newline at end of file