Darwinbots Forum

Code center => Bugs and fixes => Bug reports => Topic started by: EricL on March 14, 2006, 07:16:57 PM

Title: Unassigned variable when using InstaWin
Post by: EricL on March 14, 2006, 07:16:57 PM
Pressing the InstaWin button on the Contest Results dialog in 2.4A (VB version) during a contest results in a crash at line 16 of Contest_Form.frm.  The variable nd is declared but never used or initalized.  Since nd is never used, commenting out the line (t=nd.robn) addresses the problem and appears to result in correct behaviour.

"Doctor, it hurts when I do this."
"Then don't do that."
Title: Unassigned variable when using InstaWin
Post by: Griz on March 14, 2006, 07:33:46 PM
thanks eric.

I ran into that in earlier versions of 2.4

but in 2.4.A ... I haven't been able to get leauges to run ...
crashes anytime I try to create a leauge ...
or to load an existing one, even F1.
I've asked about this a number of times here ... got no reply.
so let me make sure ...
you are able to load and run leauges in 2.4.A, yes?
do they work except for this InstaWin button?

thanks ...
one reason I stopped using 2.4 and went back to 2.37.6 ...
so this may be good news. ;)
Title: Unassigned variable when using InstaWin
Post by: Numsgil on March 14, 2006, 10:23:17 PM
I always feel bad working on 2.4 since it postpones the C++ development...

If you'd really like me to I can go through and try to make the leagues work.  To be honest though the code is a mess (I wrote the code I admit, not one of my cleaner hacks).
Title: Unassigned variable when using InstaWin
Post by: Griz on March 14, 2006, 10:56:12 PM
Quote
I always feel bad working on 2.4 since it postpones the C++ development...

If you'd really like me to I can go through and try to make the leagues work.  To be honest though the code is a mess (I wrote the code I admit, not one of my cleaner hacks).
well it sounds like Eric has it working to some degree ...
and is finding/fixing bugs so ... ???

the errors I get may be due to something else ...
I get path errors sometimes ...
and I didn't want to spend more time on it if it wasn't working at all ...
but if he has it up and going ...
then maybe the problem is I don't have all the folders and
league tables in the right place or something.
that he has it working makes it worthwhile for me to play with it again.

so I wouldn't sweat it.
eventually, it would be nice to have ...
as I don't see being able to alter the c++ version myself ...
so the VB programs are more interesting for learning.
maybe we'll keep poking around and figure it out.
Title: Unassigned variable when using InstaWin
Post by: EricL on March 14, 2006, 11:29:41 PM
Nums, I'd say you should stay focused on the C++ version.  I'm just filing bugs on 2.4A as I find them mostly because I can I guess, just to have a record of them to make sure they get picked up in the C++ fork (yea, I know.  I expect the value of 2.4A bug reports is marginal for the C++ fork given the magnitude of the re-write but what the hey...).  I'm not on a mission to make anything specific (like leagues) work in 2.4 - just fixing crashing bugs at this stage - though if there is high demand to make a specific feature work in 2.4 that used to work in previous versions, I could probably be of some use there.  

I have a pretty fast machine, so it's pretty easy for me to run things in VB all the time and identify/investigate/fix simple things as/when I hit them.   I don't really have to know the code that well to fix simple overflows and such, not in depth and those who do know it like yourself are IMHO better utilized working on the new architecture and the port.   I certainly don't expect any more 'official' work on the VB fork given the focus on C++ and I'd be happy to share my private VB exe with anyone who can't build the post 2.4A cumulative fixes themselves.  I'd also be happy to spend a little bit of time (ephansis on 'little') making specific functionality work in 2.4A if someone really needs something (I really miss the gene activation form for debuigging bots and may spend some time on that this week) but at some point in the not too distant future, I plan to volunteer to help on the C++ version so I don't want to do too much down level....

So, I do think we want to track 2.4A bugs, expecially crashing bugs, but that doesn't mean you or anyone else has to fix them much less make specific features work.  My vote is to keep the big guns full speed ahead on the C++ port.

If someone is dying for something specific to work in 2.4A, let me know and I can spend some time on it, letting Nums work on the real deal.

-E
Title: Unassigned variable when using InstaWin
Post by: EricL on March 14, 2006, 11:38:52 PM
In answer to Griz's specific question about running leagues, well, to be honest, I'm not really sure.  I barely understand what a league is!  I'm still a real Newbie, one who can code (can you say 'dangerous'?) but still really quite the DB newbie.  

What I can do is load a sim with a couple of bots and check the F1 checkbox on the 'Restart and League' page and I get the Contest Results dialog with dynamic population counters.  Very useful that, league or no league.  With my little crahs fix, I can press the Istawin button and not crash.  It seems to play a number of rounds though there are still some quirks.  Sometimes Instawin kills the loosing bots but doesn't start another round for example.  But in particular, I have not played around with (nor do I fully understand yet) the other setttings on the page, including the Challenge league stuff.  Will do tomorrow.
Title: Unassigned variable when using InstaWin
Post by: Griz on March 15, 2006, 12:47:03 AM
ah.
yeah ... that's not the same as loading in a league ...
that's where I get my crash.
will have to try it like you were ... yes that's useful too.

play with it in version 2.37.6 ... as everything works there. I think.
well, I seem to have problems limiting the number of rounds ...
I figured best of 3 was good enough but it always seemed to keep
going longer than that.

I think someone was going to do a page on the wiki on leagues ...
as I'm still not sure how it's supposed to work.
seems you do have to have the league tables in place.
I don't think they come with the later versions ...
you may have to go back to ver 2.34 or something to get them.

maybe a 'search' here for leagues might turn up a message or two
to get you started.  seems I asked when I was starting ...
and now it's been so long I don't recall how to do them anymore. ;)

I ended up making my own leagues ... with just 3 or 4 bots ...
never did play with F1 ... other than just to see if it worked.

that InstaWin fix is good ...
I had that crash too ... probably while doing the same thing as you ...
and with bots that were simply mutations or bots with only slightly
different values in their dna ... they tended to be evenly matched ...
and if left to the contest ... never would select a winner.
so what I did was manually select a winner after a given number of cycles.
it would be nice to have that option work ... stopping the contest
after a given number of cycles.  

try loading F1 league in version 2.4.A ...
the error I got often was some path error.
I never did do it via VB and try to debug.
time!  I need a 36 hour day. ;)

let me know if you discover anything more.
Title: Unassigned variable when using InstaWin
Post by: Griz on March 15, 2006, 10:38:38 AM
re: League errors in 2.4

ver 2.4.A
trying to load F1 League ...
I get error 9  Subscript out of range

debug takes me to the line in bold in:

Public Function DnaLen(DNA() As block) As Integer
  DnaLen = 1
  While Not (DNA(DnaLen).tipo = 10 And DNA(DnaLen).value = 1)
   DnaLen = DnaLen + 1
  Wend
End Function

where DnaLen = 20
DNA(DnaLen).tipo = <Subscript out of range>
DNA(DnaLen).value =  <Subscript out of range>

so ... ?????????????????


just running under F1 conditions ...
the contest mode works ...
and clicking on InstaWin ...
I get Run-time error '91':
Object variable or With block variable not set.

commenting out  't = nd.robn then takes care of this ...
as Eric1 said.

also encountered the   .mem(837) = .Paracount overflow
and fixed that wih his patch as well.
thanks Eric!

so this is great, as I use this much as eric does ...
to evaluate a few bots with minor differences.
also ... keeping mutations enabled ...
and saving the dna of successful winners ...
one can so a bit of 'evolving' here as well.
it would be nice to be able to save the robots
at the end of each round and have a way to look
at them to find such mutants.

perhaps I can work the Invested Energy King bot thing
into this, using # of offspring along with # of mutations
as the criteria.

we will see
Title: Unassigned variable when using InstaWin
Post by: Griz on March 15, 2006, 10:42:04 AM
Eric ...
in case you hadn't noticed:
in ver 2.4.A ...
the error.sim save is named differently than in 2.37.6
it is not 'on error go to fine' as it is there.

in:

~~~
' main procedure. Oh yes!
Private Sub main()
  Dim clocks As Long
  clocks = GetTickCount
  Do
    If Active Then
     
      If MDIForm1.ignoreerror = True Then
        On Error Resume Next  
      Else
        'On Error GoTo SaveError  '<uncomment this line for the 'compiled' version>
      End If
~~~

then it will save as error.sim running compiled.
commented out in the VB ... it won't and you can Debug.

hmmmm ...
wondering if we could set this up to be 'toggled' from within the program
so I wouldn't keep forgetting to uncomment it for the compiled version.
Title: Unassigned variable when using InstaWin
Post by: Numsgil on March 15, 2006, 10:52:53 AM
Quote
re: League errors in 2.4

ver 2.4.A
trying to load F1 League ...
I get error 9  Subscript out of range

debug takes me to the line in bold in:

Public Function DnaLen(DNA() As block) As Integer
  DnaLen = 1
  While Not (DNA(DnaLen).tipo = 10 And DNA(DnaLen).value = 1)
   DnaLen = DnaLen + 1
  Wend
End Function

where DnaLen = 20
DNA(DnaLen).tipo = <Subscript out of range>
DNA(DnaLen).value =  <Subscript out of range>
That's odd.  The code is trying to find the end of the DNA.  ALL DNA, as far as I remember, must end with tipo = 10 and value = 1 (the 'end')
Title: Unassigned variable when using InstaWin
Post by: Griz on March 15, 2006, 12:16:48 PM
Quote
Quote
re: League errors in 2.4

ver 2.4.A
trying to load F1 League ...
I get error 9  Subscript out of range

debug takes me to the line in bold in:

Public Function DnaLen(DNA() As block) As Integer
  DnaLen = 1
  While Not (DNA(DnaLen).tipo = 10 And DNA(DnaLen).value = 1)
   DnaLen = DnaLen + 1
  Wend
End Function

where DnaLen = 20
DNA(DnaLen).tipo = <Subscript out of range>
DNA(DnaLen).value =  <Subscript out of range>
That's odd.  The code is trying to find the end of the DNA.  ALL DNA, as far as I remember, must end with tipo = 10 and value = 1 (the 'end')
looks like ...
and this was an established F1 league ...
obviously one that had been run before ...
not one I made up with my own bots.

will try it again trying to load F2 or make a new league ...
see if the numbers are the same.
what is the significance of DnaLen = 20?

oh well ...
onward

oh yeah ... a question:

did number of rounds ever work?
as I recall, they just keep going on up to 10.
and what is that sampling rate = 10 do/not-do?
Title: Unassigned variable when using InstaWin
Post by: Numsgil on March 15, 2006, 12:38:58 PM
In order to win a contest, a bot must win Sqr(# rounds) + (rounds / 2)
So a 4-1 record won't win, but a 5-0 one will.

This was chosen way before I joined as being a statistically significant way to judge that one bot is better than another.

DnaLen of 20 is usually a veggy if I remember correctly.
Title: Unassigned variable when using InstaWin
Post by: PurpleYouko on March 15, 2006, 02:02:49 PM
What the heck is the league function doing looking at DNA length??  :blink:
Title: Unassigned variable when using InstaWin
Post by: Numsgil on March 15, 2006, 03:13:47 PM
I don't remember to be honest.
Title: Unassigned variable when using InstaWin
Post by: EricL on March 15, 2006, 03:21:58 PM
The function that loads the robots (RobScriptLoad) calls DnaLen to set the length in the rob array when the league table is loaded/created.

I think the bug has to do with reuse of rob array elements.  Working on it...
Title: Unassigned variable when using InstaWin
Post by: PurpleYouko on March 15, 2006, 03:55:37 PM
Seems a bit weird  :blink:

Were you high on something when you wrote that Num?  B)
Title: Unassigned variable when using InstaWin
Post by: Numsgil on March 15, 2006, 05:00:21 PM
It was the first large project I had tried doing if I remember right.

The basic stuff wasn't too hard, but there were dozens of special cases that needed special code, and it quickly got messy.

I've since gotten better at anticipating coding complexity and forcing myself to design it properly.
Title: Unassigned variable when using InstaWin
Post by: Griz on March 15, 2006, 05:09:49 PM
hey ...
if if always works exactly like you expect it to ...
you never learn how to do anything new.
mistakes is where it's at, man ...
takin' you where you'd never go otherwise. ;)
Title: Unassigned variable when using InstaWin
Post by: EricL on March 15, 2006, 06:38:10 PM
Okay.  I traced Griz's DNALen out of range bug to the function League_Eyefudge in F1Mode.bas.  It adds a fake gene to the end of a bot in F1 mode so that the combatents don't have the same number of .eye statements.  

It's a huge hack (which the author well knew given the comments in the code and the name of the routine -  IMHO, bots should have and use GUIDs for species identification in the future) but the routine as it is is inadvertedly overwriting the end of the DNA and thus removing the tipo = 10, value = 1 at the end of the DNA casuing the run off in DNALen().

Changing lines 538 adn 539 in F1Mode.bas from

Code: [Select]
rob(robotnumber).DNA(t).tipo = 4
rob(robotnumber).DNA(t).value = 4

to the following:

Code: [Select]
rob(robotnumber).DNA(t).tipo = 10
rob(robotnumber).DNA(t).value = 1

fixes that specific issue.  The DNA will now be terminated correctly and DNALen will work properly without walking off the end of the DNA array.

To be sure, there are still a bunch of issues with leagues, but this fixes Griz's crash.
Title: Unassigned variable when using InstaWin
Post by: Numsgil on March 15, 2006, 11:30:27 PM
Thanks for fixing it.

The Eyefudge thing was something that seemed like a good idea when I started but quickly became unwieldly.
Title: Unassigned variable when using InstaWin
Post by: EricL on March 16, 2006, 12:30:06 AM
Reminds me of an old girlfriend...   :D
Title: Unassigned variable when using InstaWin
Post by: Griz on March 16, 2006, 07:17:53 AM
Quote
Reminds me of an old girlfriend...   :D
LOL  :lol:
so ...
just how old was she? ;)

hey ...
thanks Eric ...
will get this thing finetuned yet.
Title: Unassigned variable when using InstaWin
Post by: Griz on March 16, 2006, 07:35:04 AM
Quote
Changing lines 538 adn 539 in F1Mode.bas from

I do find the lines in Public Function League_Eyefudge

'end
    rob(robotnumber).DNA(t).tipo = 4
    rob(robotnumber).DNA(t).value = 4

I assume these are the lines you refer to ...
but ...
don't know where you guys get your line numbers from in VB
I don't find them ...
where they be?
Title: Unassigned variable when using InstaWin
Post by: EricL on March 16, 2006, 10:49:16 AM
Those be the lines.  In VB 6, the line and column numbers of where the cursor is located are displayed to the right of the standard toolbar.

And she swore she was over 18...  Perhaps I should have said it reminds me of my current marriage.  Oh, hey, did I type that outloud?