lamorric / ai-contest

Automatically exported from code.google.com/p/ai-contest
0 stars 0 forks source link

Review request - map generator no longer creates planets 1 apart, nor "too close" starting planets #179

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
tl;dr: Starting planets too close to center or each other more than 1 in 200 
times, 1-growth planets can be 1 apart. This change fixes these.

Purpose of code changes on this branch:
Examination of the current map generator yields the following observations:
The too_close function is not called for the starting planets.
The distance threshold for two 1-growth planets is .8, meaning distances of, 
say, .85 could occur.

As coordinates are chosen randomly in [-12, 12) x [-12, 12), a starter planet 
could be distance 1 from the center, if the coordinate is in a small portion of 
the center (a circle with radius 1). The math indicates the probability of this 
is pi/(24^2), about .545%. The starting planets would be 1 apart from each 
other if the coordinate is in a circle of radius .5, which occurs with 
probability .25 * pi/(24^2), or about .136%.

I added a simple check that to rule out distances of 1 or less, and added a 
function to check for closeness of the starting planets.

After the review, I'll merge this branch into:
/trunk/planet_wars/backend

Original issue reported on code.google.com by jokeserver on 27 Sep 2010 at 5:43

GoogleCodeExporter commented 9 years ago
Will any planets (such as zero-growth ones) be able to be 1 turn from each 
other? 

IIRC this currently leads to some strange edge-cases when it comes to the 
departure/advance/arrive code and fleet state lines.

Original comment by hage...@gmail.com on 28 Sep 2010 at 6:56

GoogleCodeExporter commented 9 years ago
I am not sure whether you are asking whether my change makes it possible or 
whether it is already possible. The answer is that it is already possible. Two 
planets that are 0- or 1-growth can be within 1 unit of each other.

The strange edge-cases are the reason they shouldn't be 1-unit apart. It 
appears from a cursory glance at engine.py that the fleets are handled 
correctly (launched with 1 turn left, then fleets advance, then they land), but 
players will never see these fleets, only the changing sizes on the effectively 
adjacent planets.

Original comment by jokeserver on 29 Sep 2010 at 4:48

GoogleCodeExporter commented 9 years ago

Original comment by jokeserver on 30 Sep 2010 at 2:38