Exemple #1
0
    def compete(self, b1, b2):
        while True:
            if Tetris.mode == 'auto':
                time.sleep(1)
            else:
                input()

            Board.create_piece()
            l1 = b1.get_attack_points()
            l2 = b2.get_attack_points()

            print('l1: %d; l2: %d' % (l1, l2))
            b1.get_attacked(l2)
            b2.get_attacked(l1)

            s1, _, _ = b1.get_board_state()
            s2, _, _ = b2.get_board_state()

            self.print_game(s1, s2)

            if b1.defeated() or b2.defeated():
                break

        if b1.defeated() and not b2.defeated():
            print('Player2 won')
        elif b2.defeated() and not b1.defeated():
            print('Player1 won')
        else:
            print('Tie')
Exemple #2
0
    def initialize_board(self, board_size, players_list):

        self.__game_dao.set_ladders()
        self.__game_dao.set_snakes()
        self.__board = Board(board_size)

        for player in players_list:
            self.__game_dao.add_player(player)
Exemple #3
0
    def _test_from_files(self, in_file_path, out_file_path):
        with open(in_file_path) as f:
            b_in = Board.from_file(f)
        with open(out_file_path) as f:
            b_out = Board.from_file(f)

        solve_board(b_in)

        self.assertEquals(b_in, b_out, "boards don't match (in=%s, out=%s)" % (in_file_path, out_file_path))
Exemple #4
0
    def build(self, testMode=True):
        """
        Initiate objects and views.
        """
        ''' init game objects '''
        self.deck = Deck()
        self.evaluator = Evaluator()

        self.player = []
        self.player.append(Player(0))
        self.player.append(Player(1))
        # board stands for public cards on board
        self.board = Board()

        # In test mode, both player select right-most cards for the turn automatically
        self.testMode = testMode
        ''' create view objects '''
        # Scatter that can be rotated to display players
        scatter_bot = ScatterLayout(do_rotation=False,
                                    do_translation=False,
                                    do_scale=False,
                                    size_hint=(1, 1),
                                    pos_hint={
                                        'x': 0,
                                        'y': 0
                                    },
                                    rotation=0)
        # For player on top, the widget rotates 180 degree
        scatter_top = ScatterLayout(do_rotation=False,
                                    do_translation=False,
                                    do_scale=False,
                                    size_hint=(1, 1),
                                    pos_hint={
                                        'x': 0,
                                        'y': 0
                                    },
                                    rotation=180)

        box = PlayerDeck()
        box2 = PlayerDeck()
        publicArea = PublicArea()
        box.build(self, "player1", 0, self.testMode)
        box2.build(self, "player2", 1, self.testMode)
        publicArea.build()

        scatter_bot.add_widget(box)
        scatter_top.add_widget(box2)

        self.add_widget(scatter_bot)
        self.add_widget(scatter_top)
        self.add_widget(publicArea)

        # register id of view objects
        self.ids[box.id] = box
        self.ids[box2.id] = box2
        self.ids[publicArea.id] = publicArea
	def load(I, path):
		"""
		Reset the board and load history from given path.
		"""
		with open(path, mode='r', encoding='utf-8') as f:
			history = json.load(f, object_hook=Turn.from_json)
		board = Board()
		for turn in history:
			for src, dst in turn.moves:
				board = board.move(src, dst)
		I.board = board
		I.history = history
Exemple #6
0
 def load(I, path):
     """
     Reset the board and load history from given path.
     """
     with open(path, mode='r', encoding='utf-8') as f:
         history = json.load(f, object_hook=Turn.from_json)
     board = Board()
     for turn in history:
         for src, dst in turn.moves:
             board = board.move(src, dst)
     I.board = board
     I.history = history
Exemple #7
0
    def get_state(self):
        b1 = self.board1
        b2 = self.board2
        l1 = b1.get_attack_points()
        l2 = b2.get_attack_points()

        Board.create_piece()
        b1.get_attacked(l2)
        b2.get_attacked(l1)
        s1, _, _ = b1.get_board_state()
        s2, _, _ = b2.get_board_state()

        return self.reverse_row(s1), self.reverse_row(s2)
Exemple #8
0
 def post(self):
     tName = self.request.get("taskName").lower().strip()
     board_url = self.request.get("board_url")
     keyconcat = tName+'/'+self.request.get("key_board")
     key_name = ndb.Key(Task, keyconcat)
     task = key_name.get()
     if task:
         task.dueDate = datetime.strptime(self.request.get("dueDate"), '%Y-%m-%d')
         task.description = self.request.get("description")
         task.assignee = self.request.get("assignee")
         if task.status == self.request.get("status"):
             task.completionDate = task.completionDate
         else:
             if self.request.get("status") == "completed":
                 now = datetime.now() #using utc time
                 task.completionDate = now
             elif self.request.get("status") == "not completed":
                 task.completionDate = None
         task.status = self.request.get("status")
         task.put()
         boardCheck = Board.get_by_id(int(self.request.get("key_board")))
         for i in range(0,len(boardCheck.tasks)):
             if str(boardCheck.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                 boardCheck.tasks[i].status = task.status
                 boardCheck.tasks[i].description = task.description
                 boardCheck.tasks[i].assignee = task.assignee
                 boardCheck.tasks[i].dueDate = task.dueDate
                 boardCheck.tasks[i].completionDate = task.completionDate
         boardCheck.put()
         self.add_message('Task updated successfully', 'success')
     else:
         self.add_message('Task not found.', 'danger')
     self.redirect(str(board_url), abort=False)
Exemple #9
0
    def post(self):
        user = users.get_current_user()
        board_url = self.request.get("board_url")
        boardName = self.request.get("boardName").strip()
        userToRem = self.request.get("userRemove").strip()
        board = Board.get_by_id(int(self.request.get("key_board")))
        if board:
            board.boardTitle = boardName
            if userToRem != "" and user.email() == board.owner:
                key_user = ndb.Key(User, userToRem)
                user_details = key_user.get()
                if user_details:
                    if user_details.boards != None:
                        del user_details.boards[str(self.request.get("key_board"))]
                        user_details.put()

                for i in range(0,len(board.users)):
                    if str(board.users[i].email.lower()).strip() == userToRem.lower():
                        board.users.pop(i)
                        break

            for i in range(0,len(board.tasks)):
                if str(board.tasks[i].assignee.lower()).strip() == userToRem.lower().strip():
                    board.tasks[i].assignee = 'Unassigned'

            board.put()
            self.add_message('Board updated successfully', 'success')
        else:
            self.add_message("Board doesn't exist", 'success')

        self.redirect(str(board_url), abort=False)
Exemple #10
0
 def __init__(self):
     self.boards = {
         # player 1, 2
         1: {
             # boards 1 -> ship board
             # 2-> attack board
             1: Board(),
             2: Board()
         },
         2: {
             # boards 1 -> ship board
             # 2-> attack board
             1: Board(),
             2: Board()
         }
     }
Exemple #11
0
 def __init__(self):
     board = Board([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
     super().__init__(players=[
         HumanPlayer(name="Mikolaj", symbol='x'),
         HumanPlayer(name="Arek", symbol='o')
     ],
                      state=MemoryState(board, moves=['x', 'o']))
def delete_board(id):
    board = Board.get_or_none(Board.id == id)
    if not board:
        return jsonify({'message': 'ERROR', 'result': None}), 404

    board.delete_instance()
    return jsonify({'message': 'OK', 'result': None})
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("Drunkard walk")
        self.resizable(False, False)
        self.controller = EventController(self)

        board = Board()

        self.controller.set_board(board)

        main_frame = ttk.Frame(self, padding=(20, 10, 10, 10))
        main_frame.pack(fill="both", expand=True)
        interface_frame = InterfaceFrame(main_frame,
                                         self.controller,
                                         padding=(20, 10, 10, 10))
        interface_frame.pack(side="left", fill="x")
        board_frame = BoardFrame(main_frame,
                                 board,
                                 self.controller,
                                 padding=(10, 10, 10, 10))
        board_frame.pack(side="left", fill="both")

        output_frame = OutputFrame(self,
                                   self.controller,
                                   padding=(20, 10, 20, 10))
        output_frame.pack(side="bottom", fill="both", expand=True)
Exemple #14
0
    def post(self):
        tName = self.request.get("name")
        board_url = self.request.get("board_url")
        checkbovVal = self.request.get("checkbovVal")
        keyconcat = tName.lower().strip()+'/'+self.request.get("key_board")
        key_name = ndb.Key(Task, keyconcat)
        taskStatus = key_name.get()
        if taskStatus:
            if checkbovVal == "true":
                taskStatus.status = "completed"
                now = datetime.now() #using utc time
                taskStatus.completionDate = now
            elif checkbovVal == "false":
                taskStatus.status = "not completed"
                taskStatus.completionDate = None

            taskStatus.put()
            boardCheck = Board.get_by_id(int(self.request.get("key_board")))

            for i in range(0,len(boardCheck.tasks)):
                if str(boardCheck.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                    boardCheck.tasks[i].status = taskStatus.status
                    boardCheck.tasks[i].completionDate = taskStatus.completionDate
            boardCheck.put()
            self.add_message('Task status updated successfully', 'success')
        else:
            self.add_message('Task not found.', 'danger')
        self.redirect(str(board_url), abort=False)
 def __init__(self):
     board = Board([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
     super().__init__(players=[
         HumanPlayer(name="Humek", symbol='x'),
         ComputerPlayer(name="Comp", symbol='o')
     ],
                      state=MemoryState(board, moves=['x', 'o']))
Exemple #16
0
class GameService:
    def __init__(self):
        self.__game_dao = GameDao()
        self.__board = 0
        self.__dice = Dice()

    def initialize_board(self, board_size, players_list):

        self.__game_dao.set_ladders()
        self.__game_dao.set_snakes()
        self.__board = Board(board_size)

        for player in players_list:
            self.__game_dao.add_player(player)

    def play_game(self):

        while True:

            dice_num = self.__dice.roll_dice()
            player = self.__game_dao.get_player()

            print(f'{player.get_name()} turn, dice number: {dice_num}')
            position = player.get_position()
            new_position = dice_num + position
            if new_position > self.__board.get_size():
                self.__game_dao.add_player(player)
                continue
            if new_position == self.__board.get_size():
                print(f'{player.get_name()} wins')
                player.set_is_won(True)
                break

            if self.__game_dao.get_snakes(new_position) != None:
                new_position = self.__game_dao.get_snakes(new_position)
                print(f'Snake bits, new position is {new_position}')
            elif self.__game_dao.get_ladders(new_position) != None:
                new_position = self.__game_dao.get_ladders(new_position)
                print(f'Ladder Climbed, new position is {new_position}')
            else:
                print(f'new position is {new_position}')

            player.set_position(new_position)
            self.__game_dao.add_player(player)
Exemple #17
0
def render(entry, settings):

    board = Board()
    board.fromAlgebraic(entry["algebraic"])

    html = pdf.ExportDocument.header(entry, settings['lang'])
    html += board_to_html(board, settings['diagram_font'])
    html += entry['stipulation'] + ' ' + board.getPiecesCount() + "<br/>\n"
    html += pdf.ExportDocument.solver(entry, settings['lang']) + "<br/>\n"
    html += pdf.ExportDocument.legend(board) + "<br/><br/>\n"
    if 'solution' in entry:
        html += solution_to_html(entry['solution'], settings['inline_font'])
    if 'keywords' in entry:
        html += "<br/>\n" + ', '.join(entry['keywords']) + "<br/>\n"
    if 'comments' in entry:
        html += "<br/>\n" + "<br/>\n".join(entry['comments']) + "<br/>\n"
    html += "<br/><br/>\n"

    return html
Exemple #18
0
def parse_file(file_name):

    tiles = []
    with open(file_name) as f:
        num_lines = int(f.readline())

        for i in range(num_lines):
            line = [int(tile) for tile in f.readline().split(' ')]
            tiles.append(line)

    return Board(tiles)
def optimum_move(board: Board, opponent_move, player_move, cur_move):
    available_spots = board.empty_fields()
    if board.winning(opponent_move):
        return Move(None, -10)  # when computer loses -> move.score = -10
    elif board.winning(player_move):
        return Move(None, 10)  # when computer wins -> move.score = 10
    elif len(available_spots) == 0:
        return Move(None, 0)  # when there is no more fields -> tie

    moves = []

    for i in range(0, len(available_spots)):
        index = available_spots[i]
        board = board.put(available_spots[i][0], available_spots[i][1],
                          cur_move)  # simulation
        if cur_move == player_move:
            result = optimum_move(board, opponent_move, player_move,
                                  opponent_move)
        else:
            result = optimum_move(board, opponent_move, player_move,
                                  player_move)
        board = board.put(available_spots[i][0], available_spots[i][1],
                          0)  # back to previous state
        moves.append(Move(
            index, result.score))  # creating a list of potential best moves

    # choosing best move for current player
    if cur_move == player_move:
        best_score = -inf
        for i in range(0, len(moves)):
            if moves[i].score > best_score:
                best_score = moves[i].score
                best_move = i
    else:
        best_score = inf
        for i in range(0, len(moves)):
            if moves[i].score < best_score:
                best_score = moves[i].score
                best_move = i

    return moves[best_move]
Exemple #20
0
 def board(self):
     threshold = GlobalProperties.histeresis
     board = sr.get_state()
     r = 0  # repeat - how many times was this state
     while not _is_valid(board, self.board_size) or r < threshold:
         pboard = board
         board = sr.get_state()
         if diff(pboard, board)[0] == 0:
             r += 1
         else:
             r = 0
     return Board(board)
def update_board(id):
    board = Board.get_or_none(Board.id == id)
    if not board:
        return jsonify({'message': 'ERROR', 'result': None}), 404

    board.name = request.json.get('name')
    board.description = request.json.get('description')
    board.image = request.json.get('image')
    board.linkedin = request.json.get('linkedin')
    board.position = request.json.get('position')
    board.save()

    return jsonify({'message': 'OK', 'result': board})
Exemple #22
0
def main():
    if not 2 <= len(sys.argv) <= 3:
        usage()
        sys.exit(-1)

    with open(sys.argv[1]) as f:
        b_in = Board.from_file(f)

    if len(sys.argv) == 3:
        with open(sys.argv[2]) as f:
            b_exp = Board.from_file(f)
    else:
        b_exp = None

    print '\nInput:\n\n', b_in, '\n'

    solve_board(b_in)

    print '\nSolution:\n\n', b_in, '\n'

    if b_exp:
        assert b_in == b_exp, 'board does not match expected result'
Exemple #23
0
    def post(self):
        user = users.get_current_user()
        if user:
            key_user = ndb.Key(User, user.email())
            user_details = key_user.get()
            board = Board()
            board.boardTitle = self.request.get('title').strip()
            board.owner = user.email()
            board.users.append(user_details)
            boardKey = board.put()
            boardKeyId = boardKey.get().key.id()
            if user_details:
                if user_details.boards: key_dict = user_details.boards
                else: key_dict = {}
                key_dict[boardKeyId] = boardKey.urlsafe()
                userModel = User(key=key_user, boards=key_dict, email=user.email())
                userModel.put()

            self.add_message('Task Board created successfully.', 'success')
            self.redirect('/boards', abort=False)
            return
        else:
            self.redirect('/', abort=False)
def play_game(ngames=100):
    verbose = ngames == 1

    cost_of_hut = 0.05
    cost_of_station = 3
    ntrees = 9
    ngardens = 3
    ncurses = 3
    """
    IDEAL GAME SCENARIOS:
        selfish vs. selfish: RARELY WIN
        selfish vs. default: MOSTLY WIN -> SELFISH
        selfish vs. generous: ALWAYS WIN -> SELFISH
        generous vs. generous: RARELY WIN
    """
    player_types = ["reasonable", "reasonable"]  #
    # player_types = ["default", "generous"] #
    # player_types = ["super-selfish", "super-selfish"] #
    # player_types = ["selfish", "reasonable"] #
    # player_types = ["selfish", "selfish"] #
    # player_types = ["reasonable", "selfish"] #
    # player_types = ["selfish", "super-selfish"] #
    # player_types = ["super-selfish", "reasonable"] #
    # player_types = ["super-selfish", "generous"] #
    # player_types = ["selfish", "default"] # 8/10, all S
    # player_types = ["selfish", "generous"] # 5/10, all S
    # player_types = ["generous", "generous"] # 0/10
    # player_types = ["reasonable", "reasonable"] # 0/10

    board = Board((6, 6), {
        "hut": cost_of_hut,
        "station": cost_of_station
    },
                  ntrees=ntrees)
    deck = Deck({"garden": ngardens, "curse": ncurses})
    g = Game(board, deck, verbose=verbose)
    ps = get_players(player_types)
    ss = []
    ws = []
    for i in xrange(ngames):
        status, winner = g.play(ps, print_end_status=False)
        ss.append(status)
        ws.append(winner)
        g.reset()

    import collections
    print '=================='
    print collections.Counter(ws)
    print collections.Counter(ss)
Exemple #25
0
    def get(self, id=None):
        user = users.get_current_user()
        ex_user = True
        board = []
        cmpTask = []
        actTask = []
        cmpToday = []
        taskLen = []
        if user:
            url = users.create_logout_url(self.request.uri)
            url = url.split("board")[0]+"boards"
            url_string = "Logout"
            key_user = ndb.Key(User, user.email())
            if not key_user.get():
                userModel = User(key=key_user, email=user.email())
                userModel.put()
                ex_user = False
            board = Board.get_by_id(int(id))
            if board:
                if board.tasks:
                    taskLen = board.tasks
                    for task in board.tasks:
                        if task.status == "not completed":
                            actTask.append(task.status)
                        if task.status == "completed":
                            cmpTask.append(task.status)
                            if datetime.now().date() == task.completionDate.date():
                                cmpToday.append(task.status)

        else:
            url = users.create_login_url(self.request.uri)
            url_string = "Login"

        template_values = {
            "messages": self.messages,
            "url": url,
            "url_string": url_string,
            "user": user,
            "ex_user": ex_user,
            "board_url": "board/"+id,
            "key_board": id,
            "board": board,
            "taskLen": len(taskLen),
            "cmpTask": len(cmpTask),
            "actTask": len(actTask),
            "cmpToday": len(cmpToday)
        }
        template = JINJA_ENVIRONMENT.get_template("/TaskManagement/taskboard.html")
        self.response.write(template.render(template_values))
Exemple #26
0
def start():
    print("Waiting for other players")
    message = s.recv(10240)
    print(message.decode())

    view = View()

    while True:
        data = s.recv(10240)
        new_game = pickle.loads(data)
        view.print_board(new_game)

        print("waiting for oponent move")
        data = s.recv(10240)
        new_game = pickle.loads(data)
        view.print_board(new_game)
        while True:

            column_number = Board.take_number_from_user('column')
            row_number = Board.take_number_from_user('row')
            lista = [column_number, row_number]
            print(lista)
            data = pickle.dumps(lista)
            s.send(data)
            message = s.recv(10240).decode()
            if (message != "This field is already occupied"):
                if (message == "draw"):
                    print("Draw")
                    return
                elif (message == "won"):
                    print("You won")
                    return
                else:
                    break
            else:
                print("This field is already occupied")
Exemple #27
0
    def get_board_stats(self, project_name: str, board_name: str) -> Task:

        board_data = self._get_board(project_name, board_name)

        board = Board(project_name, board_name)

        for column in board.columns:
            tasks = create_tasks_from_dict(column.tasks)
            board.add_column(column['title'], tasks)


        # tasks = list()
        # for project in my_dashboard:
        #     task = Task(project['project_name'], project['title'], project['priority'], project['column_name'],
        #                 project['assignee_username'], project['date_due'])
        #     tasks.append(task)
        #
        # if printable:
        #     table = self.get_summary_tasks(tasks)
        #     print(table)
        #
        # return tasks

        pass
Exemple #28
0
 def get(self):
     tName = self.request.get("name")
     board_url = self.request.get("board_url")
     keyconcat = tName.lower().strip()+'/'+self.request.get("key_board")
     key_name = ndb.Key(Task, keyconcat)
     taskDel = key_name.get()
     if taskDel:
         taskDel.key.delete()
         boardDel = Board.get_by_id(int(self.request.get("key_board")))
         for i in range(0,len(boardDel.tasks)):
             if str(boardDel.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                 boardDel.tasks.pop(i)
                 break
         boardDel.put()
         self.add_message('Task Deleted successfully.', 'success')
     else:
         boardDel = Board.get_by_id(int(self.request.get("key_board")))
         for i in range(0,len(boardDel.tasks)):
             if str(boardDel.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                 boardDel.tasks.pop(i)
                 break
         boardDel.put()
         self.add_message('Task not found in database.', 'danger')
     self.redirect(str(board_url), abort=False)
Exemple #29
0
    def post(self):
        board_url = self.request.get("board_url")
        keyconcat = self.request.get("taskName").lower().strip()+'/'+self.request.get("key_board")
        key_name = ndb.Key(Task, keyconcat)
        if not key_name.get():
            task = Task(key=key_name)
            task.taskTitle = self.request.get("taskName").lower().strip()
            task.dueDate = datetime.strptime(self.request.get("dueDate"), '%Y-%m-%d')
            task.description = self.request.get("description")
            task.status = self.request.get("status")
            task.assignee = self.request.get("assignee")
            task.put()
            board = Board.get_by_id(int(self.request.get("key_board")))
            board.tasks.append(key_name.get())
            board.put()
            self.add_message('Task Created successfully.', 'success')
        else:
            self.add_message('Task with same task name already exists.', 'danger')

        self.redirect(str(board_url), abort=False)
Exemple #30
0
 def get(self, id=None):
     user = users.get_current_user()
     board = Board.get_by_id(int(id))
     board_url = self.request.get("board_url")
     form_url = '/board/{}'.format(id)
     if board:
         if len(board.users) == 1 and len(board.tasks) == 0 and user.email() == board.users[0].email.strip():
             key_user = ndb.Key(User, user.email())
             user_details = key_user.get()
             if user_details:
                 if user_details.boards != None:
                     del user_details.boards[str(id)]
                     user_details.put()
             board.key.delete()
             self.add_message('Board deleted successfully.', 'success')
             self.redirect('/boards', abort=False)
         else:
             self.add_message('Please remove all the tasks and users in order to delete this board', 'danger')
             self.redirect(form_url, abort=False)
     else:
         self.add_message('Board not found in database.', 'danger')
         self.redirect(form_url, abort=False)
Exemple #31
0
    def post(self):
        user = users.get_current_user()
        board_url = self.request.get("board_url")
        if user:
            board = Board.get_by_id(int(self.request.get("key_board")))
            user_email_key = ndb.Key(User, str(self.request.get("email_id").strip()))
            invited_user = user_email_key.get()
            if invited_user:
                if invited_user.boards:
                    board_dict = invited_user.boards
                else:
                    board_dict = {}
                board_dict[board.key.id()] = board.key.urlsafe()
                invited_user.boards = board_dict
                invited_user.put()
                existing_u = []
                for addedUser in board.users:
                    existing_u.append(addedUser.email.strip())

                if invited_user.key.id().strip() not in existing_u:
                    board.users.append(invited_user)
                    board.put()
                    self.add_message('User invited successfully.', 'success')
                    self.redirect(str(board_url), abort=False)
                else:
                    self.add_message('User already invited.', 'danger')
                    self.redirect(str(board_url), abort=False)

                return
            else:
                self.add_message('User not found.', 'danger')
                self.redirect(str(board_url), abort=False)
                return

        else:
            self.add_message('Not authorized.', 'danger')
            self.redirect('/', abort=False)
            return
Exemple #32
0
def main():
    # get players
    player1, player2 = initialisePlayer()
    # build board
    boardConfig = {
        "size": initialiseBoard()
        # "size": 5
    }
    board = Board(**boardConfig)
    gameController = GameController(board)

    # reset
    gameController.resetBoard()
    gameController.printBoard()

    # build battleship and place
    ships = initialiseShip()
    for ship in ships:
        gameController.place(Battleship(**ship))
        gameController.printBoard()
    
    # player attacks
    print(gameController.attack(**playerAttack()))
    gameController.printBoard()
Exemple #33
0
    if row == 4:
        return (Board.FIFTH_ROW_TOP_BORDER + Board.FIFTH_ROW_BOTTOM_BORDER) / 2
    if row == 5:
        return (Board.SIXTH_ROW_TOP_BORDER + Board.SIXTH_ROW_BOTTOM_BORDER) / 2


# Initializes the pygame modules
pygame.init()

# The window of the game
display = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
display_width, display_height = pygame.display.get_surface().get_size()
pygame.display.set_caption('ConnectFour')

# Initialize the board and discs
board = Board.Board(display_width, display_height)
disc_array = [
    Disc.Disc("Red") if i % 2 == 0 else Disc.Disc("Yellow") for i in range(42)
]
for disc in disc_array:
    disc.x = (Board.FIRST_COLUMN_LEFT_BORDER +
              Board.FIRST_COLUMN_RIGHT_BORDER) / 2
    disc.y = Board.TOP_BOARD_SPACE - Disc.DISC_PIXEL_DIAMETER / 2 - 5
disc_used_array = []
move = (0, 0)
row_position = None

# Disc number in the array
disc_number = 0

# Create a scoreboard and set its position to the right of the board
Exemple #34
0
 def deserialize_board(self, string):
     board_export = self.string_to_array(string)
     board = Board()
     board.from_export(board_export)        
     return board