Wednesday, August 14, 2013

New KReversi design

Why we need new design?

  1. Player has no ability to play white.
  2. You can't play with friend (I mean hotseat mode).

Why we can't do changes at existing code?

Because current design has very bad level of abstraction: KReversiView controls part of game-flow, all code based on Computer-Player system with special code for computer and player moves, so to simply implement player-player mode we need to add many IF-statements to KReversiView, KReversiGame and mainwindow code.

What is new design?

I am going to bring especially new level of abstraction to KReversi:
  1. KReversiGame will control all of game-flow and game rules checking
  2. There will be KReversiPlayer interface. KReversiGame will have two such objects, that represent players
  3. There will be two implementations of KReversiPlayer class: KReversiHumanPlayer (for actual player sitting in front of computer), KReversiComputerPlayer (for AI player)
  4. KReversiView will not control any game rules, only UI and simple signal to indicate that somebody had pressed some cell on field
All this stuff will use qt signals and slots to connect to each other according to scheme below:

How we will use all this stuff?

Now we can simple pass (Computer, Human) or (Human, Computer) to play for black or white, we can pass (Computer, Computer) to see demo-mode or (Human, Human) to enable hotseat! That's the power of abstraction. Also somebody can implement KReversiPlayer interface to introduce network play :)

No comments:

Post a Comment