'''
Pretty prints a bitboard to the console given its hex or decimal value.
'''
import sys, textwrap

def print_bb(bb_str):
    # Handle hex/decimal bitboards
    if bb_str.startswith('0x'):
        bb = bin(int(bb_str, 16))
    else:
        bb = bin(int(bb_str, 10))

    # Slice off the '0b'
    bb = bb[2:]

    bb = bb.replace('0', '.')
    bb = bb.replace('1', '#')

    if len(bb) < 64:
        bb = '.' * (64-len(bb)) + bb

    print bb_str
    print '\n'.join([' '.join(line[::-1]) for line in textwrap.wrap(bb, 8)]) + '\n'

if len(sys.argv) == 1:
    for line in sys.stdin.readlines():
        print_bb(line.strip())
else:
    print_bb(sys.argv[1])

@@ -67,16 +67,35 @@
 al value
+ from%0Aargv or stdin
 .%0A'''%0Aim
@@ -114,16 +114,66 @@
 xtwrap%0A%0A
+FULL_BITBOARD = 0xFFFFFFFFFFFFFFFF # 64 set bits%0A%0A
 def prin
@@ -266,47 +266,168 @@
    b
-b = bin(int(bb_str, 16))%0A    else:%0A    
+ase = 16%0A    else:%0A        base = 10%0A%0A    if int(bb_str, base).bit_length() %3E 64:%0A        print 'WARNING: Bit length is greater than 64, taking lowest 64 bits'%0A
     
@@ -451,11 +451,29 @@
 tr, 
-10)
+base) & FULL_BITBOARD
 )%0A%0A 
@@ -569,17 +569,17 @@
 e('1', '
-#
+1
 ')%0A%0A    

Improve showbb.py