Where to Start?

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

Moderator: Defcon moderators

Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Where to Start?

Postby Th3xpl0iT » Wed May 19, 2010 5:33 pm

I really want to write a Bot AI, either in Lua or C++, but I don't know where to start or how. Can someone PLEASE point me in the right direction.. Maybe give me some steps in starting?

- Th3xpl0iT
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Wed May 19, 2010 5:34 pm

This is a very good place to start: http://www.doc.ic.ac.uk/~rb1006/projects:api

It has all the information you need for Lua and C++ (I think).
Smoke me a kipper, I'll be back for breakfast...
Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Postby Th3xpl0iT » Wed May 19, 2010 6:27 pm

Yeah I looked there, I didn't know where to click. Is there a tutorial on this forum, or no?
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Wed May 19, 2010 6:48 pm

No tutorial.

How much information do you need? That page has everything you need to get started; the Defcon API for LUA, Defcon 1.57 (bot-enabled version), documentation (some is included in the downloads.
Smoke me a kipper, I'll be back for breakfast...
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Wed May 19, 2010 6:53 pm

Th3xpl0iT wrote:Yeah I looked there, I didn't know where to click. Is there a tutorial on this forum, or no?


Tutorial for what exactly? How to program? How to code in Lua? How to make an AI? How to use the API? There should be an example bot included with the API on the above link which, providing you know a little about how to code in your chosen language, should get you going. Possibly the closest thing to a tutorial is this, an explanation of how and why to use the yield feature in the Lua API since it can be a bit tricky to get your head around but nothing really more specific than that.

If you get stuck or have a particular problem you can just post here and people will normally help if they can. Alternatively you can try reading through some of the threads here as they'll include snippets of code and document times when people slipped up.
Uplink help: Check out the Guide or FAQ.
Latest Uplink patch is v1.55.
Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Postby Th3xpl0iT » Wed May 19, 2010 7:05 pm

Maybe I should give an example..

I guess I can piece it together but I want to see what you guys say first. I want my bot to launch a nuke at New York when Defcon 1 hits. What would that look like? Two variables and an if/then statement?
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Wed May 19, 2010 7:54 pm

Th3xpl0iT wrote:Maybe I should give an example..

I guess I can piece it together but I want to see what you guys say first. I want my bot to launch a nuke at New York when Defcon 1 hits. What would that look like? Two variables and an if/then statement?


Step 1, determine if NA is playing. (loop and if)
Step 2, determine what continent you are. (if)
Step 3, determine where to place your silos based on your given continent. (loop and if)
Step 4, Wait til Defcon 1. (if)
Step 5, Get New York object/location. (get)
Step 6, iterate through your silos targeting New York until all nukes fired. (loop and if)

How complex all that is depends on if you want it to be smart or dumb i.e. place silos based on population densities, enemy location, enemy placements, etc. or just hard code silo locations.
Last edited by Montyphy on Wed May 19, 2010 9:59 pm, edited 1 time in total.
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Postby Th3xpl0iT » Wed May 19, 2010 9:40 pm

Okay, I'll start working on that, thank you very much.

Now how about something simple but effective.

An enemy fires upon one of my units. I calculate the shot's origin and I fire back. Can you help me write the C++ code?
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Wed May 19, 2010 9:48 pm

Th3xpl0iT wrote:Can you help me write the C++ code?


Depends what you mean by help. Will I write it for you? No. Will I help troubleshoot the odd error and provide hints on optimisations in code you post? Yes. Although if you want to maximise your chances of receiving help I would suggest you use the Lua API since that's what most/all people here use and understand.
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Postby Th3xpl0iT » Wed May 19, 2010 9:58 pm

Well I'm brand new to this API, so I don't expect you to write it for me - But it would be nice for you to write it WITH me. :)

First I want the bot to identify itself, what continent it is so it can place it's fleets in certain places. What function can I do to do that?
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Wed May 19, 2010 10:11 pm

GetOwnTeamId
GetTerritoryId
GetCityIds
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Postby Th3xpl0iT » Wed May 19, 2010 10:15 pm

So how do I find out the x,y of a city? This bot will be a South American bot.
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Wed May 19, 2010 10:21 pm

GetLongitude
GetLatitude


You really should just read through the API documentation:
Quickstart
Function list
Constants
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
Th3xpl0iT
level1
level1
Posts: 17
Joined: Wed May 19, 2010 5:31 pm

Postby Th3xpl0iT » Wed May 19, 2010 10:28 pm

Okay so at the beginning of bool Bot::Update()

Code: Select all

     float longitude = m_game->GetLongitude(1);
     float latitude = m_game->GetLatitude(1);



Something like that?

EDIT: I am, but it's a little confusing..
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Wed May 19, 2010 10:30 pm

Providing 1 is a valid unitId, cityId, or eventId.
Last edited by Montyphy on Fri May 21, 2010 4:52 pm, edited 1 time in total.
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 5 guests