Git Product home page Git Product logo

Comments (3)

erikbern avatar erikbern commented on July 28, 2024

sorry no idea, but if you figure out feel free to send over a PR!

from deep-pink.

brianprichardson avatar brianprichardson commented on July 28, 2024

I think this is related to Issue #11
By going back to python-chess 0.8.3 it seems to work.
In recent versions pieces is no longer iterable in bb2array()

from deep-pink.

Nick-Pieros avatar Nick-Pieros commented on July 28, 2024

I was having the same issue and, assuming my understanding of the original loop is correct, I may have a work around for python-chess 0.9.0 and newer.

This pretty much just walks through the board square by square (0 to 63) and does the calculations when it finds a piece.

`

python-chess 0.9.0 work around

board_pos = 0
# looping through each row 
for row in range(0, 8):
    # looping through each column
    for col in range(0, 8):
        # getting the Piece at the current position
        piece = b.piece_at(board_pos)
        # Checking that there is actually a piece at the current position
        if piece is not None:
            # getting the integer value of the piece (between 1 and 6)
            piece_val = piece.piece_type
            # getting the color of the piece
            color = int(piece.color)
            if flip:
                row = 7 - row
                color = 1 - color
                
            piece_val = color * 7 + piece_val

            x[row * 8 + col] = piece_val
        board_pos += 1

`

There may be a better/more efficient way to do this, I just wanted to come up with a quick work around. I'm still fairly new to Python so if there's anything that I should fix or improve in that loop let me know!

Edit:
Also, as brianpirchanderson pointed out, I believe this should be the same issue as #11

from deep-pink.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.