Weight is now more accurate
This commit is contained in:
parent
dd70d575d4
commit
1a670b59b5
1 changed files with 26 additions and 16 deletions
|
@ -55,23 +55,44 @@ class WeightHeuristicEngine(HeuristicEngine):
|
|||
|
||||
# Elements in the corner
|
||||
if pos_x in [0, size -1] and pos_y in [0,size - 1]:
|
||||
w[pos_x][pos_y] = self.options['weight'][2]
|
||||
w[pos_x][pos_y] = self.options['weight'][3]
|
||||
|
||||
# corners are a bad place!
|
||||
elif (pos_x in [0, size - 1] and pos_y in [size - 2, 1]) or \
|
||||
(pos_x in [1, size -2] and pos_y in [0, size - 1]):
|
||||
w[pos_x][pos_y] = self.options['weight'][0]
|
||||
|
||||
# in diagonale of the corner too
|
||||
elif pos_x in [size - 2, 1] and pos_y in [size - 2, 1]:
|
||||
w[pos_x][pos_y] = int(self.options['weight'][0] * 1.5)
|
||||
|
||||
elif pos_x in [1,size - 2] and pos_y in range(2, size - 2) or \
|
||||
pos_y in [1,size - 2] and pos_x in range(2, size - 2) :
|
||||
w[pos_x][pos_y] = int(self.options['weight'][0] * 0.75)
|
||||
|
||||
# center border : cool but not so...
|
||||
elif (pos_x in center_range and pos_y in [0, size-1]) or \
|
||||
pos_y in center_range and pos_x in [0, size-1]:
|
||||
w[pos_x][pos_y] = int(self.options['weight'][2] // 1.25)
|
||||
|
||||
# Elements on the border
|
||||
elif pos_x in [0, size -1] or pos_y in [0, size -1]:
|
||||
w[pos_x][pos_y] = self.options['weight'][1]
|
||||
w[pos_x][pos_y] = self.options['weight'][2]
|
||||
|
||||
# Element the center
|
||||
elif pos_x in center_range and pos_y in center_range:
|
||||
w[pos_x][pos_y] = self.options['weight'][0]
|
||||
w[pos_x][pos_y] = self.options['weight'][1]
|
||||
|
||||
return w
|
||||
|
||||
|
||||
def show_weights(self):
|
||||
display = "\n |"
|
||||
sep = "\n----"
|
||||
for x in range(self.options['size']):
|
||||
display += "{:^3}|".format(x)
|
||||
display += "\n"
|
||||
sep += '----'
|
||||
display += sep + "\n"
|
||||
for x in range(self.options['size']):
|
||||
display += "{:^3}|".format(str(x))
|
||||
for y in range(self.options['size']):
|
||||
|
@ -79,18 +100,7 @@ class WeightHeuristicEngine(HeuristicEngine):
|
|||
display += "\n"
|
||||
return display
|
||||
|
||||
@staticmethod
|
||||
def show_weight_score(weights, size):
|
||||
display = "\n |"
|
||||
for x in range(size):
|
||||
display += "{:^3}|".format(x)
|
||||
display += "\n"
|
||||
for x in range(size):
|
||||
display += "{:^3}|".format(str(x))
|
||||
for y in range(size):
|
||||
display += "{:^3}|".format(weights[x][y])
|
||||
display += "\n"
|
||||
return display
|
||||
|
||||
class FullHeuristicEngine(WeightHeuristicEngine):
|
||||
|
||||
def get(self, board, player):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue