Skip to content

A Bot to implement Tic-tac-toe game on FB messenger

Notifications You must be signed in to change notification settings

ZhuMon/Chat_Robot

Repository files navigation

Chat_Robot

https://hackmd.io/p/S1GCfktbE#/

  • A chat bot on FB messenger.
  • It's a Tic-tac-toe game.
  • You are "o", the bot is "x".
  • After send a text, it will return two image.

    text: A1, A2, A3, B1, B2, B3, C1, C2, C3

  • One is your choice, the other is the bot's choice.
  • You can send init to restart at any time.
  • Or send anything to see tutorial.

Dependencies

  • transitions
    • to implement FSM
  • pillow
    • to make image
  • pyimgur
    • to upload image to imgur.com
  • protobuf
    • record states of users
    • to handle multiple users
  • psycopg2
    • postgreSQL for python
    • to record url in imgur.com to avoid upload too many times
  • pygraphviz
    • to draw FSM
  • processing
    • only for draw base image

Deploy

  • heroku
  • docker

FB Fan Page

Usage

Initial State : user

You can type init at any time to go back to user state

Input a position to start the game bot

Example : user -> A1 -> A1B1 -> A1B1A3 -> A1B1A3C2

user

  • Input: A1
  • go to A1

A1

  • Reply:

  • Input: B1
  • go to A1B1

A1B1

  • Reply:

  • Input: A3
  • go to A1B1A3

A1B1A3

  • Reply:

  • Input: C2
  • go to A1B1A3C2

A1B1A3C2

  • Reply:

End in a tie

  • go to user

Finite State Machine

NOT complete FSM

The complete image is too big to push to github( 176 MB )

So split to 9 images

Removed the back flow

The fsm which has back flow(to user) will seem so mussy

  • A1 A1
  • B1 B1
  • C1 C1
  • A2 A2
  • B2 B2
  • C2 C2
  • A3 A3
  • B3 B3
  • C3 C3

About

A Bot to implement Tic-tac-toe game on FB messenger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages