Skip to content

Castling on Move() Broken? #2

@yamamushi

Description

@yamamushi
pe2-e4, pe7-e6
bf1-e2, pe6-e5
ng1-f3, pd7-d6
ke1-g1 == Error func can_castle: cannot castle

The section of code that appears to be responsible is:

func (b *Board) can_castle(side int) bool {
...
...
...
348: 		if i != 2 {
349:  			for _, p := range b.Board {
350: 				if p.Color == b.Turn*-1 && p.Attacking(s, b) {
351: 					return false
352:  				}
353:  			}
354:  		}

I'm not familiar enough with how the internals of the castling check works, but setting that to "true" does let castling work. If I had to guess, this is checking to see if a piece is being attacked or crosses the line of attack while moving, but the check doesn't seem to be working as intended.

In my own fork I've left it as "true" to just let games continue, knowing that there may be an illegal move made at some point. I'd rather have that than no castling at all 😆

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions