X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=qchess%2Fsrc%2Fagent_bishop.py;h=20cb4c0ee213d143f006034b1b6b2dca81ee53d3;hb=HEAD;hp=13be5bdcb2fdb79a95746fce220e3be70d365992;hpb=877034f05346e24fdf822f6e6149ad50d891f030;p=progcomp2013.git diff --git a/qchess/src/agent_bishop.py b/qchess/src/agent_bishop.py index 13be5bd..20cb4c0 100644 --- a/qchess/src/agent_bishop.py +++ b/qchess/src/agent_bishop.py @@ -1,11 +1,10 @@ # A sample agent -class AgentBishop(InternalAgent): # Inherits from InternalAgent (in qchess) - def __init__(self, name, colour): +class AgentBishop(AgentRandom): # Inherits from AgentRandom (in qchess) + def __init__(self, name, colour,value={"pawn" : 1, "bishop" : 3, "knight" : 3, "rook" : 5, "queen" : 9, "king" : 100, "unknown" : 2}): InternalAgent.__init__(self, name, colour) - self.value = {"pawn" : 1, "bishop" : 3, "knight" : 3, "rook" : 5, "queen" : 9, "king" : 100, "unknown" : 4} - + self.value = value self.aggression = 2.0 # Multiplier for scoring due to aggressive actions self.defence = 1.0 # Multiplier for scoring due to defensive actions @@ -47,10 +46,9 @@ class AgentBishop(InternalAgent): # Inherits from InternalAgent (in qchess) # Get total probability that the move is protected - [xx,yy] = [piece.x, piece.y] - [piece.x, piece.y] = [x, y] - self.board.grid[x][y] = piece - self.board.grid[xx][yy] = None + self.board.push_move(piece, x, y) + + defenders = self.board.coverage(x, y, piece.colour, reject_allied = False) d_prob = 0.0 @@ -73,9 +71,8 @@ class AgentBishop(InternalAgent): # Inherits from InternalAgent (in qchess) if (a_prob > 1.0): a_prob = 1.0 - self.board.grid[x][y] = target - self.board.grid[xx][yy] = piece - [piece.x, piece.y] = [xx, yy] + self.board.pop_move() + # Score of the move @@ -163,6 +160,7 @@ class AgentBishop(InternalAgent): # Inherits from InternalAgent (in qchess) def select(self): #sys.stderr.write("Getting choice...") self.choice = self.select_best(self.colour)[0] + #sys.stderr.write(" Done " + str(self.choice)+"\n") return [self.choice.x, self.choice.y] @@ -174,5 +172,5 @@ class AgentBishop(InternalAgent): # Inherits from InternalAgent (in qchess) if len(moves) > 0: return moves[0][0] else: - return InternalAgent.get_move(self) + return AgentRandom.get_move(self)