Jump to content

Chess player: Difference between revisions

(→‎{{libheader|python-chess}}: add some randomness as a tie breaker)
Line 959:
 
The default Unicode board may look wonky and misaligned with certain terminal fonts. To use an ASCII board instead (like in the output shown below), set UNICODE = False. If your terminal uses dark mode, set DARKMODE = True.
 
Increasing RANDFAC, e.g. RANDFAC = 15, creates more variety in computer moves, so that there is less repetition in games and openings.
 
The computer may say some things that allude to the chess game in ''2001: A Space Odyssey'', by the way.
Line 969 ⟶ 971:
UNICODE = True # Print board with Unicode symbols?
DARKMODE = False # Invert symbol colors?
RANDFAC = 1 # Randomness factor
 
board = chess.Board()
Line 1,015 ⟶ 1,018:
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'])
mobility = len(list(board.legal_moves)) + RANDFAC * random.random()
p += mobility / 1000
#print(mymove, yourmove, p)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.