Skip to content

Rock Paper Scissor AI written in python and tkinter

Notifications You must be signed in to change notification settings

eroc123/RPS-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 

Repository files navigation

RPS-Bot

Rock Paper Scissor AI written in python and PyQt5

This is a true AI in the sense that it does not read your input and use that against you, but it will use your past inputs to learn how to beat you :)

Requriements

  • PyQt5
  • Python (3.x)

How to use

Download the files git clone https://github.com/Eroc123/RPS-Bot.git

Put them in the same folder

Run python3 main.py in terminal (linux)

Else run py main.py in the terimal (windows)

You need to install PyQt5 is not already installed

You can import cogs.py into your own code

Some important functions

  • predict() get the AI choice

  • log(the ai choice, the player choice, the result)

    make sure to use from cog import Ai

    0 : 'rock'
    1 : 'paper'
    -1 : 'scissor'
    for example

      from cogs import Ai
      #the cogs.py does not provide functions to find if its a win or a loss
      win = [[1,0],[0,-1],[-1,1]]
      lose = [[0,1],[-1,0],[1,-1]]
      tie = [[1,1],[-1,-1],[0,0]]
      
      score = 0
      
      def check(rt):
        if rt in win:
            return 1
        elif rt in lose:
            return -1
        elif rt in tie:
            return 0
      
      c = Ai()
      userchoice = input() #here the user input 1, 0, -1
      AIchoice = c.predict()
      score += check([userchoice, AIchoice]) #remember its user choice first, then ai choice
      print(score)
    

About

Rock Paper Scissor AI written in python and tkinter

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages