Skip to content

4 artificial inteligence projects: genethic algorith (tournament, roulette), CSP (forward checking, backtracking), checkers engine (min-max, alpha-beta), machine learing (supervised).

Notifications You must be signed in to change notification settings

ksproska/artificialInteligence_java_python

Repository files navigation

This repository contains 4 different project implementing different topics regarding Artificial Inteligence.

Algorithm was created for problem of Facility Layout Optimization (examlpe below).

image

Grid 3x4, 9 machines need to be set up, each pair has a cost depending on destination between machines on grid + extra parameters. Sample data is stored in .json files in folder, README for .json.

Implemented genethic algorithm elements

Sample genetic algorithm implementation.

CSP implemented for solving two problems:

Binary problem (and example solution)

  • 0 or 1 for each cell
  • max sequence of same numbers of length less than 3
  • each row and column is unique
  • each row and column has same number of 0 and 1

image image

Futoshiki problem (and example solution)

Rules for solving futoshiki problem can be found here.

image image

Implementation

image

Overview of interfaces and their implementations.

Additionaly for each problem are avaliable different heuristics for ordering cells to fill and ordering their domains.

Both problems:

  • in order (left to right, up to down) (+ domain order swapped)
  • smallest domain first (+ domain order swapped)

Binary:

  • most in rows first (+ domain order swapped)

Futoshiki:

  • most constraints first (+ domain order swapped)
  • most constraints first unless domain size of any equals 1 (+ domain order swapped)

Implementation of checkers engine for human player and bots. Avaliable bots:

image

For accessment of grid avaliable are two approaches:

  • simple - counting figures (with weights normal=1, crowned=5)
  • complex - counting figures + the closer to the border the better

image

Game is avaliable in version:

image image

  • clicable gui + console for displaying wrong inputs and past moves: implementation

image

Creating models for recognizing book genre from it's description.

Preprocessing

For books avaliable in booksummaries.txt, in format:

620	/m/0hhy	Animal Farm	George Orwell	1945-08-17	{"/m/016lj8": "Roman \u00e0 clef", "/m/06nbt": "Satire", "/m/0dwly": "Children's literature", "/m/014dfn": "Speculative fiction", "/m/02xlf": "Fiction"}	 Old Major, … malleable propaganda.
843	/m/0k36	A Clockwork Orange	Anthony Burgess	1962	{"/m/06n90": "Science Fiction", "/m/0l67h": "Novella", "/m/014dfn": "Speculative fiction", "/m/0c082": "Utopian and dystopian fiction", "/m/06nbt": "Satire", "/m/02xlf": "Fiction"}	 Alex, a teenager living … fatalistically.
...

We process data choosing 4 most popular genres (book count, books with multiple genres from the list were excluded):

Science Fiction                           2395
Fantasy                                   1641
Children's literature                     1287
Crime Fiction                             970

Books were saved in file normalised_genres.csv, in format:

id	title	Children's literature	Science Fiction	Fantasy	Crime Fiction	description
/m/0hhy	Animal Farm	1	0	0	0	 Old Major, … malleable propaganda.
/m/0k36	A Clockwork Orange	0	1	0	0	 Alex, a teenager living … fatalistically.
...

Text lametization

For text lametization WordNetLemmatizer from library nltk with stopwords was used, implementation.

Before:

Old Major, the old boar on the Manor Farm, calls the animals on the farm for a meeting, where he compares the humans to parasites and teaches the animals a revolutionary song, 'Beasts of England'. …

After:

old major old boar manor farm call animal farm meeting compare human parasite teach animal revolutionary song england …

Creating models

Method taking model type and number of best feacutes is implemented here.

For purposes of comparing different models as well as testing texts from outside the avaliable ones (using trained models) see here.

About

4 artificial inteligence projects: genethic algorith (tournament, roulette), CSP (forward checking, backtracking), checkers engine (min-max, alpha-beta), machine learing (supervised).

Resources

Stars

Watchers

Forks