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

Create a function that returns a list of available pawn moves #1

Closed
8 tasks done
RobStallion opened this issue Dec 4, 2018 · 2 comments
Closed
8 tasks done
Assignees

Comments

@RobStallion
Copy link
Owner

RobStallion commented Dec 4, 2018

  • Create a function that checks the available moves a pawn can make.
    • will need to take a tile and return a list of indexes that the pawn can move to
    • will need to use piece colour to filter moves that a pawn can make (black pawns move in negative numbers. White pawns move in positive numbers)
    • Will need to turn the list of pawn moves into a list of tile indexes that a pawn can move to.
    • will need to filter out indexes that are out of bounds
    • if pawn is on home square allow pawn to move two tiles forward (keep pawn index + 20 in the list of int else remove it)
    • Is a piece blocking the pawns way? if so remove tile from list (also remove tiles after the tile that is blocked. e.g. if pawn is on b2(22) and wants to move to b4(42) but there is a piece on b3(32), remove both b3 and b4 as options)
    • is there an opponent piece on tiles 9/11 in front or behind the current tile a pawn is on. If so allow pawn to move there and replace(capture) that piece. If the piece is a same team just remove the tile.
Edits View issue history
Edit Count View History: http://localhost:4000/issues/387354004
@RobStallion RobStallion self-assigned this Dec 4, 2018
@RobStallion RobStallion changed the title Create a function that checks for available pawn moves Create a function that returns a list of available pawn moves Dec 5, 2018
@RobStallion
Copy link
Owner Author

This was proving to be a little more difficult than I first expected. Not sure if my first approach was not best or if I should update my data structures.

Going to look into another approach for now

@RobStallion
Copy link
Owner Author

My next approach is going to be to put more information in the tile and remove some from the Piece.

Tile will remain the same but the Status will contain more information (if the tile has a light or dark piece, if the tile is empty, if the type is available for a piece to move to etc)

I will be able to update a tiles status to available if a piece can move to it. This should help remove some of the more complex logic that was building up in my first approach.

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

No branches or pull requests

1 participant