Author Topic: Runtime error 11 in Mutation rates dialog  (Read 3669 times)

Offline frankle

  • Bot Neophyte
  • *
  • Posts: 21
    • View Profile
Runtime error 11 in Mutation rates dialog
« on: December 16, 2006, 10:49:05 PM »
Start DB
Start new sim
Robots->mutation rates

Runtime error '11'
division by zero

Offline Sprotiel

  • Bot Destroyer
  • ***
  • Posts: 135
    • View Profile
Runtime error 11 in Mutation rates dialog
« Reply #1 on: December 16, 2006, 11:24:12 PM »
Well spotted!

Welcome to DarwinBots!

I suspect it's a matter of the program trying to access the mutation settings of a non-existent species. If you select your robot species first, you shouldn't have problems.

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Runtime error 11 in Mutation rates dialog
« Reply #2 on: December 17, 2006, 06:32:44 AM »
Hiya Frankle,

Thanks for letting us know about this bug. As Sprotiel suggested there is a way to avoid this bug for now but hopefully it will get fixed sometime soon.

Hope to see you again on the forum and welcome to DB!
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline frankle

  • Bot Neophyte
  • *
  • Posts: 21
    • View Profile
Runtime error 11 in Mutation rates dialog
« Reply #3 on: December 17, 2006, 10:00:59 AM »
I tested it this morning with bots running in the sim, and it still crashed. Same repro. Has anyone else reproduced this or is it just me?

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Runtime error 11 in Mutation rates dialog
« Reply #4 on: December 17, 2006, 11:48:34 AM »
I reproduced it before posting a reply earlier. The way round it is to start the sim, select one of the bots in the sim, then open mutations. (or so I thought)

Oh bugger, 400k cycles into a league match (DIN v The One) and managed to crash it by having another look.  

I don't seem to be able to consistently avoid that problem; it can happen with a bot selected when you select robots/mutations or when you r/click on a bot and open mutations, doesn't seem to make much difference if sim is paused or running.

I presume you want to change mutation rates while you have a sim running, I know it is possible, some people do it. We'll just have to wait until they tell us how...  

I only ever set mutations before start of sim so don't know how they do this, sry.

EDIT

In fact, I just thought I'd check on mutation rates before starting a new league match, it done the same thing, v nasty. May have to download latest version of DB again or restart pc just to make sure I haven't messed anything up.

EDIT

It seems I had to delete the bots from the 'loaded species' list and put them back again to stop the error occuring when I tried to open mutation rates before starting a new sim. Starting again with new bots and selecting a bot before opening robots/mutations seems to work again. Will see if I can find out what I did to make it go so weird.

Last EDIT

And now the only way I can get it to crash is by opening robots/mutations without a bot selected, V. Strange.
« Last Edit: December 17, 2006, 12:23:35 PM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Runtime error 11 in Mutation rates dialog
« Reply #5 on: December 18, 2006, 06:14:00 PM »
The Mutation Rates menu item should be disabled when no bot is selected.  This is the ultimate cause of the divide by zero.  

In 2.42.9p and beyond, the Mutation Rates menu item will be disabled unless a bot is selected.

I cannot reproduce the crash when a bot is selected.  What I suspect is happening is that running leagues is messing up the data structure that underlies the species list box on the optiosn dialog.  The way the Mutation Rates dialog works when it is invoked from somewhere other than the optiosn dialog is to fake out an element in this structure using the bot with the focus.  Leauges is potentially messing up this fake out.  So, I suspect you will only be able to get it to crash even when a bot is selected only after running leagues.  If you have not run leagues that DB invocation, I bet it will not crash with a bot selected.

I will be spending mroe time on leagues thios week and may pick this up but the larger issue of crashing when no bot is selected is addressed in 2.42.9p and beyond.
Many beers....

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
Runtime error 11 in Mutation rates dialog
« Reply #6 on: January 01, 2007, 04:50:26 PM »
ver 2.42.9r

got this a couple of times ...
runtime error 11, division by zero ...
clicking the Mutations button on the Species page to ensure
a species doesn't have them enabled ... I got the error.

the last two times was coming back from having run
Leagues, wanting to run a special match between two
bots ... but this time outside of Leagues.
those bots happened to be in the Species window ...
and I clicked on one, then clicked on the Mutations button
to see if they were indeed disabled, and got the error.
now I didn't actually load that species in before doing so ...
as they were already listed ...
so that may be it.

anyway ...
when the problem does show up ...
as it seems to do on occasion ...
it leads me to this:

in MutationsProbability ...
line 134:
Probs(1).text = CStr(CLng(1 / Psome))

Psome = 0

Code: [Select]
Private Sub Probs_Change(Index As Integer)
  If Index = 0 Then
    
    If TmpOpts.Specie(optionsform.CurrSpec).Mutables.mutarray(Mode) = 0 Then
        TmpOpts.Specie(optionsform.CurrSpec).Mutables.mutarray(Mode) = 1
    End If
    
    TmpOpts.Specie(optionsform.CurrSpec).Mutables.mutarray(Mode) = val(Probs(Index)) * _
      Sgn(TmpOpts.Specie(optionsform.CurrSpec).Mutables.mutarray(Mode))
      
    'update summations...
    
    With TmpOpts.Specie(optionsform.CurrSpec).Mutables
    
    Dim Pnone As Single, Psome As Single
    
    Pnone = Anti_Prob(.mutarray(1)) * _
            Anti_Prob(.mutarray(2)) * _
            Anti_Prob(.mutarray(3)) * _
            Anti_Prob(.mutarray(5)) * _
            Anti_Prob(.mutarray(6))
    Psome = 1 - Pnone
          
          
    Probs(1).text = CStr(CLng(1 / Psome))
    End With
  End If
End Sub
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]