Chess player: Difference between revisions

Content added Content deleted
(→‎{{libheader|python-chess}}: add some randomness as a tie breaker)
Line 964: Line 964:
# Computer plays Black
# Computer plays Black


import sys, chess
import sys, random, chess
from collections import Counter
from collections import Counter


Line 1,015: Line 1,015:
p = (9 * (v['q']-v['Q']) + 5 * (v['r']-v['R']) + 3 * (v['b']-v['B'])
p = (9 * (v['q']-v['Q']) + 5 * (v['r']-v['R']) + 3 * (v['b']-v['B'])
+ 3 * (v['n']-v['N']) + v['p'] - v['P'])
+ 3 * (v['n']-v['N']) + v['p'] - v['P'])
mobility = len(list(board.legal_moves))
mobility = len(list(board.legal_moves)) + random.random()
p += mobility / 1000
p += mobility / 1000
#print(mymove, yourmove, p)
#print(mymove, yourmove, p)