반응형
move 12시 3시 6시 9시
dx=[-1, 0, 1, 0]
dy=[0, 1, 0, -1]
기준 좌표 초기화
x, y = 0, 0
방향 변경 이용
0 : 좌
1 : 상
2 : 우
3 : 하
point = 1
좌표 이동
nx, ny = x + dx[point], y + dy[point]
map 보다 큰 경우 체크
n은 맵 크기 일 경우
특정 조건 작성
if nx < 0 or nx >= n or ny < 0 or ny >= n:
90도 회전(시계방향)
point = (point + 1) % 4
좌표 고정
x, y = nx, ny
반응형
'스스로 학습 > python' 카테고리의 다른 글
[python] colab에서 conda 사용하기 (python 3.6.8 및 tensorflow 1.12.3 설치) (0) | 2023.08.03 |
---|---|
[python] plotly.express image save 방법 (0) | 2023.05.22 |
[python] sort 함수 (0) | 2022.12.22 |
[python] 다른경로 파일 import (동일, 하위, 상위경로) (0) | 2022.12.14 |