Chess Engine in Python - Part 1 - Drawing the board
Why Stack Overflow recommends it
Stack Overflow users link it as the tutorial they were following when their pygame chessboard code fails to display, import, or run.
Recommended by 0 people across 0 different months, 2020 to 2022.
What it is
The first part of Eddie Sharick's multi-part series on building a chess engine in Python with pygame. This 47-minute screencast sets up the project, loads piece images and draws the 8x8 board and pieces from a game state object.
What people said
Cites Axhul · 2020-08 · Stack Overflow · on “Why won't pygame display my images or chessboard?”
I'm using Pycharm Community 2020 for my IDE. I'm using Python 3.7.4. I have the Pygame 1.9.6. So I've been following a YouTube video on how to code a working chessboard, but it isn't display my board to me with the pieces on it or anything. I have to separate python files to do this one for the Chess engine which is responsible for storing all the information about the current state of a chess game. Also will be responsible for determining the valid moves at the current state. It will also keep move log. Another is Chess Main which is the main driver file. It's responsible for handling user input and displaying the current game state object. Chess main code: WIDTH = HEIGHT = 512 # 400 is ano
Cites Satvik Agnihotri · 2020-11 · Stack Overflow · on “Syntax Error on def drawPieces(screen, board):”
Just for context - I have imported pygame into pycharm and am receiving an error on the def on def drawPieces(screen,board): The end goal is to build a chess engine but so far it's only been importing things and trying to set up something that looks like a chessboard/chess set. I am following this tutorial: [this video] Here is the rest of the code: """ This is our main driver file. It will be responsible for handling user input and displaying the current GameState object """ #import os #import sys #os.chdir(sys.path[0]) # thank adam ^^^^ import pygame as p from Chess import ChessEngine WIDTH = HEIGHT = 400 # CAN CHANGE TO 512 DIMENSION = 8 # Dimensions of a chess board are 8x8 SQ_Size = HEIGHT /
Cites Brian Barton · 2021-02 · Stack Overflow · on “from Chess import ChessEngine: error on Chess Engine”
I have reviewed the tutorial numerous times but still, I have this error. After the first video in the series, he is able to display the board. The error highlights ChessEngine on my import statement. this is my primary resource: [this video] This is the error: ImportError: cannot import name 'ChessEngine' from 'Chess' (unknown location) pls halp my code is the following ***import pygame as p from Chess import ChessEngine WIDTH = HEIGHT = 512 # optional 400 DIMENSIONS = 8 # dimensions are 8x8 SQ_SIZE = HEIGHT // DIMENSIONS MAX_FPS = 15 # For animation IMAGES = {} ''' Initialize global dictionary of images. this will be called once in the main ''' def load_images(): pieces = ["wp", "wR", "wN", "wB
Cites James · 2022-07 · Stack Overflow · on “AttributeError: 'function' object has no attribute 'GamesState'”
I am currently making a chess game. I have started to try and draw the board. I've started making the board and where the pieces will go. I wanted to run the code to see whether it works and I ended up getting the error. I am also using Eddie Sharick on youtube to help me make my code. For some reason it works for him but not for me. I'm not sure whether its because we are using different python versions. Link to his tutorial [this video] AtttributeError:"function" object has no attribute "GamesState". My first file called chess main: """ This is the main driver file. It will be responsible for handling user input and displaying the current gamesState object """ import pygame as p from chess impo