From 57ff012187311c07ec2c5582254cbdd6b600fa05 Mon Sep 17 00:00:00 2001 From: tzzzzzzzx <414850847@qq.com> Date: Tue, 18 Oct 2022 20:55:33 +0800 Subject: [PATCH] final final --- SafariChess_AI.py | 14 +++++++------- SafariChess_Gamev1.0.py | 11 ++++++----- SafariChess_backend.py | 2 +- __pycache__/SafariChess_AI.cpython-39.pyc | Bin 6444 -> 6538 bytes .../SafariChess_backend.cpython-39.pyc | Bin 12674 -> 12752 bytes network/config.txt | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) 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 d0af32666acf2d74c102d0b8c762b9b4d57540f0..31a9500550d28b3e9e61ebb8c6081d29321f2ea8 100644 GIT binary patch delta 532 zcmZ{hyG{Z@6ozLZ>@2%1u5w8*x{?@FydVPJ@UBQ{V{E1|#-Es2`T`W9g@p;3gjiVF z*w|6~2KGLKiIwpIJRBO>#F^y(|MQ)5GR3@=9?I^8>)L{jx<9%6ZMz?d$rs~Fz-P^n zN@cZwa!r987g1{Vu)qxKEbGKTp5xqKwP`NT^*rkW>*7G}^WKb9&i~U*^j8PRV+|8a zD6|B5i0<-TI3sG})@Vo+nacpTu)^F5@F+^mqXBNC%-lwE_yGqMZa9I37*?6bhB?-r zC=XR^k&j{^^|_hV*K*qQsdJOmS*y@}HH(IRH*F`ytS1TmEvs5aeC?SLBds50 Oo|3JnEZIG?KD|Gie1e<+ delta 527 zcmeA&USq_Y$ji&c00apiosvIJ&mQQJg>y zNSGl-6-+{u%OJ7Uz-)+CE}%MfFkb^qYJy2EBsN4Gq=r3;n~>`I6lCQ*scb3QDLO3- zK$-~%bz7Mw8C)2e8B^I)^uXfmXyP0x`e1PmG;z)p1F$$JnmAXAAy}LXDqat>fIGzq zEWwSYfhWZnEY5=}o?R{UF^WIMEXBNqAxa>{BE=F&3#M45SOaOH6q^)V zAT69?mtqg3MN%A69D%fGic^X+kQPf}VhLu@beTMZX&PGvFv?yAY&KyQV4hsT!819F zoquvXo5JK&R=LRnY=WEbvS~7kN&yuW$$$uXI7@0WBfH*YPoNfvQm)B<9PFDnb6ghy E05Ru*T>t<8 diff --git a/__pycache__/SafariChess_backend.cpython-39.pyc b/__pycache__/SafariChess_backend.cpython-39.pyc index eafd3dc0fe768ba5fa233a63f24dc4c9b03800e3..338d82ad70c9d76599e669aa15743e885b255e78 100644 GIT binary patch delta 243 zcmZolzL3nD$ji&c00hcY{F3=M@@7ghzM5Pv*;Q{<%T~jX#ahF*fNdc|4Z{NVg$yaI zy-Y=IKv51XqO1!zYuFYtGBOmll`z(@HZ!I$W-}E%E8$9ETfhy}!(4nXg*lHYg=ryU zGf-6xYcPW*yI&C_(CVUS5D^0+Sb>BlQ&AQJ3y>2x*+)u8o2MuhB$Eargg`_%hzI}? rxgbIwM8tuJg30|-SrSq}CIcf2qY$GQ5X&&B0NEUjI*gn7rHjP?ecd$? delta 146 zcmcbR+?33l$ji&c00c!XPRW8Bc{3#$_f0OB?DFQTWvgLbz*@t$kdcw0u&so#hP9b7 zg)y6{Xjcha3hM&)8ip+9;!P>cc}yux3mKb%s%lt+88q4aiWou0MT3YK5WzaRMM{T} mWAa8Rsmb@H(!?Zyf((o-j6#fJKrF+g0%UVAZH|>L76SmHFd(u3 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