Ambedkar Institute of Advanced Communication Technologies & Research

 

AI-based Games

Implementation of AI-based Games is a complete implementation of A.I. based game programming in C++. As part of this implementation, we have programmed three games – CleanSweep, Glutton and Chess.

CleanSweep is a simple board game where two players compete for board supremacy and the person capturing the biggest space wins. The objective for the player is to play the pieces well by pushing the opponent towards the sideline and grabbing most of the opponents territory. In the end, the player with the highest occupancy wins.

When both players cannot play another piece or if every square on the board is filled, the game is over. The computer automatically counts up the number of black and green pieces. The winner is the one with the most pieces of a particular color.

In Glutton, the board is like a 2D maze, with dots lying all over the valid path. The Glutton tries to eat as many dots as it can on the screen.

The guardian demons live in a cell inside the game board and try to catch Glutton. If they happen to catch Glutton, it dies and as a result we lose a chance.

There are four big blinking dots on the screen, called power dots. By eating them, Glutton gets special powers for some time. During that period, the demons’ speed is reduced greatly as they try to run away since Glutton can kill them. Once the duration of power mode gets over, the game continues as before.

Once the Glutton eats all the dots present on the screen, the level gets over, and the next level begins. As the level rises, the duration of power of the Glutton after eating the power dot diminishes, thus making the game tougher as levels pass.

Chess is played on a square board with 64 squares and two forces with 16 warriors each. The warriors on each side constitute of eight Pawns, two Knights, two Bishops called ‘Minor Pieces’; two Rooks and a Queen known as ‘Major Pieces’ and the all-powerful King. The aim of the game is to threaten the enemy King in such a way that it cannot escape and neither of its army can save it. This situation is called ‘Checkmate’ and it marks the end of the game.

The various warriors have their particular style of movement. The Pawn moves straight and captures diagonally one square, and is allowed to move two squares forward from its starting position. The Pawn cannot move backwards and so the Pawns of different colors move in opposite directions only. If a Pawn reaches the last rank from its side, it gets converted to a Queen, Rook, Bishop or Knight of the same color, depending on the player’s choice. The Knight moves two squares straight in any of the four directions, and then a square in any of the two perpendicular directions to it. It has the unique power of crossing over the other warriors. So, it doesn’t matter what is in the path, but what’s on the square where it has to land is important. The Bishop can move diagonally on any square, as far as any other warrior does not block it.

The Rook can move in any of the four straight directions. It too cannot jump over any other warrior. The Queen possesses the powers of a Rook and a Bishop, and can move either diagonally or straight. The all-powerful King can move in a single square in any of the possible eight squares in its vicinity. Apart from them, there are some special moves like en-passant, castling etc. Also there are rules for valid moves.

The warriors can move only in the predefined and fixed fashion. Apart from a Knight, no other warrior can jump over any other warrior. Same color warriors cannot capture each other. Apart from valid movements, there is additional cover for check. No warrior is allowed to make a particular move, if making it causes its King to go under ‘Check’.

Three special moves are there apart from the general moves of chess. These are en-passant, castling and a pawn reaching the last rank.

In en-passant, if a Pawn is in 5th rank from its side and an opponent Pawn on any of the two adjacent tiles, moves two squares from its initial position, then that Pawn can capture it by simply crossing it diagonally. This move can be made only on the very next move of the opponent Pawn’s move, and is invalid later.

In Castling the King can move two squares to the right or to the left of its initial position, and the Rook on the corner takes the position on the square just opposite and adjacent to the King. For making this move possible, the path between the King and any of the two Rooks elected to castle should be free from any other warrior. Also, the King and the Rook shouldn’t have moved before and there shouldn’t be any threat by any of the opponent’s warrior in the King’s path. It is the only move in Chess, where two pieces can move.

When a Pawn reaches the last rank, it gets the power to be reincarnated as a stronger warrior, and it can be converted to any of the Knight, Bishop, Rook or Queen. The choice of the warrior to select will be of the player and it will arrive at the same square on the last rank where the Pawn reached.

The moves are made alternately with the white making the first move. A player cannot skip any move or make an illegal move. When both the white and black have played a warrior, one move is completed. The moves should be aimed to grab the enemy’s territory, capture their warriors, and most importantly to checkmate the enemy King, which ends the game.

 
You are here  :