artificial-intelligence

Artificial Intelligence Python codes for solving puzzles and problems.

1. TIC-TAC-TOE (TWO USERS)

  • A basic two user playable Tic-Tac-Toe game that uses your numpad as the position markers.
  • Players take turn by turn to position their mark.
  • The game does not have a GUI as of now. It is a console version.

INTERFACE

Numpad Keys For Placing The Mark

image

Tic-Tac-Toe Board

image

Positioning Your Mark

image

image

Game Over

image


2. TIC-TAC-TOE (USER vs AI)

  • Instead of another user, the machine will play against you.
  • Developed using basic algorithm and some Tic-Tac-Toe tricks
  • I have played against it a thousand times and the highest I have gone is a DRAW.
  • GIVE IT A TRY. CAN YOU BEAT IT?

INTERFACE

Numpad Keys For Placing The Mark

image

You Will Go First

image

Immediately The AI Plays

image

Play Until One Wins...

image

... Or It's A Draw

image


3. 8 - PUZZLE PROBLEM

  • There are 9 cells arranged in a 3x3 grid. Eight of them are numbered from 1 - 8 and one is left blank (in my case, I have numbered it to 0).

  • The rule of this game is to swap the blank cell with its adjacent cell and arrange the cells in ascending order (with the blank space in the last cell).

    That is, convert this...

    image

    To this...

    image

KEYBOARD BINDINGS

A - LEFT

S - DOWN

D - RIGHT

W - UP

GOAL STATE

image

TRY SOLVING THE PUZZLE. IF STUCK, THEN LOOK MY NEXT TOPIC :)


4. 8 - PUZZLE PROBLEM SOLVER (AI)

  • Uses BEST FIRST SEARCH to find the optimum solution.
  • Heuristic function used is MANHATTAN DISTANCE
  • Feed the 8 - puzzle problem board values and it will spit out the steps.
  • Solves the problem blazing fast!

FEED THE BOARD VALUES

image

THE SOLUTION

image

This repository was created solely to discuss the various Artificial Intelligence codes in Python that can be used to solve puzzles and problems. If you have any idea or algorithm, please feel free to update this repository as it will help all of us to grow as a community.

GitHub

https://github.com/CYBERDEVILZ/artificial-intelligence