Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I have taken an AI course, and the teacher asked us to implement a game that makes use of one of the AI algorithms. Here is where I need a bit of help:

  • I don't know what kind of games each algorithm is applied

  • if you could just give an example of a game or game type and the algorithm it uses, I would appreciate it

I don't need any coding help, I can manage that (my language of choice is Java). I only need a little help in selecting an algorithm.

1 Answer

0 votes
by (107k points)

Game AI/heuristic algorithms are used in a wide variety of quite disparate fields inside a game. The most obvious is in the control of any NPCs in the game, although "scripting" (decision tree) is currently the most common means of control.

Pathfinding, another common use for AI, is widely seen in real-time strategy games. Pathfinding is the method for determining how to get the NPC from one point on a map to another, taking into consideration the terrain, obstacles and possibly "fog of war".

You can implement an AI algorithm in a Tic-Tac-Toe game:

Rules of the Game

  • The game is to be played between two people (in this program between HUMAN and COMPUTER).

  • One of the players chooses ‘O’ and the other ‘X’ to mark their respective cells.

  • The game starts with one of the players and the game ends when one of the players has one whole row/ column/ diagonal filled with his/her respective character (‘O’ or ‘X’).

  • If no one wins, then the game is said to be a draw.

                            image

Implementation: In our program, the moves taken by the computer and the human are chosen randomly. We use rand() function for this.

What more can be done in the program?

The program is not played optimally by both sides because the moves are chosen randomly. The program can be easily modified so that both players play optimally (which will fall under the category of Artificial Intelligence). Also, the program can be modified such that the user himself gives the input (using scanf() or cin).

Winning Strategy – An Interesting Fact

If both players play optimally then it is destined that you will never lose (“although the match can still be drawn”). It doesn’t matter whether you play first or second. In another way – “ Two expert players will always draw ”.

For the code, you can refer the link: https://www.geeksforgeeks.org/implementation-of-tic-tac-toe-game/

Interested in learning Artificial Intelligence? Check out the Artificial Intelligence Online Course!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...