2013-12-23 1 views
0

먼저 의사 코드를 입력하겠습니다. 실제 보행자 동작에 따른 유효성 및 개선 방법을 알려주십시오.목표에 이르는 경로에서 '친구'를 검색하고 섞는 보행자 동작에 적합한 알고리즘입니까?

전제 : 거북이가 스폰 지점에서 목표까지 걷습니다. 도중에 다른 거북이들과 만난다. 같은 색상의 거북이는 "친구"로 간주되어 그 근처로 이동하여 "친구들이 걷는 거리"시나리오를 시뮬레이션합니다. 더 가까운 거리에있는 동일한 색상의 거북이가 더 높은 우선 순위를가집니다. 친구 A는 친구 B보다 가깝기 때문에 먼저 친구 A에게 접근합니다.

목표에 도달하면 거북이가 스폰 지점으로 돌아갑니다.

의사 코드 : 제발 개선을위한

determine if i am already in the goal 
if yes, 
    determine if there are patches I can walk on 
    set eyes on nearest patch I can walk on (for the goal path) 
    if there is a friend nearby, approach friend 
    if there is no friend nearby, continue walking the goal path 
    if im already in the goal, respawn. 

조언?

답변

1

전제는 스폰 지점으로 돌아 오는 방법에 관해서는 아무 말도하지 않습니다. 전제가 한 단계 조치라고 가정합니다 (즉, 그 세부 사항에 관심이 없음). 줄을 따라 더 많은 것을 볼 수 있습니다.

spawn loop: 
    spawn 
    goal loop: 
    determine if turtle already reached goal 
    if no, 
     determine if there are patches I can walk on 
     set eyes on nearest patch I can walk on (for the goal path) 
     if there is a friend nearby, approach friend 
     if there is no friend nearby, continue walking the goal path 
    if yes, 
     setup so can respawn (return to spawn loc, etc) 
     goal loop ends 
관련 문제