Author Topic: Dogfighting  (Read 3107 times)

Offline googlyeyesultra

  • Bot Destroyer
  • ***
  • Posts: 109
    • View Profile
Dogfighting
« on: August 19, 2007, 12:10:29 PM »
Essentially, I'm working on creating a new bot with a tentative title of "Sharpshooter". It's designed to accurately predict where it should aim in order to make the shot hit you, without matching your velocity (well, at this point, it does match your velocity, but only because I haven't figured out a cool dogfighting routine yet). Essentially, it won't care much (when I finish coding it), at least when fighting instead of feeding, whether or not the returning energy hits it. All it will try to do is pump the enemy full of shots and duck and weave to prevent any returned fire from hitting it. It's kindof a large bot, so it'll have to be really good at dodging. So far I've got most of the basic code together, as well as a prototype of the advanced aiming. I'm holding off on shell, slime, etc. until I've got most of the other stuff working as planned. Essentially, any tips for dogfighting or aiming code that would work for this would be much appreciated. Or, well, code itself, if you're really nice. Thanks.

Code: [Select]
'Sharpshooter: A bot by googlyeyesultra.
'It semi-accurately leads targets.

cond
start
'Conspec
*.myeye *.myshoot add *.myup add 998 *.robage sgn 1 sub -1 mult mult store

'Sharefeed if multi
99 .sharenrg *.multi mult store
.sharewaste *.multi mult inc

'Set eyewidth
1221 .eye5width *.robage sgn 1 sub -1 mult mult store
stop

'Reproduce
cond
*.nrg 25000 >=
*.nrg 2 div *.body ~=
start
49 .repro store
stop

'Conspec
cond
*.refeye *.refshoot add *.refup add *.refshell add *997 !=
start
*.refeye *.refshoot add *.refup add *.refshell add 997 store
stop

'Birthie cut
cond
*.robage 2 <
start
.tie *.robage -1 mult 1 add mult inc
.deltie inc
stop

'Shoot feed
cond
*.eyef 0 >
*997 *998 !=
*.refpoison *.refshell >=
start
*.refxpos *.refveldx *.veldx sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add *.refypos *.velup *.refvelup sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add dist 30 div -1 mult .shootval store
-6 .shoot store
stop

cond
*.eyef 0 >
*997 *998 !=
*.refpoison *.refshell <
start
*.refxpos *.refveldx *.veldx sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add *.refypos *.velup *.refvelup sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add dist 30 div -1 mult .shootval store
-1 .shoot store
stop

'Deltie enemy ties/conspec ties
cond
*.numties 0 >
*.tiepres *996 !=
*.trefshoot *.trefeye add *.trefup add *998 = or
start
*.tiepres .deltie store
stop

'Tie
cond
*.eyef 30 >
*997 *998 !=
start
998 rnd 1 add 996 *996 sgn -1 mult 1 add mult store
*996 .tie store
stop

'Tiefeed/Counter leach
cond
*.numties 0 >
*.trefshoot *.trefeye add *.trefup add *998 !=
start
*996 .tienum store
*.tieval sgn .tieloc store
-1000 .tieval store
stop

'Regulate body/energy
cond
*.nrg 2 div *.body >
start
*.nrg 2 div *.body sub .strbody store
stop

cond
*.nrg 2 div *.body <
start
*.body *.nrg 2 div sub .fdbody store
stop

'Waste Removal
cond
*.waste 100 >=
start
-4 .shoot store
*.waste .shootval store
stop

'Aiming
cond
*.eyef 0 >
start
*.aim *.refxpos *.refveldx *.veldx sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add *.refypos *.velup *.refvelup sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add angle sub .aimshoot store
stop

'Orientation
cond
*.aim 314 !=
start
314 .setaim store
stop

'Search
cond
*.eyef 0 =
*.velscalar 10 <
start
50 4 rnd store
stop

'Movement
cond
*.eyef 0 >
*997 *998 !=
start
*.velup *.refvelup sub *.refypos *.ypos sub 2 div dup .dn store
*.refveldx *.veldx sub *.refxpos *.xpos sub 2 div dup .dx store
stop

'Avoid conspecs
cond
*.eyef 0 >
*997 *998 =
start
200 *.velup *.refvelup sub *.refypos *.ypos sub 2 div add sub .dn store
200 *.refveldx *.veldx sub *.refxpos *.xpos sub 2 div add sub .dx store
stop

'Chameleon genes
cond
*.in1 0 !=
*.in1 *.out1 !=
start
*.in1 .out1 store
stop

cond
*.in2 0 !=
*.in2 *.out2 !=
start
*.in2 .out2 store
stop

'Some various code defenses
cond
*.fixed 0 !=
start
0 .fixpos store
stop

cond
*.delgene 0 !=
start
0 .delgene store
stop

cond
*.shoot -2 =
start
0 .shoot store
stop

cond
*.mrepro 0 !=
start
0 .mrepro store
stop

cond
*.sexrepro 0 !=
start
0 .sexrepro store
stop

cond
*.repro 49 !=
*.repro 0 !=
start
0 .repro store
stop

'Antivirus
cond
*.mkvirus 0 !=
start
*.mkvirus .delgene store
0 .mkvirus store
stop

'End of Program
end

Essentially, if you're facing upwards, this code snippet will return where it thinks the targeted bot will be (Factoring in my movement as well).

Code: [Select]
*.refxpos *.refveldx *.veldx sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add *.refypos *.velup *.refvelup sub *.refxpos *.refveldx *.veldx sub add *.refypos *.velup *.refvelup sub add dist 40 div mult add
Also, it's alot easier to see it leading targets if it is set to "voluntary movement disabled".
« Last Edit: August 19, 2007, 04:32:51 PM by googlyeyesultra »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Dogfighting
« Reply #1 on: August 20, 2007, 12:19:22 AM »
If you don't care too much about getting the returning energy, you're probably better off with a smaller bot that's harder to hit.  You can also use negative shootvals and keep out of range of the other bot.

Offline googlyeyesultra

  • Bot Destroyer
  • ***
  • Posts: 109
    • View Profile
Dogfighting
« Reply #2 on: August 20, 2007, 08:31:44 AM »
I'm using the negative shootvals already. Really, the only reason I'm going this large is because powering up the shootvals enough to get the same range on a small bot is really, really expensive, and small bots don't have much energy to spare. Hmm, another way to do it would be to predict where and when the returning shots would be, based on the velocities, store that in a queue, and go run around and grab them while constantly firing.

You see, this is why I want trig functions. Now I've got to go make them. Somehow. Or, some sort of an angle to slope function. Or something.
« Last Edit: August 20, 2007, 10:33:15 AM by googlyeyesultra »

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
Dogfighting
« Reply #3 on: August 23, 2007, 09:48:10 AM »
Guardian uses a two-step approximation (iirc) for position rather than a one-step, and it still looks pretty. If your accuracy takes a hit when the enemies aren't within the right range you might want to take a look at that.
Solving for the intersection of shot and enemy is the equivalent of solving a quadratic, so when you're using a linear approximation, more steps is good.
« Last Edit: August 23, 2007, 09:49:44 AM by abyaly »
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)