Search Unity

Need Help on Enemy AI logic

Discussion in 'Game Design' started by ReLisK, May 1, 2023.

  1. ReLisK

    ReLisK

    Joined:
    Mar 18, 2023
    Posts:
    1
    I am a newby game dev (not new to programming) who has bit off more than he can chew here. I need help on what logic I should use to create my enemy AI. The premise of the game is, its a turn based game on a grid. You can only shoot from your left or right sides (or both). When it's the play phase you can select to either move Forward(vector3.forward)/Right(vector3.forward + vector3.Right)/Left(vector3.forward + -vector3.Right) for eg. and can chose to shoot if you want on both sides or one side. You can select up to 4 moves in total for eg. Forward and shoot left => right => left and shoot both sides => forward; or w.e you want. Once play phase is over the game then actually does all the moves for u and opponent at the same time 1 by 1. I have already built all of this in NGO but I also want an enemy AI for when a live opponent cant be found.

    Problem is I cant figure out a good way to make the enemy AI select its moves. I have narrowed down a few thoughts but have no idea how to go about this. Some simple things that makes sense are:
    1. If the AI enemy isn't within shooting distance of the player it shouldn't shoot or fear being shot.
    2. If AI sees that the player has made no moves the aim would be to get within distance - be at a 90 degree angle and shoot as much as it can.
    3. If AI sees that the player made only 1 move we also know where to aim for and shoot.
    4. Continuing on the above you can in fact know all possible places the player could end up depending on how many moves they select and maybe make a list of that but i'm not sure how that helps. I actually drew this out on a grid in paint. You an see the best spots to shoot from that cover the most ending positions and maybe just pick one of these at random (maybe weight the closer ones more heavily) but this sounds a bit crazy. I would also still need to think of at what point whilst moving to this "random best shooting spot" do I shoot. Do I just make it randomly shoot whilst traveling there.
    5. Additionally I was thing there should be an HP threshold where if HP>threshold keep trying to fight else attempt to move away.
    Overall I feel like there is a simple logic I could use to select moves that I am just missing. I also know that the point of enemy AI isn't to make it unbeatable. I want one that actually seems like its trying to win but players can outwit.

    First post here if this is wrong place let me know.