POV-Ray : Newsgroups : povray.text.scene-files : Weird Loop Behavior : Re: Weird Loop Behavior Server Time
15 Aug 2022 08:17:11 EDT (-0400)
  Re: Weird Loop Behavior  
From: Dave Blandston
Date: 13 Jul 2022 16:10:00
Message: <web.62cf2569a05c0a6d476c222a607c1b34@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> question re code - NSuccesses only gets updated after all prisoners have looked
> at their boxes?  wondering, ought that not be something like:
>
>   #if (!MatchFound)  // fail
>     #break
>   #else
>     // add to NSuccesses
>   #end



Thanks jr! The #break instruction that gets executed when MatchFound is false
stops one round of the exercise early as soon as one prisoner fails to find his
number, then the next exercise begins which is controlled by the #for (I...)
loop. NSuccesses does not count the number of individual prisoners who find
their numbers, it counts the number of successful exercises in which all
prisoners find their numbers. I think it would be interesting to count how many
individual prisoners succeed though because, due to the inadvertent discovery,
it's obvious that the success or failure of the exercise can be determined well
before all the prisoners have actually completed the search for their numbers.

There is one part of the simulation that needs to be improved first, which is
the part that puts a random slip in each box. The current code is extremely
inefficient and will take about a week to complete for one million prisoners. I
have an idea to speed this operation up significantly, which will be a fun
exercise of its own.

Have an awesome day!

Kind regards,
Dave Blandston


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.