コード例 #1
0
 def _timer_tick(self) -> None:
     for queue in iteration_queue(self.sync_queue):
         if queue.sync_type == SyncType.SYNC_DRAW and self._detect_diff_board(
                 queue.game_vector):
             self.update_board(queue.game_vector)
         elif queue.sync_type == SyncType.SYNC_KILL:
             exit()
         elif queue.sync_type == SyncType.SYNC_SELECT:
             self._abalone_cell[self._get_1d_pos(
                 queue.y, queue.x)].set_select(queue.selected)
コード例 #2
0
ファイル: TextGraphic.py プロジェクト: junghyun397/AbaloneRL
 def _main_loop(self) -> None:
     prv_time, run = time.time(), True
     while run:
         if time.time() - prv_time > 1 / self.update_feq:
             for queue in iteration_queue(self.sync_queue):
                 if queue.sync_type == SyncType.SYNC_DRAW or queue.sync_type == SyncType.SYNC_INIT:
                     self._draw(queue.game_vector)
                 elif queue.sync_type == SyncType.SYNC_KILL:
                     run = False
                     break
             prv_time = time.time()
コード例 #3
0
ファイル: play_abalone.py プロジェクト: codeaudit/AbaloneRL
import args_parser
from abalone import FieldTemplate
from abalone.AbaloneModel import AbaloneAgent
from graphics.QSyncManager import iteration_queue
from graphics.Qt5PlayableGraphic import Qt5PlayableGraphic

args = args_parser.get_parser(add_graphic_option=False).parse_args()

if __name__ == '__main__':
    abalone_model = AbaloneAgent(edge_size=args.board_size,
                                 vector_generator=FieldTemplate.basic_start)
    graphic_agent = Qt5PlayableGraphic()
    graphic_agent.init_ui(abalone_model.game_vector)

    handler_queue = graphic_agent.handler_queue

    while True:
        for event in iteration_queue(handler_queue):
            pass
コード例 #4
0
 def _timer_tick(self) -> None:
     for queue in iteration_queue(self.sync_queue):
         if queue.sync_type == SyncType.SYNC_DRAW and self._detect_diff_board(queue.game_vector):
             self.update_board(queue.game_vector)
         elif queue.sync_type == SyncType.SYNC_KILL:
             exit()
コード例 #5
0
 def iter_event(self) -> None:
     for event in iteration_queue(self.handler_queue):
         pass
コード例 #6
0
import args_parser
from abalone import FieldTemplate
from abalone.AbaloneModel import AbaloneAgent
from graphics.QSyncManager import iteration_queue, SyncType
from graphics.qt5.Qt5PlayableGraphic import Qt5PlayableGraphic
from model.AbalonePlayController import AbalonePlayController

args = args_parser.get_parser(add_graphic_option=False).parse_args()

if __name__ == '__main__':
    abalone_model = AbaloneAgent(edge_size=args.board_size,
                                 vector_generator=FieldTemplate.basic_start)

    graphic_agent = Qt5PlayableGraphic()

    abalone_play_controller = AbalonePlayController(
        abalone_model=abalone_model, sync_queue=graphic_agent.sync_queue)

    graphic_agent.init_ui(abalone_model.game_vector)

    while True:
        for event in iteration_queue(graphic_agent.handler_queue):
            if event.sync_type == SyncType.SYNC_CLICK:
                abalone_play_controller.click_stone_event(event.y, event.x)
            elif event.sync_type == SyncType.SYNC_ENTER:
                abalone_play_controller.enter_event()