Giter Site home page Giter Site logo

fbunaren / tic-tac-toe-ai Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 7 KB

A Tic-Tac-Toe AI written in Python 3

License: MIT License

Python 100.00%
adversarial-search artificial-intelligence game minimax-algorithm noughts-and-crosses python3 tic-tac-toe

tic-tac-toe-ai's Introduction

Hi ๐Ÿ‘‹ I'm Fransiscus Emmanuel Bunaren

About Me

Currently, I am a third-year double degree student at the University of Queensland and University of Indonesia. I am interested to learn more about Software Engineering, Data Science, and Cyber Security.

My Personal Website: https://bunaren.com

๐ŸŽ“ Education

  • Information Technology, University of Queensland (2021-2021)
  • Computer Science, University of Indonesia (2018-2022)

๐Ÿ’ป Work Experience

  • Teaching Assistant of Data Structures and Algorithms (August 2020 โ€“ January 2021)
  • Teaching Assistant (TA Coordinator for International Class) of Programming Foundations 2 (Java) (January 2020 - June 2020)
  • Teaching Assistant (TA Coordinator for International Class) of Programming Foundations 2 (Python) (August 2019 - January 2020)

๐Ÿš€ Recent Projects

fbunaren

Free Domain devs.id

fbunaren's GitHub stats Top Langs

tic-tac-toe-ai's People

Contributors

fbunaren avatar

Watchers

 avatar

tic-tac-toe-ai's Issues

some lines need to be improved to make the codes cleaner in play.py

Here are my reports

************* Module play
play.py:16:10: C0326: Exactly one space required before assignment
    symbol= input("Choose your symbol (X/O) : ").upper()
          ^ (bad-whitespace)
play.py:27:26: C0326: Exactly one space required after comma
        pos = list(map(int,input("Draw " + symbol + " at [row column] : ").split()))
                          ^ (bad-whitespace)
play.py:32:30: C0326: Exactly one space required after comma
            pos = list(map(int,input("Draw " + symbol + " at [row column] : ").split()))
                              ^ (bad-whitespace)
play.py:64:0: C0304: Final newline missing (missing-final-newline)
play.py:1:0: C0111: Missing module docstring (missing-docstring)
play.py:11:0: C0111: Missing function docstring (missing-docstring)
play.py:9:0: C0411: standard import "import os" should be placed before "from engine import Engine" (wrong-import-order)

-----------------------------------
Your code has been rated at 8.37/10

Bad code quality in engine.py

I was using pylint to check your codes quality and here are the results.

************* Module engine
engine.py:4:26: C0326: Exactly one space required after comma
from random import uniform,choice
                          ^ (bad-whitespace)
engine.py:11:37: C0326: No space allowed before :
        self.symbol2value = lambda x : 1 if x == "X" else (-1 if x == "O" else 0)
                                     ^ (bad-whitespace)
engine.py:13:22: C0326: Exactly one space required after comma
    def setSymbol(self,symbol="X"):
                      ^ (bad-whitespace)
engine.py:17:25: C0326: Exactly one space required after comma
    def invertSymbol(self,symbol):
                         ^ (bad-whitespace)
engine.py:20:21: C0326: Exactly one space required after comma
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                     ^ (bad-whitespace)
engine.py:20:28: C0326: Exactly one space required after comma
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                            ^ (bad-whitespace)
engine.py:20:41: C0326: Exactly one space required after comma
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                                         ^ (bad-whitespace)
engine.py:20:49: C0326: Exactly one space required after comma
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                                                 ^ (bad-whitespace)
engine.py:20:56: C0326: No space allowed around keyword argument assignment
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                                                        ^ (bad-whitespace)
engine.py:20:71: C0326: Exactly one space required after comma
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                                                                       ^ (bad-whitespace)
engine.py:20:77: C0326: No space allowed around keyword argument assignment
    def bestMove(self,inputs,ai_turn=True,depth=0,alpha = -float("inf"),beta = float("inf")):
                                                                             ^ (bad-whitespace)
engine.py:24:34: C0326: Exactly one space required after comma
        best_value = [float("inf"),0]
                                  ^ (bad-whitespace)
engine.py:38:53: C0326: Exactly one space required after comma
                state_value = self.bestMove(tmp_board,not ai_turn,depth + 1,alpha,beta)
                                                     ^ (bad-whitespace)
engine.py:38:65: C0326: Exactly one space required after comma
                state_value = self.bestMove(tmp_board,not ai_turn,depth + 1,alpha,beta)
                                                                 ^ (bad-whitespace)
engine.py:38:75: C0326: Exactly one space required after comma
                state_value = self.bestMove(tmp_board,not ai_turn,depth + 1,alpha,beta)
                                                                           ^ (bad-whitespace)
engine.py:38:81: C0326: Exactly one space required after comma
                state_value = self.bestMove(tmp_board,not ai_turn,depth + 1,alpha,beta)
                                                                                 ^ (bad-whitespace)
engine.py:41:49: C0326: Exactly one space required after comma
                        best_value = [state_value,i]
                                                 ^ (bad-whitespace)
engine.py:42:41: C0326: Exactly one space required after comma
                        alpha = max(alpha,best_value[0])
                                         ^ (bad-whitespace)
engine.py:45:49: C0326: Exactly one space required after comma
                        best_value = [state_value,i]
                                                 ^ (bad-whitespace)
engine.py:46:39: C0326: Exactly one space required after comma
                        beta = min(beta,best_value[0])
                                       ^ (bad-whitespace)
engine.py:55:0: C0304: Final newline missing (missing-final-newline)
engine.py:1:0: C0111: Missing module docstring (missing-docstring)
engine.py:9:0: C0111: Missing class docstring (missing-docstring)
engine.py:13:4: C0103: Method name "setSymbol" doesn't conform to snake_case naming style (invalid-name)
engine.py:13:4: C0111: Missing method docstring (missing-docstring)
engine.py:17:4: C0103: Method name "invertSymbol" doesn't conform to snake_case naming style (invalid-name)
engine.py:17:4: C0111: Missing method docstring (missing-docstring)
engine.py:17:4: R0201: Method could be a function (no-self-use)
engine.py:20:4: C0103: Method name "bestMove" doesn't conform to snake_case naming style (invalid-name)
engine.py:20:4: C0111: Missing method docstring (missing-docstring)
engine.py:20:4: R0913: Too many arguments (6/5) (too-many-arguments)
engine.py:28:12: R1705: Unnecessary "elif" after "return" (no-else-return)
engine.py:14:8: W0201: Attribute 'symbol' defined outside __init__ (attribute-defined-outside-init)
engine.py:53:4: C0103: Constant name "engine" doesn't conform to UPPER_CASE naming style (invalid-name)
engine.py:4:0: W0611: Unused uniform imported from random (unused-import)
engine.py:4:0: W0611: Unused choice imported from random (unused-import)
engine.py:5:0: W0611: Unused import pprint (unused-import)
engine.py:6:0: W0611: Unused import json (unused-import)

-----------------------------------
Your code has been rated at 0.95/10

Bad code quality in board.py

I was using pylint to check your codes quality and here are the results.

************* Module board
board.py:7:37: C0326: No space allowed before :
        self.symbol2value = lambda x : 1 if x == "X" else (-1 if x == "O" else 0)
                                     ^ (bad-whitespace)
board.py:11:21: C0326: Exactly one space required after comma
    def setBoard(self,inputs):
                     ^ (bad-whitespace)
board.py:18:18: C0326: Exactly one space required after comma
    def print(self,show_turn=False):
                  ^ (bad-whitespace)
board.py:19:0: C0301: Line too long (107/100) (line-too-long)
board.py:19:29: C0326: Exactly one space required after comma
        print("  " + str(['1','2','3']).replace("["," ").replace("]"," ").replace("'","").replace(","," "))
                             ^ (bad-whitespace)
board.py:19:33: C0326: Exactly one space required after comma
        print("  " + str(['1','2','3']).replace("["," ").replace("]"," ").replace("'","").replace(","," "))
                                 ^ (bad-whitespace)
board.py:19:51: C0326: Exactly one space required after comma
        print("  " + str(['1','2','3']).replace("["," ").replace("]"," ").replace("'","").replace(","," "))
                                                   ^ (bad-whitespace)
board.py:19:68: C0326: Exactly one space required after comma
        print("  " + str(['1','2','3']).replace("["," ").replace("]"," ").replace("'","").replace(","," "))
                                                                    ^ (bad-whitespace)
board.py:19:85: C0326: Exactly one space required after comma
        print("  " + str(['1','2','3']).replace("["," ").replace("]"," ").replace("'","").replace(","," "))
                                                                                     ^ (bad-whitespace)
board.py:19:101: C0326: Exactly one space required after comma
        print("  " + str(['1','2','3']).replace("["," ").replace("]"," ").replace("'","").replace(","," "))
                                                                                                     ^ (bad-whitespace)
board.py:20:15: C0326: Exactly one space required after comma
        print(1,str([self.board[0],self.board[1],self.board[2]]).replace("'","").replace(",","|"))
               ^ (bad-whitespace)
board.py:20:34: C0326: Exactly one space required after comma
        print(1,str([self.board[0],self.board[1],self.board[2]]).replace("'","").replace(",","|"))
                                  ^ (bad-whitespace)
board.py:20:48: C0326: Exactly one space required after comma
        print(1,str([self.board[0],self.board[1],self.board[2]]).replace("'","").replace(",","|"))
                                                ^ (bad-whitespace)
board.py:20:76: C0326: Exactly one space required after comma
        print(1,str([self.board[0],self.board[1],self.board[2]]).replace("'","").replace(",","|"))
                                                                            ^ (bad-whitespace)
board.py:20:92: C0326: Exactly one space required after comma
        print(1,str([self.board[0],self.board[1],self.board[2]]).replace("'","").replace(",","|"))
                                                                                            ^ (bad-whitespace)
board.py:21:15: C0326: Exactly one space required after comma
        print(2,str([self.board[3],self.board[4],self.board[5]]).replace("'","").replace(",","|"))
               ^ (bad-whitespace)
board.py:21:34: C0326: Exactly one space required after comma
        print(2,str([self.board[3],self.board[4],self.board[5]]).replace("'","").replace(",","|"))
                                  ^ (bad-whitespace)
board.py:21:48: C0326: Exactly one space required after comma
        print(2,str([self.board[3],self.board[4],self.board[5]]).replace("'","").replace(",","|"))
                                                ^ (bad-whitespace)
board.py:21:76: C0326: Exactly one space required after comma
        print(2,str([self.board[3],self.board[4],self.board[5]]).replace("'","").replace(",","|"))
                                                                            ^ (bad-whitespace)
board.py:21:92: C0326: Exactly one space required after comma
        print(2,str([self.board[3],self.board[4],self.board[5]]).replace("'","").replace(",","|"))
                                                                                            ^ (bad-whitespace)
board.py:22:15: C0326: Exactly one space required after comma
        print(3,str([self.board[6],self.board[7],self.board[8]]).replace("'","").replace(",","|"))
               ^ (bad-whitespace)
board.py:22:34: C0326: Exactly one space required after comma
        print(3,str([self.board[6],self.board[7],self.board[8]]).replace("'","").replace(",","|"))
                                  ^ (bad-whitespace)
board.py:22:48: C0326: Exactly one space required after comma
        print(3,str([self.board[6],self.board[7],self.board[8]]).replace("'","").replace(",","|"))
                                                ^ (bad-whitespace)
board.py:22:76: C0326: Exactly one space required after comma
        print(3,str([self.board[6],self.board[7],self.board[8]]).replace("'","").replace(",","|"))
                                                                            ^ (bad-whitespace)
board.py:22:92: C0326: Exactly one space required after comma
        print(3,str([self.board[6],self.board[7],self.board[8]]).replace("'","").replace(",","|"))
                                                                                            ^ (bad-whitespace)
board.py:24:35: C0326: No space allowed before comma
            print("\n" + self.turn , "turns")
                                   ^ (bad-whitespace)
board.py:37:20: C0326: Exactly one space required after comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                    ^ (bad-whitespace)
board.py:37:22: C0326: Exactly one space required after comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                      ^ (bad-whitespace)
board.py:37:26: C0326: No space allowed before comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                          ^ (bad-whitespace)
board.py:37:30: C0326: Exactly one space required after comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                              ^ (bad-whitespace)
board.py:37:32: C0326: Exactly one space required after comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                                ^ (bad-whitespace)
board.py:37:36: C0326: No space allowed before comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                                    ^ (bad-whitespace)
board.py:37:40: C0326: Exactly one space required after comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                                        ^ (bad-whitespace)
board.py:37:42: C0326: Exactly one space required after comma
        for i in [[0,1,2] , [3,4,5] , [6,7,8]]:
                                          ^ (bad-whitespace)
board.py:42:16: C0326: Exactly one space required after comma
        tmp = [0,3,6]
                ^ (bad-whitespace)
board.py:42:18: C0326: Exactly one space required after comma
        tmp = [0,3,6]
                  ^ (bad-whitespace)
board.py:44:0: W0311: Bad indentation. Found 11 spaces, expected 12 (bad-indentation)
board.py:45:0: W0311: Bad indentation. Found 11 spaces, expected 12 (bad-indentation)
board.py:48:0: C0301: Line too long (128/100) (line-too-long)
board.py:48:59: C0326: Exactly one space required after comma
        is_over = abs(sum([self.symbol2value(self.board[0]),self.symbol2value(self.board[4]),self.symbol2value(self.board[8])]))
                                                           ^ (bad-whitespace)
board.py:48:92: C0326: Exactly one space required after comma
        is_over = abs(sum([self.symbol2value(self.board[0]),self.symbol2value(self.board[4]),self.symbol2value(self.board[8])]))
                                                                                            ^ (bad-whitespace)
board.py:51:0: C0301: Line too long (128/100) (line-too-long)
board.py:51:59: C0326: Exactly one space required after comma
        is_over = abs(sum([self.symbol2value(self.board[2]),self.symbol2value(self.board[4]),self.symbol2value(self.board[6])]))
                                                           ^ (bad-whitespace)
board.py:51:92: C0326: Exactly one space required after comma
        is_over = abs(sum([self.symbol2value(self.board[2]),self.symbol2value(self.board[4]),self.symbol2value(self.board[6])]))
                                                                                            ^ (bad-whitespace)
board.py:54:0: C0303: Trailing whitespace (trailing-whitespace)
board.py:62:20: C0326: Exactly one space required after comma
    def isValid(self,pos):
                    ^ (bad-whitespace)
board.py:68:17: C0326: Exactly one space required after comma
    def move(self,pos):
                 ^ (bad-whitespace)
board.py:1:0: C0111: Missing module docstring (missing-docstring)
board.py:5:0: C0111: Missing class docstring (missing-docstring)
board.py:11:4: C0103: Method name "setBoard" doesn't conform to snake_case naming style (invalid-name)
board.py:11:4: C0111: Missing method docstring (missing-docstring)
board.py:12:11: C0123: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)
board.py:18:4: C0111: Missing method docstring (missing-docstring)
board.py:26:4: C0103: Method name "getTurn" doesn't conform to snake_case naming style (invalid-name)
board.py:26:4: C0111: Missing method docstring (missing-docstring)
board.py:29:4: C0103: Method name "changeTurn" doesn't conform to snake_case naming style (invalid-name)
board.py:29:4: C0111: Missing method docstring (missing-docstring)
board.py:35:4: C0103: Method name "isOver" doesn't conform to snake_case naming style (invalid-name)
board.py:35:4: C0111: Missing method docstring (missing-docstring)
board.py:56:8: R1705: Unnecessary "else" after "return" (no-else-return)
board.py:62:4: C0103: Method name "isValid" doesn't conform to snake_case naming style (invalid-name)
board.py:62:4: C0111: Missing method docstring (missing-docstring)
board.py:63:8: R1703: The if statement can be replaced with 'return bool(test)' (simplifiable-if-statement)
board.py:63:8: R1705: Unnecessary "else" after "return" (no-else-return)
board.py:63:11: R1716: Simplify chained comparison between the operands (chained-comparison)
board.py:68:4: C0111: Missing method docstring (missing-docstring)
board.py:69:8: R1705: Unnecessary "else" after "return" (no-else-return)

------------------------------------
Your code has been rated at -2.88/10

I hope you can use these reports to make your codes cleaner.

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.