Ejemplo n.º 1
0
def __king_test():
    g = TokenGrid( 10, 10 )
    assert( King().isValid( g, (1,1 ) ) ) 
    assert( g.placeToken( King(), (1, 1) ) ) 
    assert( g.placeToken( King(), (5, 5) ) )
    assert( not g.placeToken( King(), (5, 6) ) )
    assert( not g.placeToken( King(), (6, 6) ) )
    assert( not g.placeToken( King(), (0, 0) ) )
    assert( g.placeToken( King(), (3,3) ) )
Ejemplo n.º 2
0
def __glob_test():
    g = TokenGrid( 10, 10 )

    assert( g.placeToken( Glob(), (5, 5) ) )
    assert( g.placeToken( Glob(), (5, 6) ) )
    assert( g.placeToken( Glob(), (5, 7) ) )
    assert( g.placeToken( Glob(), (6, 8) ) )
    assert( not g.placeToken( Glob(), (1,1) ) )
    assert( g.frequencyHistogram()['Glob'] == 4 ) 
Ejemplo n.º 3
0
def __state_test():
    g = TokenGrid(10, 10)
    
    assert( g.placeToken( State(), (3,3) ) )
    
    assert( not State().isValid( g, (3, 1 ) ) )
    assert( not State().isValid( g, (3, 7 ) ) )
    assert( not State().isValid( g, (7, 3 ) ) )
    assert( not State().isValid( g, (2, 3 ) ) )
    assert( State().isValid( g, (5, 5) ) )
Ejemplo n.º 4
0
def __checker_test():
    g = TokenGrid(10, 10)

    assert( not g.placeToken( Checker(), (0, 0 ) ) )
    assert( g.placeToken( Checker(), (0, 1 ) ) )
    assert( not Checker().isValid( g, (0, 2) ))
    assert(  Checker().isValid( g, (0, 3) ))
    assert( not Checker().isValid( g, (0, 4) ))
    assert(  Checker().isValid( g, (1, 0) ))
    assert( not Checker().isValid( g, (1, 1) ))
    assert(  Checker().isValid( g, (1, 2) ))
    assert( not Checker().isValid( g, (1, 3) ))
    assert(  Checker().isValid( g, (1, 4) ))
Ejemplo n.º 5
0
def __knight_test():
    g = TokenGrid(10, 10)
    
    assert( g.placeToken( Knight(), (5, 5) ) ) 
    
    assert( Knight().isValid( g, (7, 6 ) ) )
    assert( Knight().isValid( g, (6, 7 ) ) )
    assert( Knight().isValid( g, (4, 7 ) ) )
    assert( Knight().isValid( g, (7, 4 ) ) )
    assert( not Knight().isValid( g, (3, 5) ) )

    g.setToken( Knight(), (9, 9 )  ) 
    assert( Knight().isValid( g, (7, 8) ) )
    assert( not Knight().isValid( g, (7, 7) ) )
Ejemplo n.º 6
0
def __rook_test():
    g = TokenGrid(10, 10)
    
    assert( g.placeToken( Rook(), (3,3) ) )
    
    assert( Rook().isValid( g, (3, 1 ) ) )
    assert( Rook().isValid( g, (3, 7 ) ) )
    assert( Rook().isValid( g, (7, 3 ) ) )
    assert( Rook().isValid( g, (2, 3 ) ) )
    assert( not Rook().isValid( g, (5, 5) ) )

    #Nothing can be placed next to a king.     
    assert( g.placeToken( King(), (3,8) ) )
    assert( not Rook().isValid( g, (3,9) ) )
Ejemplo n.º 7
0
def __pawn_test():
    g = TokenGrid(10, 10)
 
    assert( g.placeToken( Knight(), (5,5) ) ) 
    
    assert( Pawn().isValid( g, (5, 6 ) ) )
    assert( Pawn().isValid( g, (6, 5 ) ) )
    assert( Pawn().isValid( g, (4, 5 ) ) )
    assert( Pawn().isValid( g, (5, 4 ) ) )

    assert( g.placeToken( Pawn(), (6,5 ) ) )
    assert( Pawn().isValid( g, (7, 6 ) ) )
    assert( Pawn().isValid( g, (5, 4 ) ) )
    assert( Pawn().isValid( g, (7, 4 ) ) )
    assert( Pawn().isValid( g, (5, 6 ) ) )
    assert( not Pawn().isValid( g, ( 6, 6 ) ) )
Ejemplo n.º 8
0
def __wallflower_test():
    g = TokenGrid( 10, 15 )
    assert( not g.placeToken( Wallflower(), (5, 5) ) ) 
    assert( g.placeToken( Wallflower(), (0, 5) ) ) 
    assert( g.placeToken( Wallflower(), (0, 0) ) ) 
    assert( g.placeToken( Wallflower(), (5, 0) ) ) 
    assert( g.placeToken( Wallflower(), (5, 14) ) ) 
    assert( g.placeToken( Wallflower(), (9, 5) ) ) 
    assert( g.placeToken( Wallflower(), (9, 14) ) ) 
Ejemplo n.º 9
0
def __crowd_test():
    g = TokenGrid(10, 10)
    
    assert( g.placeToken( Rook(), (3,3) ) )
    assert( g.placeToken( Rook(), (3,4) ) )
    assert( g.placeToken( Rook(), (4,3) ) )
    assert( g.placeToken( Rook(), (5,3) ) )
    assert( g.placeToken( Rook(), (5,4) ) ) 
    
    assert( g.placeToken( Crowd(), (4,4) ) )
    assert( not g.placeToken( Crowd(), (6,6) ) )
Ejemplo n.º 10
0
def __joker_test():
    g = TokenGrid( 100, 10 )
    
    for point in g.points():
        g.placeToken( Joker(), point ) 

    counter = 0 
    for point in g.points():
        if g.isAnyTokenAtPoint( point ): 
            counter += 1
    assert( counter > 0 and counter < 1000 )
Ejemplo n.º 11
0
def __bomb_test():
    g = TokenGrid( 10, 10 )

    assert( g.placeToken( Rook(), (4,6) ) )
    assert( g.placeToken( Rook(), (5,6) ) )
    assert( g.placeToken( Rook(), (6,6) ) )
    assert( g.placeToken( Rook(), (4,5) ) )
    assert( g.placeToken( Rook(), (6,5) ) )
    assert( g.placeToken( Rook(), (4,4) ) )
    assert( g.placeToken( Rook(), (5,4) ) )
    assert( g.placeToken( Rook(), (6,4) ) )
    
    assert( g.placeToken( Bomb(), (5,5) ) ) 

    assert( not Rook().existsOnTheBoard( g ) )
Ejemplo n.º 12
0
def __assassin_test():
    g = TokenGrid(10, 10)
    
    assert( g.placeToken( Assassin(), (3,3) ) )
    assert( g.placeToken( Assassin(), (5,5) ) )
    assert( g.frequencyHistogram()[InvisibleToken().name()] == 2 ) 
Ejemplo n.º 13
0
def __church_test():
    g = TokenGrid( 10, 10 )
    assert( g.placeToken( Church(), (5, 5) ) )
    assert( not g.placeToken( Church(), (8, 8) ) )
    assert( not g.placeToken( Church(), (3, 7) ) )
    assert( g.placeToken( Church(), (1, 2 ) ) ) 
Ejemplo n.º 14
0
def __brick_test():
    g = TokenGrid( 10, 10 )
    assert( g.placeToken( Brick(), (5, 5) ) ) 
    assert( g.frequencyHistogram()[Brick().name()] == 9 ) 
Ejemplo n.º 15
0
def __parasite_test():
    g = TokenGrid( 10, 10 )
    assert( g.placeToken( Bishop(), (5, 5) ) )
    assert( g.placeToken( Parasite(), (5, 6) ) )
    assert( not g.placeToken( Parasite(), (6, 6) ) )
Ejemplo n.º 16
0
def __bishop_test():
    g = TokenGrid( 10, 10 )
    assert( g.placeToken( Bishop(), (5, 5) ) )
    assert( g.placeToken( Bishop(), (8, 8) ) )
    assert( g.placeToken( Bishop(), (3, 7) ) )
    assert( not g.placeToken( Bishop(), (1, 2 ) ) )