Ejemplo n.º 1
0
    def load_myformat(self, filename):
        filetext=file(filename, 'r')
        go_lines=filetext.readlines()
        
        header=go_lines[0:6]

        self.title=header[1]
        self.game_commentary=header[3]
        self.setsize(header[5])
        
        movelines=go_lines[7:]
#        go_lines=str.splitlines(filetext)
#        go_lines=filetext.splitlines()
        #
        # TODO add the part to read the header and board size
        #
        for line in movelines:
            content=line.split(None,2)
            
            number=content[0]
            color=content[1]
            pos=Vector()
#            pos.fromString3(content[2].strip(" "))
            pos.fromString(content[2].strip(" "))
            next_move=stone.Stone(number,color,pos)
            self.moves.append(next_move)
Ejemplo n.º 2
0
@author: ludl
"""

# Test of vector
from vector import Vector
import pdb

print 'test vector constructor'
x=Vector()
print 'x ', x
print 'x.x is ', x.x

print 'test vector from String'
a='[1, 2, 3, 4, 5, 6, 7, 8]'
x.fromString(a)
print 'a =',a
print 'x =',x

b='[3,8,6]'
z=Vector().fromString(b)

print 'b, z are :'
print b, z

c='[3, 8, 6]'
z1=Vector()

print 'z1 is :'
print z1