...sono alle prese con la programmazione di un chess engine in python.

premesso che sono un principiante, ho un problema.

voglio rappresentare la scacchiera tramite le bitboard, e sto utilizzando gli operatori:

and     & (bitwise and)
or     | (bitwise or)
xor     ^ (bitwise xor)
not     ~ (bitwise not)
ishft(a, 1)     a << 1 (left shift)
ishft(a,-1)     a >> 1 (right shift)

facendo delle prove ottengo questi risultati con python:

0110 & 1010 = 1000000

0110 | 1010 = 1111111010

0110 ^ 1010 = 1110111010

0010 << 100000

in realtà io mi aspetterei che:


0110 & 1010 = 0010

0110 | 1010 = 1110

0110 ^ 1010 = 1100

0010 << 1000

dove sbaglio??

ciao,

Alfredo

_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a