float rangeScore(vector<char> &goal,vector<char> &test,float score, int x,int y)
{
int i = 0;
float local_score = score;
for(i=x;i<y;i++)
if(test == goal)
local_score++;
return local_score;
//return( score / 10.24f) ;
}
example call:
new_score = rangeScore(goal,test,current_score,i,i+4);
new_score = rangeScore(goal,test,new_score,j,j+4);
scoring an unsorted array vs a sorted one
I'm doing something wrong but I can figure out what.
What is supposed to happen is I call a swap function that swaps 8 indicies in an array ( 2 blocks of 4). Then I'll update the score of the test array compared to the goal array ( goal is a sorted copy of test) with the intention of only increasing the score if the newly swapped items are in order.
What happens is new_score keeps increasing every time , which doesn't make sense considering if you swap something like this:
AADD CBCB test
CBCB AADD test swapped
AABB CCDD goal
and score it vs the sorted goal it should score 3 but I get 4.
I suggest you step through it with a debugger to figure out why it's not behaving exactly as you'd expect
yay - alot of good that does me when I don't understand assembly - maybe you do so here is what I got at the if (test == goal]) line
0040231E mov ecx,dword ptr [ebp-4]00402321 push ecx00402322 mov ecx,dword ptr [ebp+0Ch]00402325 call @ILT+365(std::vector<char,std::allocator<char> >::operator[]) (00401172)0040232A movsx esi,byte ptr [eax]0040232D mov edx,dword ptr [ebp-4]00402330 push edx00402331 mov ecx,dword ptr [ebp+8]00402334 call @ILT+365(std::vector<char,std::allocator<char> >::operator[]) (00401172)00402339 movsx eax,byte ptr [eax]0040233C cmp esi,eax0040233E jne rangeScore+6Ch (0040234c)
Quote:Original post by vanegerYour debugger shouldn't output assembly if you invoke it correctly. What platform/environment are you using?
yay - alot of good that does me when I don't understand assembly - maybe you do so here is what I got at the if (test == goal]) line
*** Source Snippet Removed ***
Yeah, you don't need to step through assembler. Assumedly you're already running a debug build, which debugger are you using? If you're on windows you should be using visual studio's debugger, which is unmatched in usefulness
Quote:Original post by vanegerThrow that out directly, and download a copy of Visual C++ Express, which happens to be free. Apart from being ancient, MSVC 6 had one of the worst C++ compilers in existence, and you will save yourself a world of trouble by moving on.
I'm using msvc 6.0 .
Ok so I got the express version - still don't know what settings out of the million of them to use for debugging.
Yeah as I just mentioned in my PM, the thing you're doing wrong is that you need to subtract one for each match, then modify the array, and then add one for each match.
Quote:Original post by vanegerClick in the margin to set a breakpoint next to the statement you want to debug, and the hit the green arrow, or choose 'run with debugger' from the menu.
Ok so I got the express version - still don't know what settings out of the million of them to use for debugging.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement