예제 #1
0
def execute():
    ai = Player()

    ai.bank = 3000
    ai.limit = 3000

    op = Opponent()

    op.bank = 3000

    participants = [ai, op]

    game = Game()

    game.handout(1)

    pre_chance, _ = game.make_round(participants)

    floop_chance, _ = game.make_round(participants)

    turn_chance, _ = game.make_round(participants)

    game.make_round(participants)

    river_chance, gess = game.make_round(participants)

    return gess, river_chance, turn_chance, floop_chance, pre_chance
예제 #2
0
def spawn_player(board):
    """Deletes the existing player object and spawns a new one on the given board"""
    if State.player:
        State.player.kill()
    if type(board) == EndScreen:
        return
    State.player = Player(board.spawncoords)
    board.spawn_player()
예제 #3
0
파일: test.py 프로젝트: zschneider/pychess
    def test_make_move_pawn_promotion(self):
        """Verifies that making promition moves work appropriately."""
        board, white = Board(), Player(Color.W)
        pawn_white = Pawn(white, [3, 1])  # d7
        board.add_to_board(pawn_white)

        board.make_move(pawn_white, [3, 'Q'])  # promotion at d8 square
        # ensure the new piece is a queen.
        self.assertTrue(isinstance(board.get_piece_at_position([3, 0]), Queen))
예제 #4
0
파일: test.py 프로젝트: zschneider/pychess
 def test_get_piece_at_position(self):
     """Fetch a piece we add to the board, fetch an empty square
     and make sure we get None."""
     board, white = Board(), Player(Color.W)
     pos_white = [4, 6]  # e2
     pawn_white = Pawn(white, pos_white)
     board.add_to_board(pawn_white)
     self.assertTrue(board.get_piece_at_position(pos_white) is pawn_white)
     self.assertTrue(board.get_piece_at_position([1, 1]) is None)
예제 #5
0
파일: test.py 프로젝트: zschneider/pychess
    def test_castling_to_check(self):
        """Ensures that castling is not returned in the King's moved
        list if the King would be castling into check."""
        board, white, black = Board(), Player(Color.W), Player(Color.B)
        king_white = King(white, [4, 7])  # e1
        board.add_to_board(king_white)

        rook_white = Rook(white, [7, 7])  # h1
        board.add_to_board(rook_white)

        castle_move = [6, 7]  # g1

        returned_moves = king_white.get_legal_moves(board, True)
        self.assertTrue(castle_move in returned_moves)

        rook_black = Rook(black, [6, 0])  # g7
        board.add_to_board(rook_black)
        returned_moves = king_white.get_legal_moves(board, True)
        self.assertFalse(castle_move in returned_moves)
예제 #6
0
파일: test.py 프로젝트: zschneider/pychess
    def test_make_move_pawn_double_jump(self):
        """Verifies that making a double jump opens up the piece for
         en passant."""
        board, white = Board(), Player(Color.W)
        pawn_pos_white = [5, 6]  # f2
        pawn_white = Pawn(white, pawn_pos_white)
        board.add_to_board(pawn_white)

        board.make_move(pawn_white, [5, 4])
        self.assertTrue(board.en_passant is pawn_white)
예제 #7
0
파일: test.py 프로젝트: zschneider/pychess
    def test_check_if_empty(self):
        """Make sure check_if_empty returns True at first,
        and then False when we add a piece."""
        board, white = Board(), Player(Color.W)
        pos_white = [4, 6]  # e2
        pawn_white = Pawn(white, pos_white)

        self.assertTrue(board.check_if_empty(pos_white))
        board.add_to_board(pawn_white)
        self.assertFalse(board.check_if_empty(pos_white))
예제 #8
0
class StatisticsTest(unittest.TestCase):

    #Setting up Player
    def setUp(self):
        self.player = Player(200, 200, "imagename", 5)

    #Check coordinates after the method move() (should decrease the y coordinate by dot_size (in this case 5))
    def testCoordinates(self):
        self.player.move()
        self.assertEquals(self.player.x, 200, "Incorrect default x position")
        self.assertEquals(self.player.y, 195, "Incorrect default y position")

    #Check coordinates after left button is pressed and move() method is called
    # (should decrease the y coordinate by dot_size (in this case 5) and x coordinates by dot_size)
    def testCoordinatesAfterLeft(self):
        self.player.left = True
        self.player.move()
        self.assertEquals(self.player.x, 195, "Incorrect x position")
        self.assertEquals(self.player.y, 195, "Incorrect y position")
예제 #9
0
파일: test.py 프로젝트: zschneider/pychess
    def test_remove_a_piece(self):
        """Add a piece, then remove it, and verify space is empty"""
        board, white = Board(), Player(Color.W)
        pos_white = [4, 6]  # e2
        pawn_white = Pawn(white, pos_white)
        board.add_to_board(pawn_white)

        # emptySpace
        self.assertFalse(board.check_if_empty(pos_white))
        board.remove_from_board(pos_white)
        self.assertTrue(board.check_if_empty(pos_white))
예제 #10
0
파일: test.py 프로젝트: zschneider/pychess
    def test_pawn_white_simple(self):
        """Tests that a simple forward move is in the pawn's move list."""
        board, white = Board(), Player(Color.W)
        pawn_white = Pawn(white, [3, 4])  # d4
        pawn_white.first_move = False
        board.add_to_board(pawn_white)

        correct_move = [3, 3]  # d5

        returned_moves = pawn_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 1)
        self.assertTrue(correct_move in returned_moves)
예제 #11
0
파일: test.py 프로젝트: zschneider/pychess
    def test_make_move_simple(self):
        """Makes a simple move, verifies values are appropriately updated."""
        board, white = Board(), Player(Color.W)
        rook_white = Rook(white, [3, 2])  # d6
        board.add_to_board(rook_white)

        board.make_move(rook_white, [5, 2])  # f6
        # ensure make_move updated piece position
        self.assertTrue(rook_white.position == [5, 2])
        # ensure make_move updated board position
        self.assertTrue(board.get_piece_at_position([5, 2]) is rook_white)
        self.assertTrue(board.get_piece_at_position([3, 2]) is None)
예제 #12
0
파일: test.py 프로젝트: zschneider/pychess
    def test_board_with_passed_in_board(self):
        """Tests the creation of a board using a previous
        board's array. Each peice should have a copy created."""
        board, white = Board(), Player(Color.W)
        pawn_white = Pawn(white, [3, 2])  # d6
        board.add_to_board(pawn_white)

        new_board = Board(board.board)
        self.assertEqual(len(new_board.pieces), 1)
        self.assertFalse(new_board.check_if_empty([3, 2]))
        self.assertFalse(new_board.get_piece_at_position([3, 2]) is
                         pawn_white)
예제 #13
0
파일: test.py 프로젝트: zschneider/pychess
    def test_pawn_black_simple(self):
        """Tests that a simple forward move is in the pawn's move list."""
        board, black = Board(), Player(Color.B)
        pawn_black = Pawn(black, [3, 4])  # d4
        pawn_black.first_move = False
        board.add_to_board(pawn_black)

        correct_move = [3, 5]  # d3

        returned_moves = pawn_black.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 1)
        self.assertTrue(correct_move in returned_moves)
예제 #14
0
파일: test.py 프로젝트: zschneider/pychess
    def test_pawn_white_first_move(self):
        """Tests that two moves are available to a new unimpeded pawn."""
        board, white = Board(), Player(Color.W)
        pawn_white = Pawn(white, [3, 6])  # d2
        board.add_to_board(pawn_white)

        correct_move1 = [3, 5]  # d3
        correct_move2 = [3, 4]  # d4

        returned_moves = pawn_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 2)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
예제 #15
0
파일: test.py 프로젝트: zschneider/pychess
    def test_make_move_pawn_simple(self):
        """Makes a simple pawn move, verifies values are appropriately
         updated."""
        board, white = Board(), Player(Color.W)
        pawn_white = Pawn(white, [3, 6])  # d2
        board.add_to_board(pawn_white)

        board.make_move(pawn_white, [3, 4])  # d4
        # ensure make_move updated piece position
        self.assertTrue(pawn_white.position == [3, 4])
        # ensure make_move updated board position
        self.assertTrue(board.get_piece_at_position([3, 4]) is pawn_white)
        self.assertTrue(board.get_piece_at_position([3, 6]) is None)
예제 #16
0
파일: test.py 프로젝트: zschneider/pychess
    def test_pawn_black_first_move(self):
        """Tests that two moves are available to a new unimpeded pawn."""
        board, black = Board(), Player(Color.B)
        pawn_black = Pawn(black, [3, 1])  # d7
        board.add_to_board(pawn_black)

        correct_move1 = [3, 2]  # d6
        correct_move2 = [3, 3]  # d5

        returned_moves = pawn_black.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 2)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
예제 #17
0
파일: test.py 프로젝트: zschneider/pychess
    def test_castling_normal(self):
        """Ensures that castling is properly returned in the King's moved
        list."""
        board, white = Board(), Player(Color.W)
        king_white = King(white, [4, 7])  # e1
        board.add_to_board(king_white)

        rook_white = Rook(white, [7, 7])  # h1
        board.add_to_board(rook_white)

        castle_move = [6, 7]  # g1

        returned_moves = king_white.get_legal_moves(board, True)
        self.assertTrue(castle_move in returned_moves)
예제 #18
0
파일: test.py 프로젝트: zschneider/pychess
    def test_simple(self):
        """Verifies that a knight's returned movelist has the correct
        number of moves and that the boundaries of it's movelist is correct."""
        board, white = Board(), Player(Color.W)
        knight_white = Knight(white, [3, 4])  # d4
        board.add_to_board(knight_white)
        # c6, e6, f5, f3, e2, c2, b3, b5
        correct_move_list = [[2, 2], [4, 2], [5, 3], [5, 5],
                             [4, 6], [2, 6], [1, 5], [1, 3]]

        returned_moves = knight_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 8)
        for move in correct_move_list:
            self.assertTrue(move in returned_moves)
예제 #19
0
파일: test.py 프로젝트: zschneider/pychess
    def test_add_to_board(self):
        """Add a piece, verify the square is taken and that the board's
        pieces list has the piece in it."""
        board, white = Board(), Player(Color.W)
        pos_white = [4, 6]  # e2
        pawn_white = Pawn(white, pos_white)

        board.add_to_board(pawn_white)

        # fetch the piece using xy_conversion
        self.assertTrue(board.board[xy_to_num(pos_white)] is pawn_white)

        # assure that the piece is in the board's pieces list.
        self.assertTrue(pawn_white in board.pieces)
예제 #20
0
파일: test.py 프로젝트: zschneider/pychess
    def test_path_impeded(self):
        """Verifies that a bishop's returned moves stops when encountering
        another of the bishop's owner's pieces."""
        board, white = Board(), Player(Color.W)
        king_white = King(white, [3, 4])  # d4
        board.add_to_board(king_white)

        pawn_white = Pawn(white, [2, 4])  # c4
        board.add_to_board(pawn_white)

        incorrect_move1 = [2, 4]  # c4

        returned_moves = king_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 7)
        self.assertFalse(incorrect_move1 in returned_moves)
예제 #21
0
파일: test.py 프로젝트: zschneider/pychess
    def test_castling_already_moved(self):
        """Ensures that castling is not returned in the King's moved
        list if the King has already moved."""
        board, white = Board(), Player(Color.W)
        king_white = King(white, [4, 7])  # e1
        king_white.first_move = False
        board.add_to_board(king_white)

        rook_white = Rook(white, [7, 7])  # h1
        board.add_to_board(rook_white)

        castle_move = [6, 7]  # g1

        returned_moves = king_white.get_legal_moves(board, True)
        self.assertFalse(castle_move in returned_moves)
예제 #22
0
파일: test.py 프로젝트: zschneider/pychess
    def test_path_impeded(self):
        """Verifies that a rook's returned moves stops when encountering
        another of the rook's owner's pieces."""
        board, white = Board(), Player(Color.W)
        rook_white = Rook(white, [3, 4])  # d4
        board.add_to_board(rook_white)

        pawn_white = Pawn(white, [2, 4])  # c4
        board.add_to_board(pawn_white)

        incorrect_move1 = [2, 4]  # c4

        returned_moves = rook_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 11)
        self.assertTrue(incorrect_move1 not in returned_moves)
예제 #23
0
파일: test.py 프로젝트: zschneider/pychess
    def test_make_move_castle_kingside(self):
        """Ensures kingside castling moving works correctly."""
        board, white = Board(), Player(Color.W)
        king_pos_white = [4, 7]  # e1
        rook_pos_white = [7, 7]  # h1
        king_white = King(white, king_pos_white)
        rook_white = Rook(white, rook_pos_white)
        board.add_to_board(king_white)
        board.add_to_board(rook_white)

        board.make_move(king_white, [6, 7])  # castle to g1
        self.assertTrue(board.get_piece_at_position([6, 7]) is king_white)
        self.assertTrue(board.get_piece_at_position([5, 7]) is rook_white)
        self.assertTrue(board.get_piece_at_position([4, 7]) is None)
        self.assertTrue(board.get_piece_at_position([7, 7]) is None)
예제 #24
0
파일: test.py 프로젝트: zschneider/pychess
    def test_pawn_white_promotion(self):
        """Tests that the four promotion moves are available to a promoting
         pawn."""
        board, white = Board(), Player(Color.W)
        pawn_white = Pawn(white, [3, 1])  # d7
        board.add_to_board(pawn_white)

        correct_move1 = [3, "Q"]  # d8
        correct_move2 = [3, "N"]  # d8
        correct_move3 = [3, "B"]  # d8
        correct_move4 = [3, "R"]  # d8

        returned_moves = pawn_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 4)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
        self.assertTrue(correct_move3 in returned_moves)
        self.assertTrue(correct_move4 in returned_moves)
예제 #25
0
파일: test.py 프로젝트: zschneider/pychess
    def test_simple(self):
        """Verifies that a bishops's returned movelist has the correct
        number of moves and that the boundaries of it's movelist is correct."""
        board, white = Board(), Player(Color.W)
        bishop_white = Bishop(white, [3, 4])  # d4
        board.add_to_board(bishop_white)

        correct_move1 = [7, 0]  # h8
        correct_move2 = [6, 7]  # g1
        correct_move3 = [0, 1]  # a7
        correct_move4 = [0, 7]  # a1

        returned_moves = bishop_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 13)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
        self.assertTrue(correct_move3 in returned_moves)
        self.assertTrue(correct_move4 in returned_moves)
예제 #26
0
파일: test.py 프로젝트: zschneider/pychess
    def test_simple(self):
        """Verifies that a rook's returned move list has the correct
        number of moves and that the boundaries of it's movelist is correct."""
        board, white = Board(), Player(Color.W)
        rook_white = Rook(white, [3, 4])  # d4
        board.add_to_board(rook_white)

        correct_move1 = [0, 4]  # a4
        correct_move2 = [7, 4]  # h4
        correct_move3 = [3, 0]  # d8
        correct_move4 = [3, 7]  # d1

        returned_moves = rook_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 14)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
        self.assertTrue(correct_move3 in returned_moves)
        self.assertTrue(correct_move4 in returned_moves)
예제 #27
0
파일: test.py 프로젝트: zschneider/pychess
    def test_pawn_black_promotion(self):
        """Tests that the four promotion moves are available to a promoting
         pawn."""
        board, black = Board(), Player(Color.B)
        pawn_black = Pawn(black, [3, 6])  # d2
        board.add_to_board(pawn_black)

        correct_move1 = [3, "Q"]  # d1
        correct_move2 = [3, "N"]  # d1
        correct_move3 = [3, "B"]  # d1
        correct_move4 = [3, "R"]  # d1

        returned_moves = pawn_black.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 4)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
        self.assertTrue(correct_move3 in returned_moves)
        self.assertTrue(correct_move4 in returned_moves)
예제 #28
0
파일: test.py 프로젝트: zschneider/pychess
    def test_get_all_legal_moves_simple(self):
        """Simply verify that getting the legal moves of two pieces
        sum to the returned value of get_all_legal_moves."""
        board, white = Board(), Player(Color.W)
        pos_white = [4, 6]  # e2
        pawn_white = Pawn(white, pos_white)
        board.add_to_board(pawn_white)

        pos_white2 = [3, 3]  # d5
        rook_white = Rook(white, pos_white2)
        board.add_to_board(rook_white)

        combined_positions = []
        for move in pawn_white.get_legal_moves(board, True):
            combined_positions += [pawn_white, move],
        for move in rook_white.get_legal_moves(board, True):
            combined_positions += [rook_white, move],

        self.assertEqual(board.get_all_legal_moves(white), combined_positions)
예제 #29
0
파일: test.py 프로젝트: zschneider/pychess
    def test_simple(self):
        """Verifies that a king's returned movelist has the correct
        number of moves and that the boundaries of it's movelist is correct."""
        board, white = Board(), Player(Color.W)
        king_white = King(white, [3, 4])  # d4
        board.add_to_board(king_white)

        correct_move_list = [[3, 5]]  # d3
        correct_move_list += [2, 5],  # c3
        correct_move_list += [4, 5],  # e3
        correct_move_list += [4, 4],  # e4
        correct_move_list += [2, 4],  # c4
        correct_move_list += [4, 3],  # e5
        correct_move_list += [3, 3],  # d5
        correct_move_list += [2, 3],  # c5

        returned_moves = king_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 8)
        for move in correct_move_list:
            self.assertTrue(move in returned_moves)
예제 #30
0
파일: test.py 프로젝트: zschneider/pychess
    def test_simple(self):
        """Verifies that a queen's returned movelist has the correct
        number of moves and that the boundaries of it's movelist is correct."""
        board, white = Board(), Player(Color.W)
        queen_white = Queen(white, [3, 4])  # d4
        board.add_to_board(queen_white)

        correct_move_list = [[7, 0]]  # h8
        correct_move_list += [6, 7],  # g1
        correct_move_list += [0, 1],  # a7
        correct_move_list += [0, 7],  # a1
        correct_move_list += [0, 4],  # a4
        correct_move_list += [7, 4],  # h4
        correct_move_list += [3, 0],  # d8
        correct_move_list += [3, 7],  # d1

        returned_moves = queen_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 27)
        for move in correct_move_list:
            self.assertTrue(move in returned_moves)
예제 #31
0
def test_shoot():
    weapon = Weapon(10, 0.5)
    grid = None
    person = Player(0, 0, 0, None, "")
    assert weapon.shoot_interval == 0.5
    assert weapon.is_shooting == False
    assert weapon.shoot_animation.is_animating == False
    assert weapon.shoot_animation.factor == 0
    weapon.update(0.1, person, grid)
    assert weapon.is_shooting == False
    assert weapon.shoot_animation.is_animating == False
    assert weapon.shoot_animation.factor == 0
    weapon.is_shooting = True
    assert weapon.is_shooting == True
    assert weapon.shoot_animation.is_animating == False
    assert weapon.shoot_animation.factor == 0
    weapon.update(0.1, person, grid)
    assert weapon.is_shooting == True
    assert weapon.shoot_animation.is_animating == True
    assert weapon.shoot_animation.factor == 0.2
    weapon.update(0.1, person, grid)
    assert weapon.is_shooting == True
    assert weapon.shoot_animation.is_animating == True
    assert weapon.shoot_animation.factor == 0.4
    weapon.update(0.3, person, grid)
    assert weapon.is_shooting == True
    assert weapon.shoot_animation.is_animating == False
    assert weapon.shoot_animation.factor == 1
    weapon.update(0.3, person, grid)
    assert weapon.is_shooting == True
    assert weapon.shoot_animation.is_animating == True
    assert weapon.shoot_animation.factor == 0.6
    weapon.is_shooting = False
    weapon.update(0.3, person, grid)
    assert weapon.is_shooting == False
    assert weapon.shoot_animation.is_animating == False
    assert weapon.shoot_animation.factor == 1
    weapon.update(0.3, person, grid)
    assert weapon.is_shooting == False
    assert weapon.shoot_animation.is_animating == False
    assert weapon.shoot_animation.factor == 0
예제 #32
0
from engine import Inventory
from engine import Location
from engine import Player
from engine import GamePlay



   
m_player = Player(541)
#g_inventory = Inventory()
game_play = GamePlay()

game_play.loadGame()
#print (game_play.get_game_map())
m_location = Location(game_play.get_game_map())

while True:
    m_location.display_location(m_player.get_location())
    game_play.display_navigation(m_player.get_location())
    
    commandx = raw_input('\n>')
    is_valid_cmd = game_play.is_nav_valid(m_player.get_location(), commandx)
    if is_valid_cmd == False:
        print 'You cannot do that'
        
    if is_valid_cmd == True:
        if commandx == 'n':
            m_player.set_location(m_player.get_location()-25) 
        elif commandx == 's':
            m_player.set_location(m_player.get_location()+25)
        elif commandx == 'e':
예제 #33
0
파일: game.py 프로젝트: robsonfr/atac-py
 def draw(self, target):
     Player.draw(self, target)
     if self.tiro.disparando: self.tiro.draw(target, self.sprite.x + 14)
예제 #34
0
 def setUp(self):
     self.player = Player(200, 200, "imagename", 5)