Page 1 of 3

ROFLBot Progress

Posted: Wed Feb 24, 2010 1:12 am
by roflamingo
My code will never be as beautiful or fast as Martin's... and my strategy will never be as good as Ace's :D

Up to this point, the bot will:

Tick 1 - Defcon 5
1. [DONE] Enumerate important things (who am I , who are they)
2. [DONE] Determine where it wants to start placing ground units, based on what I consider to be the core ( the city that has the most close neighbors, unweighted by pop)
3. [DONE] Deploy 3-4 'forward radar' (= radars positioned to look at neighboring lands and oceans, not intended to be used in defense).
- The forward radar can be anywhere that is not within 1.8 units of a city.
- The code starts at the core city, jumps out 90 units, and starts coming back in 5 units at a time circularly. If it can place a radar, it does. The compass is divided into sectors depending on the # of forward radar chosen. Once a forward radar has been deployed into a sector (which will be either 72 or 90 degrees wide - either 5 or 4 forward radar), that 'sector' will not be reused. Thus forward radar is spread out properly in multiple directions.
4. [Not written yet] Deploying forward subs and sending on their way
5. [DONE] Deploying scout battleships and sending on their way to the best scouting position


Tick 1 - Defcon 4
1. [DONE]Start trying to place the silos.
- Start at the core and work way out. a position is valid if
a. there is no city within 1.8 units
b. enemy territory is not within 20 units
2. [DONE]Repeat process for airbases
3. [DONE]Repeat process for remaining radar (= defensive radar).
[ Note: these parts really suck if the bot is Europe with Africa and Russia as playing opponents ]
4. [Not written yet] Fleet placement

Screenshots:
Image
Image
Image

I can post code if you guys want...or forget it if you are already way ahead!

Posted: Wed Feb 24, 2010 1:29 am
by martin
My bot draws circles on citites, I think in the leader board at the moment I'm behind you (even if my code is prettier ;) )

Posted: Fri Feb 26, 2010 10:24 pm
by roflamingo
Question:

Say you new a bunch of your own ocean co-ordinates and had them in a table. (Literally hundreds of co-ordinates)

How could you best determine that you have 2 separate oceans to consider placing in? (i.e. you are South America).

Posted: Fri Feb 26, 2010 10:33 pm
by Ace Rimmer

Code: Select all

Me = TeamIDMe
You = TeamIDYou

If IsValidTerritory(Me, x, y, isSeaAreaTrue) Then
   If IsValidTerritory(You, x, y, isSeaAreaTrue) Then
      SendChat("Is double Ocean)
   else
      SendChat("my prehchous!")
      SendBotAction(Stroke Ring)
   end
end


:idea: :?:

Posted: Fri Feb 26, 2010 10:41 pm
by roflamingo
That's the code to find out if a particular ocean piece is shared. I'm already using that and placing battleships there :D

I'm looking for a different kind of algorithm here. SA, NA, Asia, Africa, Russia all have 2 discontiguous ocean areas for placing fleets in.

Say you were SA vs. Russia and you were placing fleets - 2 separate oceans to start from and coasts to defend... and 2 separate starting points for launching an attack on Russia....

Posted: Fri Feb 26, 2010 10:51 pm
by Ace Rimmer
Ah, whoops, I misread your question. D'uh!

Perhaps find the 'center most point' of your ocean and if it's on land, you have two oceans?

Posted: Fri Feb 26, 2010 11:00 pm
by roflamingo
I was thinking something like that. What do you think of this?

Start at an arbitrary point in your known ocean space. x1,x2. This is in ocean 1.
Now iterate through the rest of your points. (x2,y2....)
If a point is within an arbitrary distance then not a separate ocean (this avoids little bumps and nubs of land between 2 points)
If it's outside of the arbitrary distance then check the midpoint. If that midpoint is land then the 2nd point is in a differnt ocean.

Need to find formula for calculating midpoint of (x1,y1) and (x2,y2).... got 1 handy?! :D

nvm... should be x3,y3 = (x1+x2)/2, (y1+y2)/2

Posted: Fri Feb 26, 2010 11:03 pm
by Montyphy
If you're going to hard code a known part of ocean you may as well hard code the knowledge of how many oceans there are. It's not like a bot is even really able to tell if a land mod is installed.

Posted: Fri Feb 26, 2010 11:04 pm
by Ace Rimmer
roflamingo wrote:Need to find formula for calculating midpoint of (x1,y1) and (x2,y2).... got 1 handy?! :D

x2+x1 /2
y2+y1 /2



:?:

Posted: Fri Feb 26, 2010 11:17 pm
by roflamingo
Montyphy wrote:If you're going to hard code a known part of ocean you may as well hard code the knowledge of how many oceans there are. It's not like a bot is even really able to tell if a land mod is installed.


I'm not hardcoding anything, exactly with what you said in mind (I think). Every co-ordinate is dynamically calculated every game and I have no static data points, because land/ocean definitions are not guaranteed from game-to-game.

Posted: Fri Feb 26, 2010 11:26 pm
by Ace Rimmer
Just remember when placing fleet:

Even if you use separate PlaceFleet (longitude, latitude, type1 [, type2 [, type3 [, type4 [, type5 [, type6]]]]]) commands, if you place multiple ships in the same cycle or tick, you end up with One Fleet. Therefore, you CAN place one ship in the Atlantic and another ship in the Pacific, and those two ships be in the Same Fleet. This means you can't give the two ships different movement targets (only one movement target per fleet).

E.g.

Tick1
PlaceFleet (x, y, BattleShip)
PlaceFleet (c, d, Carrier)
Tick2

is = to:

PlaceFleet(x/c, y/d, BattleShip, Carrier)

You are given something like:

BB ObjectID = 25, FleetID = 1
CV ObjectID = 26, FleetID = 1

On the other hand

Tick1
PlaceFleet (x, y, BattleShip)
Tick2
PlaceFleet (c, d, Carrier)

is = to:

BB ObjectID = 25, FleetID = 1
CV ObjectID = 26, FleetID = 2

Posted: Sat Feb 27, 2010 1:57 am
by martin
Ace Rimmer wrote:
roflamingo wrote:Need to find formula for calculating midpoint of (x1,y1) and (x2,y2).... got 1 handy?! :D

x2+x1 /2
y2+y1 /2



:?:


(x + x2) / 2
(y + y2) / 2

fix'd ;)

Posted: Sat Feb 27, 2010 4:55 am
by xander
martin wrote:
Ace Rimmer wrote:
roflamingo wrote:Need to find formula for calculating midpoint of (x1,y1) and (x2,y2).... got 1 handy?! :D

x2+x1 /2
y2+y1 /2



:?:


(x + x2) / 2
(y + y2) / 2

fix'd ;)

Ace's version is more correct than yours. :P

xander

Posted: Sat Feb 27, 2010 3:13 pm
by martin
Oh really? Why's that?

Posted: Sat Feb 27, 2010 4:23 pm
by xander
martin wrote:Oh really? Why's that?

Generally speaking, x and y are variables, while x_n and y_n are specific values that those variables take on. When finding the midpoint of a line segment, you take the average of the x and y values of the endpoints. You would label one endpoint (x_1, y_1), and the other endpoint (x_2, y_2), then take the average coordinate-wise. Hence the midpoint is given by (x_m, y_m) = ((x_1+x_2)/2, (y_1+y_2)/2).

xander