So, Person/J.P., I heard you need help with an Ai. What you could do (this is just pseudo-code):
@MAIN
IF D=1 THEN GOTO @LEFT
IF D=2 THEN GOTO @RIGHT
@LEFT
REPEAT X-10 UNTIL [collision with a wall]
IF [collision with a wall] THEN D=2 ELSE GOTO @LEFT
GOTO @MAIN
@RIGHT
REPEAT X+10 UNTIL [collision with a wall]
IF [collision with a wall] THEN D=1 ELSE GOTO @RIGHT
GOTO @MAIN
1そうだね 未プレイ