Solved

AI for a 2D character

Posted on 2011-03-18
13
867 Views
Last Modified: 2013-12-26
I am new to game programming and would like to implement a 2d java applet game in which a person will compete with an hero  (with AI)  to collect all the golds in a platform without being detected to creatures.  The basic game scenario  is shown in the image (without the human character included). In the game:

-There are creatures moving on their path (red line) with different speeds and moving to opposite directions
- Both the creatures and the hero (AI) will have line of sight but hero's line of sight is larger than the creatures'.
-If any of the character (human or hero(ai) ) gets into creatures' line of sight it loses.

My question is  how can I make the hero collect all the golds in the map by reacting to creatures (hiding,direction changing etc.) without being detected by creatures.is it hard to implement this kind of ai? Do I also need to implement a path finding algorithm, can't I give the route to him, if so how?Can you recommend me algorithms, examples etc.?

Thank you my plan, hero, creatures
0
Comment
Question by:BitHunt
  • 3
  • 3
  • 2
13 Comments
 
LVL 12

Expert Comment

by:satsumo
Comment Utility
Are all of the levels going to be circular?
0
 
LVL 12

Expert Comment

by:satsumo
Comment Utility
Does the hero AI know when they player takes some gold, so that it ignores the areas where could has been taken by the player.

Do the creatures move consistently?  I understand they aren't the same speed, but do they stop, or change directions?

From the diagram it looks as though the hero should follow the same path as the creatures.  The main path would have connected paths that lead to the gold.  The AI moves along the main path until it reached one of the connected paths.  It's decision about what to do is based on the positions of the creature on the path and the distance/time to the available gold.
0
 

Author Comment

by:BitHunt
Comment Utility
-An answer for rectangular structured  levels is perfectly fine. I think i should start with that since it seems easier.

-Hero AI and the player will have their own golds with different colors. They can't take each others golds.

-Creatures move consistently, they can randomly stop, wait for a couple of seconds and continue in the same direction  (it doesn't change its direction)

Thank you
0
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 500 total points
Comment Utility
Any kind of AI is usually difficult. Since you are new to it, I would recommend starting with something easy and making it more complicated as you go. You could take each approach and work it into a difficulty level. (So the first, simple approach is "Easy" and when you add some more intelligence, make it "Hard").
The first thing I would do is just use structured levels and draw a fixed path for the hero. Then he just looks and waits until the coast is clear (can't see an enemy) before moving. That could be the entire first AI step.
The next step would be to have the hero go different directions based on where the enemy is.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Assisted Solution

by:BitHunt
BitHunt earned 0 total points
Comment Utility
I think I'll be implementing A* algorithm and keeping the goal points (gold places) in a list and also visit them sequentially. To implement an ai that you recommend, after getting a gold I think I should stop in the entrance of the room  (it can be another goal point for A* I guess) and   check if the guards are there or not. If not I'll continue to next gold place. After deciding to  move to next gold place ( on my way to next gold place) if I detect a guard  I should go and hide to last visited goal point (entrance) and continue like that. Is it an ok solution?
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 500 total points
Comment Utility
That would certainly work. To make the AI better, you could have the hero have a variable speed and let him follow the enemy out of the enemy's sight range, but that would be for a more complicated solution.
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
Sorry, DHaest, I missed your first comment when you made it. http:#a35181690 gives a good solution to the original problem and http:#a35201018 answers the askers most recent question quite fully.
0
 
LVL 12

Expert Comment

by:satsumo
Comment Utility
I wish to support TommySzalapski's solution.  If I had more time I would posted a more complete description of a very similar idea.  BitHunt's answer (using A*) will work, but it's neither necessary or especially effective in this case.  A case of sledgehammer to crack a nut, final result is a smashed nut.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresIncreasing challenge 10 57
wordsWithoutList  challenge 24 72
powerN  challenge 3 46
delphi parse string to params 3 80
Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now