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

Deferred action #20

Open
olufjen opened this issue Feb 1, 2021 · 12 comments
Open

Deferred action #20

olufjen opened this issue Feb 1, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@olufjen
Copy link
Owner

olufjen commented Feb 1, 2021

Create an action during the planning procedures.
An example:
We need a plan for castling.
Step one:
We want to move Whitebishop2. Then we must first move WhitePawn5.
Create an ActionSchema
initState of Pawn
goalState of Bishop.

If such an actionSchema exists then find actionSchema for Pawn and execute.
Wait for opponent
Then find actionSchema for Bishop and execute.,
Wait for opponent

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

olufjen commented Feb 4, 2021

At present chessactions are created as part of the minimax search process.
When created the chessaction is given a AgamePiece, its reachable positions and the player who owns the piece.
Based on this the chessaction creates a possible move for this piece.

A deferred action is created with the following in mind:
I want to move a certain piece to a certain position.
I need to determine which piece I want to move.
I need to determine what position I want to mover it to.
I need the following information to achieve this:

  • Where are the opposing pieces?
  • What positions do they threaten?
  • What opposing pieces can I take?, and to what cost?

The Chesspiece has a calculated value: Pawn = 1, Rook = 5, Bishop ans Knight = 3, Queen = 9.
The King has default value 0.

@olufjen
Copy link
Owner Author

olufjen commented Feb 8, 2021

The Problem object uses permutations to calculate other actions. It uses all constants in all positions of the preconditions and effects.
This is shown in the enclosed file.
https://app.zenhub.com/files/137453363/7a0d9f6d-2626-4ac3-837b-aa3d85a38a1e/download

31.03.21

This has now been changed

@olufjen
Copy link
Owner Author

olufjen commented Apr 5, 2021

Castling and deferred actions:
OBS OBS: [occupies(WhiteKing,g1), OWNER(WhitePlayer,WhiteKing), PIECETYPE(WhiteKing,PAWN), BOARD(g1)]
06.04.21
Corrected

@olufjen
Copy link
Owner Author

olufjen commented Apr 9, 2021

After White castling the white Rook has the following positions:
The removed positions are not cleared?
The removed positions are calculated by the PreferredMove Processor
This is called when the ChessAction is created and by the player's calculatePreferredPosition method

Piece name WhiteRook2
Piece position f1 X, Y (5, 0) wR f1 ROOK ActiveName R
Available positions
Position: h1 W X, Y (7, 0)
Position: g1 B X, Y (6, 0) Occupied by: WhiteKing
Position: f2 B X, Y (5, 1) Occupied by: WhitePawn6
Position: e1 B X, Y (4, 0)
Position: f3 W X, Y (5, 2) Occupied by: WhiteKnight2
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: f4 B X, Y (5, 3)
Position: c1 B X, Y (2, 0) Occupied by: WhiteBishop1
Position: f5 W X, Y (5, 4) Occupied by: BlackBishop1
Position: b1 W X, Y (1, 0)
Position: f6 B X, Y (5, 5) Occupied by: BlackKnight2
Position: a1 B X, Y (0, 0) Occupied by: WhiteRook1
Position: f7 W X, Y (5, 6) Occupied by: BlackPawn6
Position: f8 B X, Y (5, 7) Occupied by: BlackRook2
Removed positions
Position: h2 B X, Y (7, 1) Occupied by: WhitePawn8
Position: e1 B X, Y (4, 0)
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: c1 B X, Y (2, 0) Occupied by: WhiteBishop1
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: a1 B X, Y (0, 0) Occupied by: WhiteRook1
Position: h3 W X, Y (7, 2)
Position: h4 B X, Y (7, 3)
Position: h5 W X, Y (7, 4)
Position: h6 B X, Y (7, 5) Occupied by: BlackPawn8
Position: h7 W X, Y (7, 6)
Position: h8 B X, Y (7, 7)
Position: b1 W X, Y (1, 0)

All the h positions should not be there.

@olufjen
Copy link
Owner Author

olufjen commented Apr 9, 2021

Must clear deferred moves:
After castling:
Caused by: java.lang.NullPointerException
at no.chess.web.model.game.AChessProblemSolver.deferredMove(AChessProblemSolver.java:817)
at no.chess.web.model.game.AChessProblemSolver.planProblem(AChessProblemSolver.java:852)

Deferred actions must be cleared done 09.04.21

@olufjen
Copy link
Owner Author

olufjen commented Apr 9, 2021

Too many removed positions:
Piece name WhiteRook2
Piece position f1 X, Y (5, 0) wR f1 ROOK ActiveName R
Available positions
Position: h1 W X, Y (7, 0)
Position: g1 B X, Y (6, 0) Occupied by: WhiteKing
Position: f2 B X, Y (5, 1) Occupied by: WhitePawn6
Position: e1 B X, Y (4, 0)
Position: f3 W X, Y (5, 2) Occupied by: WhiteKnight2
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: f4 B X, Y (5, 3)
Position: c1 B X, Y (2, 0) Occupied by: WhiteBishop1
Position: f5 W X, Y (5, 4) Occupied by: BlackBishop1
Position: b1 W X, Y (1, 0)
Position: f6 B X, Y (5, 5) Occupied by: BlackKnight2
Position: a1 B X, Y (0, 0) Occupied by: WhiteRook1
Position: f7 W X, Y (5, 6) Occupied by: BlackPawn6
Position: f8 B X, Y (5, 7) Occupied by: BlackRook2
Removed positions
Position: g1 B X, Y (6, 0) Occupied by: WhiteKing
Position: f2 B X, Y (5, 1) Occupied by: WhitePawn6
Position: f3 W X, Y (5, 2) Occupied by: WhiteKnight2
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: c1 B X, Y (2, 0) Occupied by: WhiteBishop1
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: a1 B X, Y (0, 0) Occupied by: WhiteRook1
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: d1 W X, Y (3, 0) Occupied by: WhiteQueen
Position: e1 B X, Y (4, 0)
Position: b1 W X, Y (1, 0)
Position: f4 B X, Y (5, 3)
Position: f5 W X, Y (5, 4) Occupied by: BlackBishop1
Position: f6 B X, Y (5, 5) Occupied by: BlackKnight2
Position: f7 W X, Y (5, 6) Occupied by: BlackPawn6
Position: f8 B X, Y (5, 7) Occupied by: BlackRook2

@olufjen
Copy link
Owner Author

olufjen commented Apr 12, 2021

12.04.21:
Caused by: java.lang.NullPointerException
at no.chess.web.model.game.AChessProblemSolver.deferredMove(AChessProblemSolver.java:821)
at no.chess.web.model.game.AChessProblemSolver.planProblem(AChessProblemSolver.java:852)

12.04.21 solved

@olufjen
Copy link
Owner Author

olufjen commented Apr 12, 2021

The black castle disappeared:
This happens when black performs castling

blackcastling.PNG

The "correct" castling:

coorectcastling.PNG

See code for explaination

@olufjen
Copy link
Owner Author

olufjen commented Apr 13, 2021

Create diagrams for the default part of the checkMovenumber method !!!

@olufjen
Copy link
Owner Author

olufjen commented Apr 14, 2021

OBS The castling move notation here:

castlingmove.PNG

The castle has been moved
castle.setCastlingMove(true);
movedPiece.setCastlingMove(true);
This must reset after castling?

@olufjen
Copy link
Owner Author

olufjen commented Apr 15, 2021

After successful castling:

Caused by: java.lang.NullPointerException
at no.chess.web.model.PlayGame.proposeMove(PlayGame.java:307)
at no.chess.web.server.resource.RapporterChessStartServerResourceHTML.storeChess(RapporterChessStartServerResourceHTML.java:808)

The chessAgent returned an action that is null

noaction.PNG

My WhitePawn5 is threatened, but it cannot be moved!!!!

@olufjen
Copy link
Owner Author

olufjen commented May 3, 2021

A "no-move" after the castling:
The rook is "moved" back to its original position.

castling030521.PNG

There should be a move after Bishop Bf5

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