m2[tmpx - 1][tmpy]) and MapUnit.getUserId( m2[tmpx - 1][tmpy]) != my.id: direction = 1 elif tmpy + 1 < 5 and m1[tmpx][ tmpy + 1] != -1 and not MapUnit.isBarrier( m2[tmpx][tmpy + 1]) and MapUnit.getUserId( m2[tmpx][tmpy + 1]) != my.id: direction = 2 elif tmpx + 1 < 5 and m1[tmpx + 1][tmpy] != -1 and not MapUnit.isBarrier( m2[tmpx + 1][tmpy]) and MapUnit.getUserId( m2[tmpx + 1][tmpy]) != my.id: direction = 3 elif tmpy - 1 >= 0 and m1[tmpx][ tmpy - 1] != -1 and not MapUnit.isBarrier( m2[tmpx][tmpy - 1]) and MapUnit.getUserId( m2[tmpx][tmpy - 1]) != my.id: direction = 4 else: direction = random.randint(1, 4) x = tmpx + x - 2 y = tmpy + y - 2 time.sleep(1) ## 以上为策略猪蹄部分 ### my.logout()
# Return: (query_res, query_status) # query_res: { # m1: [][], # m2: [][] # } # query_status: 0 => 失败 1 => 成功 query_res, query_status = a.query(x, y) time.sleep(1) # Params: (x, y, radio, direction) # radio: # 1 -> all 调动 (x, y) 所有兵力 # 2 -> half 调动 (x, y) 1/2的兵力 # 3 -> quarter 调动 (x, y) 1/4的兵力 # direction: # 1 -> (x, y) => (x - 1, y) # 2 -> (x, y) => (x, y + 1) # 3 -> (x, y) => (x + 1, y) # 4 -> (x, y) => (x, y - 1) # # Return: (action_length, move_status) # action_length 操作队列长度 # move_status: 0 => 失败 1 => 成功 print('---[moveTo]', x, y, a.id) direction = random.randint(1, 4) radio = random.randint(1, 3) action_length, move_status = a.move(x, y, radio, direction) time.sleep(1) ### 以上为策略猪蹄部分 ### a.logout()