A.i enemies tf.js

I’m thinking about creating enemies in bjs and I do not know how to do it, I think in integrating tensorflow.js I think it’s the best option but I see it a bit complicated …

someone with experience in this regard who can help me maybe with some reference code or to know if I’m on the right track xd

1 Like

Soon I will also be dealing in more detail with the use of neural networks. I think brain.js is one of the easiest libraries to program artificial intelligence.

3 Likes

how about start with learning how to get one object to move towards a player (hint: vector math to get the direction, and then add a velocity to the position each frame to move)

then pathfinding, which is first setting up some sort of navigation data (grid, nav mesh, etc) and then calculating a path (use a library) and then moving along the path towards the target (similar math to moving one object)

then a finite state machine, which is used to alternate the character between moving towards the player and attacking the player (and eventually other behaviors)

if the FSM has more behaviors than idle, path towards player, attack player, then you’ve got 95% of game ai beat right there

learning that stuff from scratch is a couple weeks to several months for an experienced programmer

machine learning is not going to offer anything practical for most games without a large team and a large budget and some sort of data-heavy domain intrinsic to the game (sure it technically could do a lot of things, but in my experience most ai needs to be made worse at the game, not better)

3 Likes