def imageToDamageArray(image_array):
dmg = [[],[]]
lastdamage = [0,0]
for player in range(2):
for time in range(len(image_array[1])):
three_cell1 = CLF.predict([hog(image_array[player][time][4:39,2:29].reshape((27, 35)),orientations=9, pixels_per_cell=(9, 7), cells_per_block=(1, 1), visualise=False)])[0]
three_cell2 = CLF.predict([hog(image_array[player][time][4:39,23:50].reshape((27, 35)),orientations=9, pixels_per_cell=(9, 7), cells_per_block=(1, 1), visualise=False)])[0]
three_cell3 = CLF.predict([hog(image_array[player][time][4:39,48:75].reshape((27, 35)),orientations=9, pixels_per_cell=(9, 7), cells_per_block=(1, 1), visualise=False)])[0]
two_cell1 = CLF.predict([hog(image_array[player][time][4:39,13:40].reshape((27, 35)),orientations=9, pixels_per_cell=(9, 7), cells_per_block=(1, 1), visualise=False)])[0]
two_cell2 = CLF.predict([hog(image_array[player][time][4:39,37:64].reshape((27, 35)),orientations=9, pixels_per_cell=(9, 7), cells_per_block=(1, 1), visualise=False)])[0]
if three_cell1 != "-" and three_cell2 != "-" and three_cell3 != "-":
if int(three_cell1)*100+int(three_cell2)*10-lastdamage[player]>50:
#print(three_cell1,three_cell2,three_cell3)
#print(two_cell1,two_cell2)
if two_cell1 != "-" and two_cell2 != "-" and two_cell1 != 0:
dmg[player].append(10*int(two_cell1)+int(two_cell2))
lastdamage[player]=dmg[player][-1]
else:
dmg[player].append("-")
else:
dmg[player].append(100*int(three_cell1)+10*int(three_cell2)+int(three_cell3))
lastdamage[player]=dmg[player][-1]
elif two_cell1 != "-" and two_cell2 != "-" and two_cell1!= 0:
dmg[player].append(10*int(two_cell1)+int(two_cell2))
lastdamage[player]=dmg[player][-1]
elif three_cell1 == "-" and three_cell2 != "-" and three_cell3 == "-":
dmg[player].append(int(three_cell2))
else:
dmg[player].append("-")
return dmg
评论列表
文章目录