Battle boat AI contest!
65 posts • Page 1 of 3 • 1, 2, 3
Battle boat AI contest!
Build your own AI for boat!
Rules are simple:
1) Write script
2) Copy it into box _AI property
3) Put your AI box on battle arena
4) Win (kill opponents or stay alive for 5 minutes and be closest to center)!
1st stage 1 feb 2013
Warm up:
You boat must win at least 2 of 3 matches 1 on 1 with 'Kilinich's dumb AI' to pass.
Qualification:
Series of matches for every possible pair 1 on 1 plus 2 'Dumb AI' (4 boats on field).
For win boat gain 3 point for 2-nd place 2 points for 3-rd place 1 point;
Best 4 boats pass to next round
Tournament:
5 rounds 4 x 4, same score, additional round if equal score for that boats
Winner gets prize: Scene on request
Link to tech docs
Rules are simple:
1) Write script
2) Copy it into box _AI property
3) Put your AI box on battle arena
4) Win (kill opponents or stay alive for 5 minutes and be closest to center)!
1st stage 1 feb 2013
Warm up:
You boat must win at least 2 of 3 matches 1 on 1 with 'Kilinich's dumb AI' to pass.
Qualification:
Series of matches for every possible pair 1 on 1 plus 2 'Dumb AI' (4 boats on field).
For win boat gain 3 point for 2-nd place 2 points for 3-rd place 1 point;
Best 4 boats pass to next round
Tournament:
5 rounds 4 x 4, same score, additional round if equal score for that boats
Winner gets prize: Scene on request
Link to tech docs
Last edited by Kilinich on Tue Jan 22, 2013 7:47 pm, edited 6 times in total.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Here it is template for AI box. You can use any local _variables, but not scene.my.
some helpful functions are already declared:
_angleDiff(a1, a2)
_sign(x)
_abs(x)
_dist(v)
_angle(v)
Code could be really simple, like that:
some helpful functions are already declared:
_angleDiff(a1, a2)
_sign(x)
_abs(x)
_dist(v)
_angle(v)
Code could be really simple, like that:
- Code: Select all
_AI = {mapCenter := _mapSize / 2;
_dist(_boatPos - mapCenter) > _mapSize(0) / 3 ? {
angleToCenter := _angle(mapCenter - _boatPos) + math.sin(sim.time) / 2;
_setBoatDirection(angleToCenter)
} : {_TargetDetected ? {_abs(_angleDiff(_radarDirection, _gunDirection)) < 0.2 ? {
_abs(_TargetRange - _gunRange) < 10 ? {_SetGunShoot(true)} : {_SetGunRange(_targetRange)}} : {_SetGunDirection(_radarDirection)}} : {_setRadarDirection(_radarDirection + _radarSector)}}
}
Last edited by Kilinich on Sat Dec 15, 2012 2:14 am, edited 3 times in total.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Let's start from basic!
Game engine will run _AI script 10 times per second.
You can give only 1 command (last given will work) per step.
You have 6 commands to control boat and equipment:
_setBoatDirection (angle)
_setBoatEngine (power)
_setRadarDirection (angle)
_setGunDirection (angle)
_setGunRange (distance)
_setGunShoot (true/false)
You can read some info from following variables:
_BoatDirection
_BoatSpeed
_BoatPos
_BoatVel
_BoatDamage
_RadarRange
_RadarSector
_RadarDirection
_TargetDetected
_TargetRange
_GunAmmo
_GunDirection
_GunRange
_GunReady
_GunReadyTimer
Here it is full tech spec:
https://docs.google.com/spreadsheet/ccc?key=0AuamFHyDQlL3dGJyM1lVQ1AwMmF1eldScUViVXpsT1E#gid=1
Game engine will run _AI script 10 times per second.
You can give only 1 command (last given will work) per step.
You have 6 commands to control boat and equipment:
_setBoatDirection (angle)
_setBoatEngine (power)
_setRadarDirection (angle)
_setGunDirection (angle)
_setGunRange (distance)
_setGunShoot (true/false)
You can read some info from following variables:
_BoatDirection
_BoatSpeed
_BoatPos
_BoatVel
_BoatDamage
_RadarRange
_RadarSector
_RadarDirection
_TargetDetected
_TargetRange
_GunAmmo
_GunDirection
_GunRange
_GunReady
_GunReadyTimer
Here it is full tech spec:
https://docs.google.com/spreadsheet/ccc?key=0AuamFHyDQlL3dGJyM1lVQ1AwMmF1eldScUViVXpsT1E#gid=1
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
This will be monthly contest!
First stage of AI battle: 01 feb 2013
Prize: Scene on request from me (I promise to make max possible ).
How to enter: Post as a scene response to that one!
First stage of AI battle: 01 feb 2013
Prize: Scene on request from me (I promise to make max possible ).
How to enter: Post as a scene response to that one!
Last edited by Kilinich on Mon Dec 31, 2012 12:50 am, edited 1 time in total.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Please be more specific about the "prize".
Thanks.
Thanks.
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
What is the rule for "who wins"? Is the winner the last boat that stayed alive, and all of the other boats were killed? Then what happens if there are two boats left, and they both fail to kill the other boat? Is the winner the boat with the fewer hits against it? Maybe you should implement a time period for the battle. Here's why: I ran a test battle with just the template (NO AI) in the RED boat. While the other three boats were battling each other, my red boat drifted off the battle area and ended up stuck on the right side of the score bars. The blue boat ended up killing the other two colors, and was just patroling around the battle area without finding my red boat. My red boat had fewer hits against it, so, even though it had NO AI, it should have been the winner!!! But without a timeout, this particular game would have gone on forever.
EDIT -- You probably should make a rule that any boat that goes outside of the battle area becomes automatically disqualified. Agree?
EDIT -- You probably should make a rule that any boat that goes outside of the battle area becomes automatically disqualified. Agree?
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Another question: Does your function that you call "_angleDiff" compute the dot product of two angles? I cannot determine what you are doing by reading your script.
Thanks!
Thanks!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Xray wrote:..game would have gone on forever.
EDIT -- You probably should make a rule that any boat that goes outside of the battle area becomes automatically disqualified. Agree?
Yes, you right. Thar's why it's beta I think I'l add timer for game and winner declared only if it kills everyone in time.
Limit 5 minutes. Winner is who will be closest to the center of the map.
Last edited by Kilinich on Sat Dec 15, 2012 2:02 pm, edited 1 time in total.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Xray wrote:Another question: Does your function that you call "_angleDiff" compute the dot product of two angles? I cannot determine what you are doing by reading your script.
Just calculation of difference between two angles. Both angles can be -inf + inf (rad). Result within -pi + pi.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Xray wrote:Please be more specific about the "prize".
Couldn't think of anything better than that. For example you want some car or airplane or game...
I'll do my best to make it.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Sorry for so many questions, but I have a couple more. I noticed in your sample AI scripts that you do not use the variable _GunReady before you fire the gun. Is it not necessary to check _GunReady? Why did you make that variable if it is not needed?
Thanks
EDIT - Another question! In your "Smarter AI" script, you pass an argument "angleToCenter" in your function call "_setBoatDirection". Where did that argument come from? I don't see it in your specification, nor do I see it in other parts of your scripts. Are there any other constants, variables or functions that aren't listed that would be helpful to us who are considering entering your contest?
Thanks
EDIT - Another question! In your "Smarter AI" script, you pass an argument "angleToCenter" in your function call "_setBoatDirection". Where did that argument come from? I don't see it in your specification, nor do I see it in other parts of your scripts. Are there any other constants, variables or functions that aren't listed that would be helpful to us who are considering entering your contest?
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Xray wrote: I noticed in your sample AI scripts that you do not use the variable _GunReady before you fire the gun. Is it not necessary to check _GunReady? Why did you make that variable if it is not needed?
That's because my AI is pretty dumb
If you set setGunShoot = true, gun will fire then it will be ready, but situation on field may change, so that's why you need to check _gunReady.
EDIT - Another question! In your "Smarter AI" script, you pass an argument "angleToCenter" in your function call "_setBoatDirection". Where did that argument come from? I don't see it in your specification, nor do I see it in other parts of your scripts. Are there any other constants, variables or functions that aren't listed that would be helpful to us who are considering entering your contest?
it's declared inside AI code (2-nd line):
angleToCenter := _angle(mapCenter - _boatPos) + math.sin(sim.time) / 2;
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Kilinich wrote:it's declared inside AI code (2-nd line):
angleToCenter := _angle(mapCenter - _boatPos) + math.sin(sim.time) / 2;
My eyes passed right over that without seeing it! Thanks!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Kilinich -- I noticed that the five minute timer is not accurate because it is based on sim.time. Therefore, the time period lags if the simulation lags. So, I modified my version of the scene to use system.time instead of sim.time, and now the five minute timer is more accurate. I placed the following code in airFrictionMult in the box that displays the time:
I created those two local variables, _time and _CorrectedTime, and I replaced every sim.time in your timer code with _CorrectedTime. That is how I did it, but you might have a more elegant method that works equally well, with less code.
- Code: Select all
{
sim.running ? {_CorrectedTime = system.time - _time} : {_time = system.time};
1.0
}
I created those two local variables, _time and _CorrectedTime, and I replaced every sim.time in your timer code with _CorrectedTime. That is how I did it, but you might have a more elegant method that works equally well, with less code.
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
We prefer to run off sim.time, Sometimes part of the lag is caused by software issues we can't control, such as antivirus software and the sorts. The computer is a complex environment, and I believe it should be kept fair, thus running off sim.time is the correct way to go.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Battle boat AI contest!
electronicboy wrote:We prefer to run off sim.time, Sometimes part of the lag is caused by software issues we can't control, such as antivirus software and the sorts. The computer is a complex environment, and I believe it should be kept fair, thus running off sim.time is the correct way to go.
I suppose you can look at it from the perspective that even though Algodoo lags due to situations that are outside of Algodoo, five minutes is still five minutes even though in the real world it may actually be 7 or 8 minutes. If Kilinich's five minute time clock slows due to lag, then the entire Algodoo scene will also slow due to the same lag, and therefore lag doesn't matter. I didn't think of it that way before I posted. Thanks electronicboy!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Kilinich wrote:First stage of AI battle: 02.01.2013
Is that date January 02, or February 01? Here in the U.S., we usually put the month before the day, and in other countries, they put the day before the month. Which is it?
Also, how do I send my AI box to you without anyone else seeing it? I want to keep it a secret until the day of the battle!
EDIT -- Sorry, I have more questions.....
1. The function _setBoatEngine doesn't seem to make any difference no matter what value I set it to within the range shown in your spreadsheet. Is the boat supposed to go fast if I set it to 1.0, and go slow if I set it to -1.0?
2. It seems that if I string two functions in series, then they do not work. For example: _SetGunRange(_targetRange); _SetGunDirection(_radarDirection); When I string them together like that, then the commands have no effect. Please confirm if what I am reporting is true.
I'll probably have more questions later.
Thanks!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Xray wrote:1. The function _setBoatEngine doesn't seem to make any difference no matter what value I set it to within the range shown in your spreadsheet. Is the boat supposed to go fast if I set it to 1.0, and go slow if I set it to -1.0?
2. It seems that if I string two functions in series, then they do not work. For example: _SetGunRange(_targetRange); _SetGunDirection(_radarDirection); When I string them together like that, then the commands have no effect. Please confirm if what I am reporting is true.
1. Must work like this: -1 backward, 0 stop, 1 - forward, 0.5 slow forward, etc.
2. Only last _Set command will work.
I need to check it for bugs.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Kilinich wrote:
1. Must work like this: -1 backward, 0 stop, 1 - forward, 0.5 slow forward, etc.
The problem is, it doesn't work at all. As I said, it doesn't matter what value I pass to it, it makes no difference in the speed of the boat. Maybe the problem is related to my other comment about functions in series not working.
Kilinich wrote:
2. Only last _Set command will work.
I need to check it for bugs.
That's not very good code. How can I command more than one function if it only works with the last one entered?
And what about my other questions? I asked about the date, and also about sending you my AI box.
Thanks
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Xray wrote:Kilinich wrote:2. Only last _Set command will work.
That's not very good code. How can I command more than one function if it only works with the last one entered?
the idea is that you can give only one command per tick, so you need to choose wich one.
give me a second, i'll answer the rest
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
_setBoatEngine bug fixed. Main scene updated.
1-st battle day is 1 feb 2013
1-st battle day is 1 feb 2013
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Xray wrote:I created those two local variables, _time and _CorrectedTime, and I replaced every sim.time in your timer code with _CorrectedTime. That is how I did it, but you might have a more elegant method that works equally well, with less code.
yea, maybe I'll replace sim time to game ticks count (10 per second * 60 * 5)
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
Xray wrote:Also, how do I send my AI box to you without anyone else seeing it? I want to keep it a secret until the day of the battle!
You can post it as reply and delete it. I'll see it anyway (as admin on algobox) .
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Battle boat AI contest!
_setBoatEngine works like it's supposed to now.
Do you have any suggestions for dealing with the requirement of one _set command per sim tick? Besides setting and decrementing flags in order to run multiple _set commands over a number of sim ticks, I don't know how else to do it. Any hints or tips would be appreciated (by me and by other Battle Boat sea captains)!
EDIT -- Never mind! I figured out how to deal with it.
EDIT - Another question just came up..... The variable _radarDirection on your spreadsheet shows that it has a range of -pi to +pi rads, but in the script menu for my AI Box, the value goes from zero to 2pi rads as the radar is rotating. After further investigation, I found that it's the same thing for _gunDirection and _BoatDirection. Is your spreadsheet incorrect?
Thanks
EDIT -- A minor bug.... The five minute timer does not stop at zero, but continues counting negative seconds! Timer should stop at zero and probably set sim.running = false.
btw - HAPPY NEW YEAR EVERYONE!
Do you have any suggestions for dealing with the requirement of one _set command per sim tick? Besides setting and decrementing flags in order to run multiple _set commands over a number of sim ticks, I don't know how else to do it. Any hints or tips would be appreciated (by me and by other Battle Boat sea captains)!
EDIT -- Never mind! I figured out how to deal with it.
EDIT - Another question just came up..... The variable _radarDirection on your spreadsheet shows that it has a range of -pi to +pi rads, but in the script menu for my AI Box, the value goes from zero to 2pi rads as the radar is rotating. After further investigation, I found that it's the same thing for _gunDirection and _BoatDirection. Is your spreadsheet incorrect?
Thanks
EDIT -- A minor bug.... The five minute timer does not stop at zero, but continues counting negative seconds! Timer should stop at zero and probably set sim.running = false.
btw - HAPPY NEW YEAR EVERYONE!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Battle boat AI contest!
Looks like the best contest I've seen. This will be every month? I'd like to try several times.
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-
mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
65 posts • Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 1 guest