Skip to content

Conversation

@radi-cho
Copy link
Member

@radi-cho radi-cho commented Apr 21, 2018

All things described below were changed. Take a look at this for more information.

The problems that was solved in 2124faa, wasn't actually solved. We're replacing the game.board with gameState.board, but if it's passed from AI, worker or backend it won't contain the important getValidMoves methods.

So instead of replacing the game.board object we can use game.piece inside the ChessAI to create the right pieces with working game prototype and getValidMoves method.

Also it will be really helpful to rethink the playAgainstAI object.
At the moment we track if we has AI mode and do all AI stuff if it's true. But in some cases (like in RSG Chess mobile) we want to customize the AI movement but keep the pawn promotion or keep the default movement but change the promotion and check simulating. We can add these additional values to the playAgainstAI object, as well as moving the comingAI argument inside.

The object will look similar to this:

playAgainstAI {
  depth: number,
  move: bool,
  comingAI: bool,
  isThinking: bool,
  customAIPromotion: function,
  customAIMovement: function
}

@radi-cho radi-cho self-assigned this Apr 21, 2018
@radi-cho radi-cho added bug Something isn't working enhancement New feature or request in progress labels Apr 21, 2018
@radi-cho
Copy link
Member Author

radi-cho commented Apr 21, 2018

All things described below were changed. Take a look at this for more information.

TODOs

  • Fix the game.board cloning using game.piece
  • Move the comingAI argument to the playAgainstAI object
  • Add the additional checks and functions:
    • defaultMovement
    • defaultPromotion
    • customAIPromotion
    • customAIMovement
    • playAgainstAI.move

@radi-cho
Copy link
Member Author

radi-cho commented Apr 22, 2018

We will remove all playAgainstAI stuff from the game.moveSelected method

Reasons:

  • The playAgainstAI methods will generate AI moves and make movement. This usually must be done outside game.moveSelected, because It slows down the app, freezes the DOM and so one.
  • (For frameworks like React and Angular) When you make movement, re-render, generate AI, make movement, re-render the user have great experience. For difference game.moveSelected will do: movement, ("frozen DOM"), AI generation, movement, some other stuff, (FINALLY) re-render.
  • It'll be a lot EASIER to make lot more CUSTOMIZABLE AI experiences for the developers.

Example

I'm rewriting RSG Chess mobile to this new API in the AI-experiments branch https://github.com/RSG-Group/RSG-Chess-mobile/tree/AI-experiments

@radi-cho
Copy link
Member Author

Theoretically everything is fine now.

@radi-cho radi-cho merged commit 78b794c into master Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants