def update(self, action):
        #update number of turns
        self.no_turns=self.no_turns+1
        self.our_turns+=1
        #shrink board when number of turns achived
        if(self.no_turns==128):
            Game.shrinkBoard(self.board)
        if(self.no_turns==192):
            Game.shrinkBoard(self.board)
        if(self.our_turns==24):
            self.placingPhase=False

        #remove kill before anything
        Game.removeKills(self.board, self.team_colour, self.oppo_colour)
        if (action != None):
            #if its the placing phase
            if(self.placingPhase):
                #after placing the peice check for kills
                Board.placePiece(self.board,action[0],action[1],self.oppo_colour)
                Game.removeKillsAfterAction(self.board, action[0], action[1],
                                            self.team_colour, self.oppo_colour)
            else:
                #after moivng check for kills
                Board.movePiece(self.board,action[0][0], action[0][1],
                                                    action[1][0],action[1][1])
                Game.removeKillsAfterAction(self.board, action[1][0],
                                action[1][1], self.team_colour, self.oppo_colour)
 def evalDeathTrap(board, col, row, colour):
     eval=0
     if((Game.checkUpKill(board,col,row, colour)) and Game.checkDownKill(
                                                     board,col,row, colour)):
         eval+=1
     if((Game.checkRightKill(board,col,row, colour) and Game.checkLeftKill(
                                                 board,col,row, colour))):
         eval+=1
     return(eval)
    def moving(board, colour):

        for col in range(0, 8):
            for row in range(0, 8):
                if (Board.comaprePieceat(board, col, row, colour)):
                    if Game.freeUp(board, col, row):
                        Board.movePiece(board, col, row, col, row - 1)
                        return ((col, row), (col, row - 1))
                    if Game.freeDown(board, col, row):
                        Board.movePiece(board, col, row, col, row + 1)
                        return ((col, row), (col, row + 1))
                    if Game.freeRight(board, col, row):
                        Board.movePiece(board, col, row, col + 1, row)
                        return ((col, row), (col + 1, row))
                    if Game.freeLeft(board, col, row):
                        Board.movePiece(board, col, row, col - 1, row)
                        return ((col, row), (col - 1, row))
        return ()
    def action(self, turns):

        Game.removeKills(self.board)

        self.no_turns = turns
        self.our_turns += 1
        if (self.no_turns == 128):
            Game.shrinkBoard(self.board)
        if (self.no_turns == 192):
            Game.shrinkBoard(self.board)
        if (self.our_turns == 24):
            self.plasingPhase = False
            print("CHnaged to mving phase")

        if (self.plasingPhase):
            return (Player.minimax(self.board, self.team_colour,
                                   self.oppo_colour, "PP"))
            Board.printBoard(self.board)
            #Player.placing_phase(self.board, self.team_colour))

        else:
            print("My moving phase activated")
            out = Player.minimax(self.board, self.team_colour,
                                 self.oppo_colour, "MP")
            print(out)
            return (out[0], out[1]), (out[2], out[3])
            return Player.moving(self.board, self.team_colour)
def getSuccessors(board, colour, needCord, type, oppo_colour):

    Successors=[]
    cord=[]
    #if its the placing phase then get states for that phase
    if (type=="PP"):

        #if you want the board as the output
        if(colour == "W"):
            for col in range (0,8):
                for row in range (0,6):
                    if (Board.comaprePieceat(board,col,row, "E")):
                        #make a copy of the board that will represent a new state
                        tempBoard=copy.deepcopy(board)
                        Board.placePiece(tempBoard,col,row,"W")
                        #check if after placing the piece there is something
                        # that can be eliminated from the board and remove it
                        #from the board
                        Game.removeKills(tempBoard, colour, oppo_colour)
                        Successors.append(tempBoard)
                        if (needCord):
                            cord.append((col, row))

        if(colour == "B"):
            for col in range (0,8):
                for row in range (2,8):
                    if (Board.comaprePieceat(board,col,row, "E")):
                        #make a copy of the board that will represent a new state
                        tempBoard=copy.deepcopy(board)
                        Board.placePiece(tempBoard,col,row,"B")
                        # check if after placing the piece there is something
                        # that can be eliminated from the board and remove it
                        #from the board
                        Game.removeKills(tempBoard, colour, oppo_colour)
                        Successors.append(tempBoard)
                        if (needCord):
                            cord.append((col, row))

    # if its in the moving phase then get states for that phase
    if (type=="MP"):
        #check all the possible moves peices of our colour can make and return states
        for row in range(Board.getMinRowSize(board), Board.getMaxRowSize(board)+1):
            for col in range(Board.getMinColSize(board), Board.getMaxColSize(board)+1):
                if (Board.comaprePieceat(board,col,row, colour )):
                    temp=checkMove(board,col, row)
                    for pos in temp:
                        #make a copy of the board that will represent a new state
                        tempBoard=copy.deepcopy(board)
                        #move the peice to the new location
                        Board.movePiece(tempBoard,col,row,pos[0],pos[1])
                        #remove kills
                        Game.removeKills(tempBoard, colour,oppo_colour )
                        Successors.append(tempBoard)
                        if (needCord):
                            cord.append((col,row,pos[0],pos[1]))

    return (cord,Successors)
    def update(self, action):
        Board.printBoard(self.board)
        self.no_turns = self.no_turns + 1
        self.our_turns += 1
        if (self.no_turns == 128):
            Game.shrinkBoard(self.board)
        if (self.no_turns == 192):
            Game.shrinkBoard(self.board)
        if (self.our_turns == 24):
            self.placingPhase = False
            print("CHnaged to mving phase")

        Game.removeKills(self.board)
        print(self.no_turns)
        print(action)

        if (self.placingPhase):
            Board.placePiece(self.board, action[0], action[1],
                             self.oppo_colour)
        else:
            Board.movePiece(self.board, action[0][0], action[0][1],
                            action[1][0], action[1][1])
    def action(self, turns):

        Game.removeKills(self.board)

        self.no_turns = turns
        self.our_turns += 1
        if (self.no_turns == 128):
            Game.shrinkBoard(self.board)
        if (self.no_turns == 192):
            Game.shrinkBoard(self.board)
        if (self.our_turns == 24):
            self.placingPhase = False
            print("CHnaged to mving phase")

        if (self.placingPhase):
            return (self.attkStrat.execute(self.board, self.team_colour,
                                           self.oppo_colour, "PP"))

        else:
            print("My moving phase activated")
            out = self.attkStrat.execute(self.board, self.team_colour,
                                         self.oppo_colour, "MP")
            return (out[0], out[1]), (out[2], out[3])
    def action(self, turns):
    
        #remove all the kills before starting
        Game.removeKills(self.board,  self.oppo_colour, self.team_colour)
        #update our number of turns
        self.no_turns=turns
        self.our_turns+=1
        #shrink the board if it reaches a set numbe rof turns
        if(self.no_turns==128):
            Game.shrinkBoard(self.board)
        if(self.no_turns==192):
            Game.shrinkBoard(self.board)

        #if we moved into the moving place, note it
        if(self.our_turns==24):
            self.placingPhase=False

        #if its the placing phase
        if (self.placingPhase):


            #if we have out peices in the 4 middle squares, excecute the god mode strategy
            if(Evaluation.mainFourSquares(self.board,self.team_colour,self.
                                                            oppo_colour)==1):
                out=self.godModeStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"PP",self.no_turns)
                #remove kills after placing
                Game.removeKillsAfterAction(self.board, out[0],out[1],
                                            self.oppo_colour, self.team_colour)
                return(out)



            tempAdvantage=Evaluation.PeiceAdvantage(self.board,self.team_colour,
                                                                self.oppo_colour)
            #if we have 5 more peices than the opponent, massacre!!!!!!!
            if(tempAdvantage>=5):
                out=self.massacreStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"PP",self.no_turns)
                #remove kills after placing
                Game.removeKillsAfterAction(self.board, out[0],out[1],
                                            self.oppo_colour, self.team_colour)
                return(out)



            #if we have 3 or less less peices than the opponent, excecute the
            #defend strategy
            if (tempAdvantage<=-3):
                out=self.defStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"PP",self.no_turns)
                #remove kills after placing
                Game.removeKillsAfterAction(self.board, out[0],out[1],
                                            self.oppo_colour, self.team_colour)
                return(out)
            else:
                #if not just atttaaackkkkkkk!!!!!
                out=self.attkStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"PP",self.no_turns)
                #remove kills after placing
                Game.removeKillsAfterAction(self.board, out[0],out[1],
                                            self.oppo_colour, self.team_colour)
                return(out)


        else: #if its moving phase
            #if we have out peices in the 4 middle squares, excecute
            #the god mode strategy
            if(Evaluation.mainFourSquares(self.board,self.team_colour,
                                                        self.oppo_colour)==1):
                out=self.godModeStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"MP",self.no_turns)
                if (out!=None):
                    #remove kills after the move
                    Game.removeKillsAfterAction(self.board, out[2],out[3],
                                            self.oppo_colour, self.team_colour)
                    return(out[0],out[1]),(out[2],out[3])
                return(None)


            #get our advantage
            tempAdvantage=Evaluation.PeiceAdvantage(self.board,
                                            self.team_colour,self.oppo_colour)
            #if we have 5 more peices than the opponent, massacre!!!!!!!
            if(tempAdvantage>=5):
                out=self.massacreStrat.execute(self.board,self.team_colour,
                                        self.oppo_colour,"MP", self.no_turns)
                Game.removeKillsAfterAction(self.board, out[2],out[3],
                                            self.oppo_colour, self.team_colour)
                return(out[0],out[1]),(out[2],out[3])
            #if we have 3 or less less peices than the opponent, excecute the
            #defend strategy
            if (tempAdvantage<=-3):
                out=self.defStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"MP", self.no_turns)
            else:
                #if not just atttaaackkkkkkk!!!!!
                out=self.attkStrat.execute(self.board,self.team_colour,
                                            self.oppo_colour,"MP", self.no_turns)
            if (out!=None):
                #remove kills after the move
                Game.removeKillsAfterAction(self.board, out[2],out[3],
                                            self.oppo_colour, self.team_colour)
                return(out[0],out[1]),(out[2],out[3])
            return(None)
    def getSuccessors(board, colour, output, type):

        Successors = []
        #if its in the placing phase then get states for that phase
        if (type == "PP"):

            #if you want the board as the output
            if (output == "boards"):
                if (colour == "W"):
                    for col in range(0, 8):
                        for row in range(0, 6):
                            if (Board.comaprePieceat(board, col, row, "E")):
                                tempBoard = copy.deepcopy(
                                    board
                                )  #make a copy of the board that will represent a new state
                                Board.placePiece(tempBoard, col, row, "W")
                                Game.removeKills(
                                    tempBoard
                                )  # check if after placing the piece there is something
                                # that can be eliminated from the board and remove it from the board
                                Successors.append(tempBoard)

                if (colour == "B"):
                    for col in range(0, 8):
                        for row in range(2, 8):
                            if (Board.comaprePieceat(board, col, row, "E")):
                                tempBoard = copy.deepcopy(
                                    board
                                )  #make a copy of the board that will represent a new state
                                Board.placePiece(tempBoard, col, row, "B")
                                Game.removeKills(
                                    tempBoard
                                )  # check if after placing the piece there is something
                                # that can be eliminated from the board and remove it from the board
                                Successors.append(tempBoard)
            #if you want the output as coordinates
            else:
                if (colour == "W"):
                    for col in range(0, 8):
                        for row in range(0, 6):
                            if (Board.comaprePieceat(board, col, row, "E")):
                                Successors.append((col, row))

                if (colour == "B"):
                    for col in range(0, 8):
                        for row in range(2, 8):
                            if (Board.comaprePieceat(board, col, row, "E")):
                                Successors.append((col, row))

        # if its in the moving phase then get states for that phase
        if (type == "MP"):
            if (output == "boards"):
                for row in range(Board.getMinRowSize(board),
                                 Board.getMaxRowSize(board) + 1):
                    for col in range(Board.getMinColSize(board),
                                     Board.getMaxColSize(board) + 1):
                        if (Board.comaprePieceat(board, col, row, colour)):
                            temp = Player.checkMove(board, col, row)
                            for pos in temp:
                                tempBoard = copy.deepcopy(
                                    board
                                )  #make a copy of the board that will represent a new state
                                Board.movePiece(tempBoard, col, row, pos[0],
                                                pos[1])
                                Game.removeKills(tempBoard)
                                Successors.append(tempBoard)

            else:
                for row in range(Board.getMinRowSize(board),
                                 Board.getMaxRowSize(board) + 1):
                    for col in range(Board.getMinColSize(board),
                                     Board.getMaxColSize(board) + 1):
                        if (Board.comaprePieceat(board, col, row, colour)):
                            temp = Player.checkMove(board, col, row)
                            for pos in temp:
                                Successors.append((col, row, pos[0], pos[1]))

        return Successors