Skip to content

Latest commit

 

History

History

README.md

Chess robot

Do you also like chess, and do you also hate cheaters? However, it can be beneficial to get experience with cheating techniques, at least just to spot them easily when they are being employed against you.

This project is creating a chess robot that is performing moves on a "physical screen" chessboard, as a response to opponents moves.

See video


Architecture

Structure of the project tries to implement clean architecture principles described by Clean Architecture book by Robert Martin. The main idea is to separate all the unique components and make them independent of each other.

It is apparent from the big amount of modules, that are all assembled together by main.py - using dependency injection.

All the interfaces between modules/components are defined in api.py - using typing.Protocol, which creates abstract classes for type-checking purposes.

Users of this interface specify this class as a type of the object they want to work with. Each implementation inherits from this abstract class. Type-checker (mypy or pyright) will then statically analyze the code to see if the object being passed to the user is really compatible with the interface. Also on the implementation side, when any interface method is badly (or not) implemented, it will complain about it.

The Clean Architecture book defines SOLID principles. Their implementing means:

  • grouping together components that change for the same reason
    • (S)ingle Responsibility Principle
  • new plugins can be created without modifying old code
    • (O)pen Closed Principle
  • each component can be tested independently and without knowing implementation details
    • (L)iskov Substitution Principle
  • users depend only on what they really need
    • (I)nterface Segregation Principle
  • components are not dependent on implementation details in other components they use
    • (D)ependency Inversion Principle

Architecture diagram

architecture diagram