파이어 엠블렘과 같은 파이어 게임을 파이 게임으로 프로그래밍하고 있지만 플레이어의 움직임에 문제가 있습니다. 작동 방식은 플레이어를 선택하면 파란색으로 강조 표시된 모든 허용 된 동작이 표시되지만 내 문제는 가능한 모든 동작에 대한 목록이 표시되는 데 문제가 있다는 것입니다. 난 당신이 마음에 무엇을 모르기 때문에회전 기반 이동 알고리즘
def showPerson(tilex, tiley, personAtTile):
global ALLOWEDMOVES
ALLOWEDMOVES = []
prepare = {k:v for v,k in PLAYERSPOSITION.items()}
z = PLAYERDISTANCE[personAtTile]
#get all coords for the possible moves
currentNewSpots = []
oldSpots = []
a = PLAYERSPOSITION[personAtTile][0]
b = PLAYERSPOSITION[personAtTile][1]
c = a + 1
test = findTileLetter(c, b)
if test:
currentNewSpots.append((c, b))
ALLOWEDMOVES.append((c, b))
c = a -1
test = findTileLetter(c, b)
if test:
currentNewSpots.append((c, b))
ALLOWEDMOVES.append((c, b))
c = b + 1
test = findTileLetter(a, c)
if test:
currentNewSpots.append((a, c))
ALLOWEDMOVES.append((a, c))
c = b - 1
test = findTileLetter(a, c)
if test:
currentNewSpots.append((a, c))
ALLOWEDMOVES.append((a, c))
for x in range(PLAYERDISTANCE[prepare[(tilex, tiley)]]):
for y in range(len(currentNewSpots) - 1):
a = currentNewSpots[y][0]
b = currentNewSpots[y][1]
c = a + 1
test = findTileLetter(c, b)
if test and ((c, b)) not in ALLOWEDMOVES:
currentNewSpots.append((c, b))
ALLOWEDMOVES.append((c, b))
c = a -1
test = findTileLetter(c, b)
if test and ((c, b)) not in ALLOWEDMOVES:
currentNewSpots.append((c, b))
ALLOWEDMOVES.append((c, b))
c = b + 1
test = findTileLetter(a, c)
if test and ((c, b)) not in ALLOWEDMOVES:
currentNewSpots.append((a, c))
ALLOWEDMOVES.append((a, c))
c = b - 1
test = findTileLetter(a, c)
if test and ((c, b)) not in ALLOWEDMOVES:
currentNewSpots.append((a, c))
ALLOWEDMOVES.append((a, c))
"허용 된"동작에 대한 기준을 이해하지 못합니다. –
Welcome to Stack Overflow! 파이썬 질문을했지만 코드가 제대로 들여 쓰기가되지 않았습니다. 공백은 파이썬에서 구문 적으로 중요하며, 들여 쓰기가 적절하지 않으면 코드가하는 일을 알 수 없으므로 도움을 줄 수 없습니다. 질문을 수정하고 들여 쓰기를 수정하십시오. 감사! –
나는이 게임이 길 찾기를 사용한다고 믿는다. 길 찾기에 대한 훌륭한 소개 : http://theory.stanford.edu/~amitp/GameProgramming/ – ninMonkey