Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
heweitykc committed Jul 2, 2014
1 parent 189c284 commit baf9393
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion proj/动画资源/cocos/roadsearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool RoadSearch::findPath(int startx, int starty, int endx, int endy)
bool RoadSearch::search()
{
Node* node = _startNode;

int count = 0;
while (node != _endNode){
int startX = fmax(0, node->x-1);
int endX = fmin(WIDTH-1, node->x+1);
Expand Down Expand Up @@ -63,8 +63,10 @@ bool RoadSearch::search()
test->parent = node;
_open.push_back(test);
}
count++;
}
}

_closed.push_back(node);
/*
list<Node*>::iterator itr = _open.begin();
Expand All @@ -82,6 +84,7 @@ bool RoadSearch::search()
node = _open.front();
_open.pop_front();
}
cout<<"count="<<count<<endl;
buildPath();
return true;
}
Expand Down
15 changes: 12 additions & 3 deletions proj/动画资源/cocos/testsearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ int main()
searcher.update(14,12, 1);
searcher.update(14,11, 1);

double seconds = GetTickCount();
LARGE_INTEGER m_liPerfFreq={0};
QueryPerformanceFrequency(&m_liPerfFreq);
LARGE_INTEGER m_liPerfStart={0};
QueryPerformanceCounter(&m_liPerfStart);

//Sleep(106);
searcher.findPath(0,0,15,16);
double seconds2 = GetTickCount();
std::cout<<"elapse:"<<(seconds2-seconds)<<endl;

LARGE_INTEGER liPerfNow={0};
QueryPerformanceCounter(&liPerfNow);
int time=( ((liPerfNow.QuadPart - m_liPerfStart.QuadPart) * 1000)/m_liPerfFreq.QuadPart);

std::cout<<"elapse:"<<time<<endl;
searcher.printPath();
return 0;
}

0 comments on commit baf9393

Please sign in to comment.