GithubHelp home page GithubHelp logo

mukeshmk / connect-4 Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 7.0 41 MB

A multi-agent implementation of the game Connect-4 using MCTS, Minimax and Exptimax algorithms.

Python 100.00%
artificial-intelligence connect4 game minimax expectimax alpha-beta-pruning random bots monte-carlo-tree-search pygame

connect-4's Introduction

Hey, How You Doin

Welcome to my page!

I'm Mukesh, a Senior Machine Leaning Engineer working with the NMT Team at Oracle EMEA. I am also a Data Science Graduate from Trinity College Dublin.

About Me:

I am from Chennai, Inida, currently living and working in Dublin, Ireland! ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently trying to change the world with NMT!
  • ๐ŸŒฑ Trying to learn to everything ๐Ÿคฃ
  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate and work with others on intresting projects or ideas! :bowtie:
  • ๐Ÿฅ… 2021 Goals: Contribute more to Open Source projects and Learn new technologies.
  • โšก Fun fact: I love to read comics and manga, play basketball and code ๐Ÿคฃ

Connect with me:

mukeshmk.github.io mukeshmk95 | LinkedIn mukeshmk95 | Instagram amukesh.mk | Twitter


Languages:

Python3

Java

R

CPP

JavaScript

TypeScript


Tools and Frameworks:

Scikit-Learn

Tensorflow

Spring

Visual Studio Code

React

Node.js

SQL

MySQL

MongoDB

Git

GitHub

Terminal

etc...

GitHub Stats

GitHub Contributions


visitors

connect-4's People

Contributors

aishwarya2345 avatar jagadish-ramamurthy avatar manasimohan avatar mukeshmk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

connect-4's Issues

MCTS rethinking the game for each move

MCTS starts rethinking the states from the beginning for each move it makes.
https://github.com/mukeshmk/cs7is2-ai-group-proj/blob/f5eb241cffd51edd9c9b07363a14022cb2ba0086/bots/montecarlo.py#L15

whatever moves the bot made and thought off are lost and it has to rethink the game each time it has to make the move, the rootnode content is erased and reinitialised with the current state of the board. This reduces the performance and accuracy of the algorithm.

Bug Introduced as part of PR #7 added Monte Carlo Tree Search Bot.

biased MinimaxBot and OneStepLookAheadBot

https://github.com/mukeshmk/cs7is2-ai-group-proj/blob/981f45f693b699907380502f864bd75f1eada5c1/bots/minimax.py#L71

https://github.com/mukeshmk/cs7is2-ai-group-proj/blob/981f45f693b699907380502f864bd75f1eada5c1/bots/onesteplook.py#L20

MinimaxBot and OneStepLookAheadBot are written in such a way that a bot vs bot match will always result in a buggy outcome (one-sided) as both the bots try to play in such a way that the BOT_PLAYER always wins.

Change this to a dynamic piece argument where the bots can be either PLAYER1 or PLAYER2, and migrate the changes to other bots.

game never ends when the players reach a draw state

Introduce draw state to the game.

Currently, there is no draw state implemented in the game, like in the bellow scenario:

It would be necessary when two players play against each other and reach such a state. The game needs to end and display that the game ended in a draw.

In the case where two bots play against each other, there is a change that the game might break.

CLI args are being over ridden by UI selection menu

when you try starting the game with these parameters

python game.py --p1 minimax --p2 montecarlo --ui false

The expected behaviour is for the two bots to play each other without the UI (in the cmd).

But the main menu screen appears and prompts the user to select the type of game he wants to play:

  • If bot vs bot is chosen the UI becomes unresponsive and the game begins without the UI in the command line (as UI is set to false when starting the game)
  • If 'player vs botorplayer vs player` is chosen the game just ends (because a human cannot play without UI).

Bug Introduced as part of PR #10 game menu selection via pygame

add ability to choose bots via terminal

The current version of the code implements various bots (algorithms) to play against but does not provide any way to choose a bot.

Use argparse package (not necessarily this) to implement this functionality to choose bots.

refer to this code segment to see how it's implemented using argparse package.

game breaks when it is MCTS Bot's turns to play the first move

if Monte Carlo Tree Search Bot has to make the first move the game breaks
https://github.com/mukeshmk/cs7is2-ai-group-proj/blob/8895798bb999556de8646c94d62af7184dc63be5/connect4.py#L15
(there is a 50% chance that this bug will occur when playing the game)
with the following error:

Traceback (most recent call last):
  File "game.py", line 75, in <module>
    main()
  File "game.py", line 72, in main
    connect4(p1, p2)
  File "D:\code\sem2\ai\cs7is2-ai-group-proj\connect4.py", line 58, in connect4
    col = p2.get_move(board)
  File "D:\code\sem2\ai\cs7is2-ai-group-proj\bots\montecarlo.py", line 72, in get_move
    self.currentNode, col = self.montecarlo_tree_search(board, 10000, self.currentNode, 3)
  File "D:\code\sem2\ai\cs7is2-ai-group-proj\bots\montecarlo.py", line 31, in 
montecarlo_tree_search
    state.drop_piece(col, state.CURR_PLAYER)
  File "D:\code\sem2\ai\cs7is2-ai-group-proj\board\board.py", line 40, in drop_piece
    self.board[row][col] = piece
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Bug Introduced as part of PR #7 added Monte Carlo Tree Search Bot.

add ability to choose bots via pygame

The current version of the code implements various bots (algorithms) to play against but does not provide any way to choose a bot.

Use pygame package to implement this functionality to choose bots.

Can do something like a separate page where we click and choose what bot to plag against, after choosing the game loads to its current state.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.