Hello. Thank you for your continuous support.
Now I'm making a game like Packman, and I'm making something like AI of enemy characters.
At that time, I could ask for the shortest route to take the item, but I asked because I didn't know how to write the program that I wanted to make efficient without asking for the shortest.
As a prerequisite, as a rule,
The strategy of the program that I want to write on my own is to write the program that gets the most points within 5 costs (for calculation reasons).Please teach me.
The language is C++.
Enemy characters are calculated by making maps on the array.
No matter what game you play, the idea of implementing AI is basically the same.Explore all the possibilities of every step, calculate the score for each of the possibilities, and choose the highest-scoring step.If it's a Pac-Man-like game, there's a possibility of up, down, left, right, left, right, right, left, right, right, left, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, left, right, right, right, left, right, right, right, right,In fact, there are walls, so all four ways won't work, and the branches will be a little less.
If there is a stochastic event such as a random warp, simply calculate the expected value.If you can calculate all your expectations in gambling, you'll find the best solution (although you'll only know that you'll lose if you repeat it).Also, while game conditions vary depending on the player's manipulation, strategies are often studied as minimax method (although this "strategy" may not necessarily agree with everyone in real-world games, it is objectively defined).
However, it is highly questionable whether it is necessary for AI in the game to seek such an optimal solution.Only some games, such as chess and shogi, need to find the best solution.
For example, if an enemy character takes such an optimal strategy in RPG, it becomes a monotonous movement in which every monster simply releases its most powerful skills and magic from the beginning until the MP runs out, and it never becomes an interesting game.Also, AI, which always takes the best solution, is not necessarily the strongest because the player reads the action.If you want to add unexpectedness to the enemy's movements, you have to add randomness to the movements, but this reduces the meaning of calculating the best solution.
In fact, even a simple AI that changes course randomly when you come to a forked road can be interesting depending on the game design, and it looks like a human being is moving it.If you want to make the game harder, it would be easier to adjust the difficulty level by increasing the enemy's HP with RPG, or by increasing the number of enemies with Pac-Man, rather than creating strong AI.
If you can't implement game trees in the first place, you should learn how to implement game trees using simple rules.
Current State
var state={
map: [0,0,0,1,1], //1 has one item
playerPosition:2
};
as
var moves=[
{ move: ["L", "L", point:0}, // If you move to the left twice, the item is 0
{ move: ["L", "R", point:0}, // If you go to the left and then to the right, the item is 0
{ move: ["R", "L", point:1} , // Go right and move left to get 1 item
{ move: ["R", "R", point:2} // Move to the right twice to get 2 items
];
Explore all possibilities and calculate the score (this pseudocode is JavaScript). Once moves
is calculated, the largest point
is the last {move:["R", "R", point:2}
, so select the first step "R"
."
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.