Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game strategies from week 46 #35

Open
olufjen opened this issue Nov 18, 2021 · 10 comments
Open

Game strategies from week 46 #35

olufjen opened this issue Nov 18, 2021 · 10 comments
Labels
enhancement New feature or request

Comments

@olufjen
Copy link
Owner

olufjen commented Nov 18, 2021

The parent and strategy knowledge bases are now complete.
We need to find the best move based on the available knowledge bases.

The Chess Problem Solver and the Chess Search Algorithm are the main objects used to find the best move.
The Chess Problem Solver creates a ChessProblem that contains a set of Action Schemas.
And the Chess Search Algorithm searches the Chess Problem for the best actions forward.
The Chess Problem Solver creates the Actions Schemas in two steps:
First the planning phase.:
An Action Schema is created for every Chess Action that contains a possible move, and that is not otherwise blocked.
Then in the scheduling phase, the Problem Solver adds temporal information. The basis for this temporal information is held in the parent and strategy knowledge bases.
This is done to make sure that the plan meets any resource constraints.
(See chapter 11)

@olufjen olufjen added the enhancement New feature or request label Nov 18, 2021
@olufjen
Copy link
Owner Author

olufjen commented Dec 2, 2021

This remaining issue has been solved:
A remaining issue:
The reachable positions a6 and a4 are not listed:
occupies(WhiteBishop2,b5)
REACHABLE(WhiteBishop2_b5,f1)
REACHABLE(WhiteBishop2_b5,e2)
REACHABLE(WhiteBishop2_b5,d3)
REACHABLE(WhiteBishop2_b5,c4)
REACHABLE(WhiteBishop2_b5,c6)

The reachable a2 and a4 are not listed:
occupies(WhiteQueen,b3)
REACHABLE(WhiteQueen_b3,c3)
REACHABLE(WhiteQueen_b3,b2)
REACHABLE(WhiteQueen_b3,b4)
REACHABLE(WhiteQueen_b3,a3)
REACHABLE(WhiteQueen_b3,b5)
REACHABLE(WhiteQueen_b3,b6)
REACHABLE(WhiteQueen_b3,b7)
REACHABLE(WhiteQueen_b3,c4)
REACHABLE(WhiteQueen_b3,d5)
REACHABLE(WhiteQueen_b3,d1)
REACHABLE(WhiteQueen_b3,c2)

@olufjen
Copy link
Owner Author

olufjen commented Dec 21, 2021

A new game:
game211221

This is the result when the clause PROTECTEDBY is added to the precondition and effect of the Action Schema

@olufjen
Copy link
Owner Author

olufjen commented Dec 21, 2021

Another game:
game211221_v1
This is the result when the clause PROTECTEDBY is added to the precondition and effect of the Action Schema and the OWNER clause is removed.
The term of the predicate PROTECTEDBY is a Variable. Then this variable is instantiated by any Constant.

@olufjen
Copy link
Owner Author

olufjen commented Dec 23, 2021

Game after the protector is a constant from the list of pieces:
game231221

OBS: The castling

@olufjen
Copy link
Owner Author

olufjen commented Dec 23, 2021

The "normal " game:
normalgame
Step by step.

@olufjen
Copy link
Owner Author

olufjen commented Dec 23, 2021

When several protectors are added:
game231221_v1

The castling is not complete and pawn b2 is moved

@olufjen
Copy link
Owner Author

olufjen commented Dec 24, 2021

A normal game:
game241221
Bugs have been removed from the PROTECTOR predicate.
The last move:
When white moves pawn e4. It must realize that opponent can take that pawn and threaten two officers, the bishop and the knight.
Does the knowledge bases contain information that tells it so?
PIECETYPE(BlackPawn5,PAWN)
THREATENEDBY(BlackPawn5,c4)
THREATENEDBY(BlackPawn5,e4)
So White knows e4 is threatened-

In the probePossibilities method of the opponent agent:
The Chess Problem Solver the "probed possible" positions for the player. We must do so also for the opponent.

@olufjen
Copy link
Owner Author

olufjen commented Dec 25, 2021

Another bug:

Chosen action Schema
Action(WhiteBishop2)
PRECOND:^PROTECTEDBY(BlackPawn2,a6)^PROTECTEDBY(BlackRook1,a6)^occupies(WhiteBishop2,d3)^PIECETYPE(WhiteBishop2,BISHOP)
EFFECT:^occupies(WhiteBishop2,a6)^PIECETYPE(WhiteBishop2,BISHOP)

The opponent pieces do not protect the player's pieces.
The end move: The bishop is moved to e2!?

@olufjen
Copy link
Owner Author

olufjen commented Jan 3, 2022

A castling but no castling:
game030122
The king is moved but is interpreted as castling.
This is why:
The fluents of end outcome:

occupies(WhiteBishop2,f1)
BOARD(f1)
PIECETYPE(WhiteBishop2,BISHOP)
REACHABLE(WhiteBishop2,c4)
BOARD(c4)
REACHABLE(WhiteBishop2,b5)
BOARD(b5)
REACHABLE(WhiteBishop2,a6)
BOARD(a6)
REACHABLE(WhiteBishop2,g2)
BOARD(g2)
REACHABLE(WhiteBishop2,e2)
BOARD(e2)
REACHABLE(WhiteBishop2,d3)
BOARD(d3)
PROTECTEDBY(WhiteKnight1,b5)
PROTECTEDBY(WhiteKnight1,e2)
PROTECTEDBY(WhiteQueen,d3)
PROTECTEDBY(WhiteQueen,e2)
PROTECTEDBY(WhiteKing,e2)
The fluents of goal state:

occupies(WhiteBishop2,c4)
PIECETYPE(WhiteBishop2,BISHOP)
BOARD(c4)

End chess search with a reserve plan
And the WhitePawn 2 is moved

@olufjen
Copy link
Owner Author

olufjen commented Jan 3, 2022

The above
WhiteBishop2 movement is:
From position f1 Color W Direction NONE sumdif 5 Piece no.chess.web.model.ChessPiece Ontology name WhiteBishop2
Chesspiece position f1
Piece active: true true Friendly false gamepiece null

To position d3 Color W Direction NONE sumdif 2 Piece None false Friendly false gamepiece Gamenone
The preconditions and effects are:
Chosen action Schema
Action(WhiteBishop2)
PRECOND:^PROTECTEDBY(BlackPawn5,c4)^occupies(WhiteBishop2,f1)^PIECETYPE(WhiteBishop2,BISHOP)
EFFECT:^occupies(WhiteBishop2,c4)^PIECETYPE(WhiteBishop2,BISHOP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant