ROFLBot Progress

Come in here to talk about your sky-net style world-destroying super bots!

Moderator: Defcon moderators

User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

ROFLBot Progress

Postby roflamingo » Wed Feb 24, 2010 1:12 am

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!
Last edited by roflamingo on Fri Feb 26, 2010 10:22 pm, edited 2 times in total.
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Wed Feb 24, 2010 1:29 am

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 ;) )
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Fri Feb 26, 2010 10:24 pm

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).
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Fri Feb 26, 2010 10:33 pm

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: :?:
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Fri Feb 26, 2010 10:41 pm

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....
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Fri Feb 26, 2010 10:51 pm

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?
Smoke me a kipper, I'll be back for breakfast...
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Fri Feb 26, 2010 11:00 pm

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
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Fri Feb 26, 2010 11:03 pm

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.
Uplink help: Check out the Guide or FAQ.
Latest Uplink patch is v1.55.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Fri Feb 26, 2010 11:04 pm

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



:?:
Smoke me a kipper, I'll be back for breakfast...
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Fri Feb 26, 2010 11:17 pm

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.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Fri Feb 26, 2010 11:26 pm

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
Smoke me a kipper, I'll be back for breakfast...
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Sat Feb 27, 2010 1:57 am

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 ;)
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Sat Feb 27, 2010 4:55 am

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
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Sat Feb 27, 2010 3:13 pm

Oh really? Why's that?
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Sat Feb 27, 2010 4:23 pm

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

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 3 guests