A program that allows a user to play against my Teeko AI player.

Overview

Teeko-AI-Player

Description

A program that allows a user to play against my Teeko AI player.

What is Teeko?

Teeko is a game played between two players, each of which with 4 red or black pieces, on a 5x5 board. At the start of the game, the player with black pieces always starts, and then each player takes turns placing their pieces until all pieces have been placed on the board - I will refer to this initial sequence of dropping pieces as the drop phase. The goal of the game is for one player to get four pieces in a row either horizontally, vertically, diagonally, or in a 2x2 box (in the example below, black wins).

Sublime's custom image

If after the drop phase neither player has won, each player continues taking turns by moving one piece to an adjacent space at a time. To be clear, by adjacent I mean that a player can move their piece either one space up, down, left, right, or to any diagonal such that the space they are moving to is not yet occupied. It should be mentioned that my program does not support the ability to wrap around the board, meaning if your piece was on the bottom right corner of the board and you tried to move the piece to the right, it would be marked as an invalid move instead of moving all the way to the bottom left corner.

Functions

There are several functions defined in this program that ensure that the Teeko game remains valid (i.e. all rules are followed). I have ommited these functions from this write-up, and have instead opted to just describe the functions that allow my AI player to make decisions about where to move their pieces.

My make_move(self, state) contains all the logic that allows my AI player to choose their move. This function can be broken down into the following components:

  1. Generates a subtree of depth d under the current state.
  2. Uses a heuristic scoring function to evaluate the "leaves" at depth d, and propagates these scores back up to the current state.
  3. Selects and returns the best possible next move using the minimax algorithm.

Helper Functions

The following helper functions are implemented to help with make_move(self, state)'s functionality:

  • succ(self, state): A function to determine a list of legal successor states from the current state.
    Inputs: A board state.
    Returns: A list of legal successor states.
  • game_value(self, state): A function to check the current board status for a win condition.
    Inputs: A board state.
    Returns: 1 if this TeekoPlayer wins, -1 if the opponent wins, 0 if no winner.
  • heuristic_game_value(self, state): A function to evaluate all non-terminal states (Details Below).
    Inputs: A board state.
    Returns: A floating-point value between 1 and -1.
  • minimax(self, state, depth): A function to return the best move for the current player.
    Inputs: A board state, and the maximum search tree depth.
    Returns: The best move for the current player.

Running Teeko-AI-Player Locally

To run this program locally simply clone this repository,

git clone https://github.com/peter-w-bryant/Teeko-AI-Player.git

and run the ai.py python3 script,

python3 ai.py

Sample Game

Screenshot Demo: Losing in the Drop Phase

For demonstration purposes, I will play against the AI player such that I lose in the drop-phase.

After executing the script, either the user or the AI player will be randomly selected to start. In this case, the AI player was selected as black, and made their move first.

Sublime's custom image

Now it is the user's turn to select. I will chose to move my piece to 'A0', or the top left position in the grid. The AI player will quickly respond.

Sublime's custom image

I subsequently respond by playing 'A1', the AI player responds by placing a piece at 'B2'. It is clear to me that the AI player will play 'A2' next turn if playing optimally, which will allow them to win the game - so I decide to place my third piece at 'A2'.

Sublime's custom image

But of course the AI player also had 'E2' available and places its final piece in that spot. They now have 4 pieces in a horizontal line, and they have won! ):

Video Demo: Losing After the Drop Phase

In this instance I will play the AI player until after the drop phase, where I will lose after just a few moves. Additionally, I will try to make atleast one error or one invalid move to demonstrate how the error is handled.

demo.mp4
You might also like...

A simple python program that can be used to implement user authentication tokens into your program...

token-generator A simple python module that can be used by developers to implement user authentication tokens into your program... code examples creat

Apr 18, 2022

A rock, paper, scissors "AI" which predicts the user's next move from a binomial distribution of the frequency of previous moves; with a CSV player database

Rock Paper Scissors "AI" Revision for 0.0.1 List of contents: Brief Introduction Instructions Console Example Legal (MIT license) Brief Introduction A

Apr 24, 2022

Telegram Music Bot, bot allows you to play music on telegram groups voice chat.

Telegram Music Bot, bot allows you to play music on telegram groups voice chat.

Codexun Music Bot Telegram music bot which can helps to play music on groups voice chat. Kangers Welcome You! Requirements FFmpeg Python 3.10.0 NodeJS

Sep 16, 2022

🚀This is a repository that was created to play and enjoy testing different things with localstack, which is a local AWS deployment that allows to interact with multiples AWS services locally. ☁☁

🚀This is a repository that was created to play and enjoy testing different things with localstack, which is a local AWS deployment that allows to interact with multiples AWS services locally. ☁☁

CLOUD STACK DEPLOY This repository has some projects using AWS services like Glue, Lambda and many others. This repository uses a simple localstack in

Aug 10, 2022

Noinoi music allows to play music on voice chat also heroku supported.

Noinoi music allows to play music on voice chat also heroku supported.

Noinoi Music bot Telegram music bot which can helps to play music on groups voice chat part of @Phoenix_Empire . Requirements FFmpeg Python 3.10.0 Nod

Aug 25, 2022

Python web scraper script that scrapes ordnet.dk. This allows the user to search words from the terminal.

Python web scraper script that scrapes ordnet.dk. This allows the user to search words from the terminal.

Ordnet.dk dictionary web scraper A simple web scraper that scrapes ordnet.dk (Danish web dictionary) for information, regarding the searched term. Whe

Apr 20, 2022

A IoT based system that allows the user to keep an eye on their dog or pet and observe if they are accessing an area unaccompanied and interacting with the owner's belongings.

A IoT based system that allows the user to keep an eye on their dog or pet and observe if they are accessing an area unaccompanied and interacting with the owner's belongings.

A IoT based system that allows the user to keep an eye on their dog or pet and observe if they are accessing an area unaccompanied and interacting with the owner's belongings.

Jun 5, 2022

DSM-tui (Decks Server Manager TUI) is a tool that allows server management by viewing active services and server status. It is developed in python with TUI (Terminal User Inteface) interface

DSM-tui (Decks Server Manager TUI) is a tool that allows server management by viewing active services and server status. It is developed in python with TUI (Terminal User Inteface) interface

DSM-TUI Documentation Description DSM-TUI (Decks Server Manager TUI) is a tool that allows server management by viewing active services and server sta

Aug 10, 2022

Application that allows a user to post a project he/she has created and get it reviewed by his/her peers.

Awwards Clone A project that allows users to create accounts and add projects as well as vote for other users projects based on design, usability and

Jun 12, 2022
Owner
Peter Bryant
Peter Bryant
The game SNAKE aims to be played normally by any player: against the PC or a friend.

The game SNAKE aims to be played normally by any player: against the PC or a friend. Also to be played by an AI that uses the A* algorithm to avoid touching obstacles and get to the fruit without the help of a person. The game becomes autonomous in this case.

Ismail Jabri 1 Aug 10, 2022
A Player for Kanye West's Stem Player. Sort of an emulator.

Stem Player Player Stem Player Player Usage Download the latest release here Optional: install ffmpeg, instructions here NOTE: DOES NOT ENABLE DOWNLOA

null 118 Sep 20, 2022
Python implementation of player-Vs-player chess game

This project is a python implementation of player-Vs-player chess game. The game’s chess board and pieces was built using class based structures. The implementation was created by Kamil Zych.

Kamil Zych 1 Aug 16, 2022
Tools for visualising contributions to 2UP Accounts with UP Bank from Player 1 and Player 2.

2UP Visualiser Tools for visualising contributions to 2UP Accounts with UP Bank from Player 1 and Player 2. 2UP Visualiser Python Script Future Plans

Aditha Doratiyawa 3 Sep 18, 2022
Play rock paper scissors against a discord python bot.

Rock Paper Scissors First functionality/game I've added as a process of setting up a multi-functional discord bot. Usage $rps Times out after 60 secon

clxrity 1 Apr 24, 2022
Play a game of nim against an AI trained with Q-learning.

Nim-AI Play a game of nim against an AI trained with Q-learning. Nim is a game wherein two players take turns picking objects from piles with the goal

Conner Rose 1 Sep 12, 2022
Telegram Lag Free radio player which can play live radio stream or yt stream in voice chat with minimum lag ❤️🚶

SilentRadioPlayer Telegram Lag Free radio player which can play live radio stream or yt stream in voice chat with minimum lag ❤️ ?? . Installation

Official Team-Silent 4 May 12, 2022
Simple auto sorting program which allows the user to specify a directory to be sorted

Simple auto sorting program which allows the user to specify a directory to be sorted. Change top lines to set your destination folders as well as which extension goes where. Uses watchdog to monitor folder and os to move files, tkinter is used for the GUI

Tigh Gallagher 1 Jul 24, 2022
Small program that allows the user to create a tree as an array, then traverse and perform actions on it, such as flipping it.

TreeFunctions Small program that allows the user to create a tree as an array, then traverse and perform actions on it, such as inverting it. The user

Olivia Gray 1 Sep 20, 2022
😂 'KillWell' exploit developed for CS:GO (Counter-Strike: Global Offensive) that allows the exploiter to force bots to target a specific player and turn on literal AI aimbot

CS:GO KillWell ?? 'KillWell' exploit developed for CS:GO (Counter-Strike: Global Offensive) that allows the exploiter to force bots to target a specif

0x44F 9 Sep 24, 2022