Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] more small directional cleanups
Home

[Freeciv-Dev] Re: [PATCH] more small directional cleanups

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] more small directional cleanups
From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
Date: Wed, 22 Aug 2001 20:35:48 -0700 (PDT)

On Wed, 22 Aug 2001, Ross W. Wetmore wrote:
> >It's not so much calling it when there're are no possibilities, but that you
> >depend on randomly finding one of the valid neighbors.  You could guess a
> >random number 1000 times and still not find it.  It seems bad to me
> >to depend on "luck" to keep your code from locking up.
> 
> I'm not sure I'm concerned about the 1000 failure case. The universe is
> something like 10^30 nanoseconds old, and the probability you are worried
> about is 1 in 10^500 or so.

What if the random number generator isn't prefect?

> But would you be willing to amalgamate the flavours to something like this?

I really don't like this version at all.  It's longer.  You duplicate the
exact same code inside and outside the loop.  The do/while loop is more
difficult to understand than the simple for loop.  You have two different ways
to return, but neither one is some kind of error condition.  It's not the
slightest bit faster.  And you depend on the enum's having values 0-7.  What
if I want them to be 1-8, and have 0 mean the center tile?  I can't see any
reason to make an assumption about the numbering, it gives you nothing.



[Prev in Thread] Current Thread [Next in Thread]