Python Solution DP+BitMask+BFS
\n# Code\npython3 []\nimport heapq\nfrom collections import deque\nclass Solution:\n    def maxMoves(self, kx: int, ky: int, positions: List[List[int]]) -> int:
\n# Code\n```python3 []\nimport heapq\nfrom collections import deque\nclass Solution:\n    def maxMoves(self, kx: int, ky: int, positions: List[List[int]]) -> int:\n        @cache\n        def validMoves(curposition):\n            i,j = curposition\n            validmoves=[]\n            for deltax,deltay in [[2,1],[1,2]]:\n                for powerx,powery in [[1,1],[1,-1],[-1,1],[-1,-1]]:\n                    newi = i + deltax*powerx\n                    newj = j + deltay*powery\n                    if newi>=0 and newj>=0 and newi<50 and newj<50:\n                        validmoves.append((newi,newj))\n            return validmoves\n        @cache\n        def bfs(curposition,finalposition):\n            if curposition==finalposition:\n                return 0\n            heap=[[0,curposition]]\n            queue = deque([[0,curposition]])\n            path=set()\n            while len(queue)!=0:\n                len1,newcur=queue.popleft()\n                if newcur==finalposition:\n                    return len1\n                if newcur in path:\n                    continue\n                path.add(newcur)\n                validmoves=validMoves(newcur)\n                for nextmove in validmoves:\n                    queue.append([len1+1,nextmove])\n        # for position in positions:\n        #     position=tuple(position)\n        #     print(bfs((kx,ky),position))\n        # return 0\n        @cache\n        def rec(aliceTurn,bitmap,curposition):\n            if bitmap=="0"*len(positions):\n                return 0\n            if aliceTurn:\n                ans=0\n            else:\n                ans=float("inf")\n            remi=0\n            for i,ch in enumerate(bitmap):\n                if ch=="0":\n                    continue\n                \n                pos=positions[i]\n                newbitmap=list(bitmap)\n                newbitmap[i]="0"\n                newbitmap="".join(newbitmap)\n                d1= bfs(curposition,tuple(pos)) +rec(not aliceTurn,newbitmap,tuple(pos) )\n                if aliceTurn:\n                    ans=max(ans,d1)\n                else:\n                    ans=min(ans,d1)\n            return ans\n        bitmap="1"*len(positions)\n        return rec(True,bitmap,(kx,ky))\n\n\n\n            \n```
['Python3']