Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOT API Framework ... #76

Open
mithrendal opened this issue Dec 6, 2020 · 2 comments
Open

BOT API Framework ... #76

mithrendal opened this issue Dec 6, 2020 · 2 comments

Comments

@mithrendal
Copy link
Collaborator

mithrendal commented Dec 6, 2020

grafik

now that we have the stencil feature which is a present from virtualC64 V4 ... we can better analyse the playfield ... and drive our attention more to the important things of live and that is to win games ...

to make bot programming much more easy than now ... the idea is to write some classes which hide and abstract the computation of angles ... and only informs the bot class about important game events like "enemy is to your left" or "enemy diagonal right up of you" ...

class myBot extends Bot {
  incoming_event(event) {
      if( 1<event.other_sprite && event.other_sprite<7 )
      {
          aim_and_shoot(event.other_sprite);
      }
      if(event.other_sprite_position == 'left' || event.other_sprite_position == 'right')
      {
          move("down", 800); //move down 800ms
      }
  }
}
new myBot( sprite=0 ).run(port=1);  /* 0 is the sprite_id controlled by the bot*/


the self designed bot will extend the following base class which will give it the API to communicate and interact with ...


class Bot {
    constructor(sprite_id) 
//getter
    get x() 
    get y() 
    get port()

//methods
    distance(other_sprite)
    x(other_sprite)
    y(other_sprite)

    aim_and_shoot(other_sprite_id) 
    move(direction, time) 
    run(controller_port) 
}
@mithrendal
Copy link
Collaborator Author

mithrendal commented Dec 7, 2020

I am ready with the base Bot class ... with the help of the new BOT API we greatly reduced the complexitiy of bot code (compare that to the archon aim bot code in #60 ...)

see here how the "oversimplified" ArchonAimBot now looks like ...

js:
class ArchonBot extends Bot {
    async next_event(event) {
        if( event.other_sprite == 1 )  this.aim_and_shoot(event);
    }
}

await new ArchonBot(process_id=this_id, sprite=0).run(port=1);

In words it does the following ... whenever there comes an event for sprite1 aim and shoot back into direction of sprite1 ...

maybe I oversimplified the whole thing a bit too much ? Hmm lets test it out tomorrrow how it does when we run it in falcon patrol ...

@mithrendal
Copy link
Collaborator Author

mithrendal commented Dec 11, 2020

it turns out that the falcon patrol auto defense bot which should control the falcon patrol plane has to be much more sophisticated logic wise compared to the relatively simplistic Archon aim bot. I mean it is a completely different level of complexity to master this piece of logic …

and that is for a few reasons

  1. plane flights in a direction left or right ... when flying left it can shoot only left and diagonally left down but not to the right nor up … likewise when flying right it can not shoot to the left ...
  2. when flying to the left and enemy is approaching from the right it has to practise a turn first in which it has to slow down speed and turn … this operarion takes some seconds…
  3. plane can fly at different speeds
  4. enemies flying at different speeds
  5. enemies changing their speeds
  6. multiple fast moving enemies compared to only one in Archon
  7. plane can not shoot up nor directly down so here the plane is most vulnerable

buddy we have to find strategies …

we have to implement different strategies depending on where the enemies approaching and how many there are

here are some which come to my mind …

  1. when enemy is approaching us from the direction in which we are flying we shoot it more precisely when it is approaching us from the same altitude or a lower altitude (because you can not shoot up)
  2. when it is approaching us from a higher altitude than we are currently at … fly up to but only when distance is still big enough otherwise we would collide
  3. prevent collision … when it is approaching us from higher altitude and distance is very small … go down to prevent collision…
  4. when enemy is approaching from the opposite of the flight direction it depends… when distance is very great then turn plane to be able to shoot … when distance is very low try to go down or up (depending on our planes altitude (we have to have enough space for that manoeuvre to avoid collision)
  5. for avoid crashing to ground we have to steer up when our altitude gets too low …

we have already working 1. and 5. … this is really a complex game to control compared to archon

grafik

grafik

help and ideas are very much appreciated...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant