diff --git a/SafariChess_AI.py b/SafariChess_AI.py index 3ec0209..ef3aeba 100644 --- a/SafariChess_AI.py +++ b/SafariChess_AI.py @@ -7,7 +7,7 @@ import random from math import inf import collections -piece_score = {"7": 180, "1": 200, "6": 120, "5": 80, "4": 60, "3": 50, "2": 81} +piece_score = {"7": 180, "1": 200, "6": 150, "5": 100, "4": 60, "3": 50, "2": 81} mouse_score = [[13, 13, 13, 13, 12, 11, 10, 9, 8], [25, 20, 15, 18, 16, 13, 10, 9, 8], @@ -34,11 +34,11 @@ eagle_score = [[14, 13, 10, 12, 14, 13, 10, 8, 7], [14, 12, 10, 13, 14, 13, 10, 8, 7]] fox_score = [[11, 12, 14, 13, 12, 11, 10, 8, 8], - [15, 15, 14, 0, 0, 0, 10, 8, 11], - [50, 20, 20, 0, 0, 0, 10, 9, 10], + [15, 15, 14, 0, 0, 0, 10, 14, 11], + [50, 20, 20, 0, 0, 0, 10, 8, 10], [1919810, 50, 20, 13, 12, 11, 11, 10, 0], - [50, 20, 20, 0, 0, 0, 10, 9, 10], - [15, 12, 15, 0, 0, 0, 10, 8, 11], + [50, 20, 20, 0, 0, 0, 10, 8, 11], + [15, 12, 15, 0, 0, 0, 10, 14, 11], [11, 12, 14, 13, 12, 11, 10, 8, 8]] # wolf_score = [[11, 12, 14, 13, 12, 11, 10, 8, 8], @@ -49,12 +49,12 @@ fox_score = [[11, 12, 14, 13, 12, 11, 10, 8, 8], # [15, 12, 15, 0, 0, 0, 10, 8, 8], # [11, 12, 14, 13, 12, 11, 10, 8, 8]] wolf_score = [[11, 12, 14, 13, 12, 11, 10, 10, 8], - [15, 15, 14, 0, 0, 0, 10, 13, 10], + [15, 15, 14, 0, 0, 0, 10, 14, 10], [50, 20, 20, 0, 0, 0, 10, 12, 10], [1919810, 50, 20, 12, 11, 10, 11, 12, 0], [50, 20, 20, 0, 0, 0, 10, 13, 10], [15, 12, 15, 0, 0, 0, 13, 14, 8], - [11, 12, 14, 15, 16, 17, 16, 15, 8]] + [11, 12, 14, 13, 12, 10, 11, 12, 8]] leopard_score = [[11, 12, 14, 13, 12, 11, 10, 8, 8], [15, 15, 14, 0, 0, 0, 10, 8, 8], diff --git a/SafariChess_Gamev1.0.py b/SafariChess_Gamev1.0.py index 902dac0..8785268 100644 --- a/SafariChess_Gamev1.0.py +++ b/SafariChess_Gamev1.0.py @@ -62,7 +62,7 @@ def listenFromServer(): recvMsg = client.recv(1024).decode('utf-8') if len(recvMsg) != 0: networkMsg = json.loads(recvMsg) - print('receive thread catch: ',networkMsg) + #print('receive thread catch: ',networkMsg) except socket.error as e: #print('Error encountered in connection. Quit.') print(e) @@ -70,7 +70,7 @@ def listenFromServer(): def startNetworkServices(): global client,server,port,addr,connection client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server = '127.0.0.1' + server = '192.168.43.115' port = 50005 addr = (server,port) connection = client.connect(addr) @@ -509,6 +509,7 @@ def main(mode): print('Game start 2 play!') game_id = networkMsg['game_id'] MySide = networkMsg['side'] + print('my side:{}'.format('b' if MySide==1 else 'r')) other_stage = True if networkMsg['side']==1 else False #一开始如果我是蓝方则other_stage为真 if(other_stage == True): print('waiting for other player to move...') @@ -719,7 +720,7 @@ def main(mode): 'msg': { "game_id": game_id, "side": MySide, - "chessman": int(thisMove.cur_piece[1:]), + "chessman": int(thisMove.cur_piece[1:])-1, "src": { "y": thisMove.start_row, "x": thisMove.start_col @@ -756,7 +757,7 @@ def main(mode): if time_out_side != None: showGameOverText(screen,"player "+ ("b" if time_out_side==1 else "r")+" timed out") #超时了 elif foul is not None: - showGameOverText(screen,"player "+ ("b" if foul == 1 else "r") + "'s foul play") + showGameOverText(screen,"foul play") game_over = True elif game_over and other_joined: if (game_state.win_person == ''): game_state.conquer() @@ -766,7 +767,7 @@ def main(mode): showText(screen,bigfont,game_state.color(),700,350) - clock.tick(50) + clock.tick(240) pg.display.flip() diff --git a/SafariChess_backend.py b/SafariChess_backend.py index 8ad5fd8..3b332fd 100644 --- a/SafariChess_backend.py +++ b/SafariChess_backend.py @@ -219,7 +219,7 @@ class GameState: self.moveFunctions[self.board[row][col][1]](row,col,moves) valid_moves = [] for move in moves: # 己方躲避17-5和7-3 - # if self.seventy_three_violation(goal=move.get_goal_chess_comb(), color=self.color()) and self.seventeen_five_violation(goal=move.get_goal_chess_comb(), color=self.color()): + if self.seventy_three_violation(goal=move.get_goal_chess_comb(), color=self.color()) and self.seventeen_five_violation(goal=move.get_goal_chess_comb(), color=self.color()): valid_moves.append(move) if len(valid_moves) == 0: print('warning: no available moves at side {}'.format('b' if not self.red_to_move else 'r')) diff --git a/__pycache__/SafariChess_AI.cpython-39.pyc b/__pycache__/SafariChess_AI.cpython-39.pyc index d0af326..31a9500 100644 Binary files a/__pycache__/SafariChess_AI.cpython-39.pyc and b/__pycache__/SafariChess_AI.cpython-39.pyc differ diff --git a/__pycache__/SafariChess_backend.cpython-39.pyc b/__pycache__/SafariChess_backend.cpython-39.pyc index eafd3dc..338d82a 100644 Binary files a/__pycache__/SafariChess_backend.cpython-39.pyc and b/__pycache__/SafariChess_backend.cpython-39.pyc differ diff --git a/network/config.txt b/network/config.txt index b34e174..fd7919c 100644 --- a/network/config.txt +++ b/network/config.txt @@ -1,4 +1,4 @@ -SOCKET_HOST=127.0.0.1 +SOCKET_HOST=192.168.43.183 SOCKET_PORT=50005 MAX_WAITING_TIME=600 MAX_THNIKING_TIME=400