Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Empty file.
Empty file.
Binary file added assets/general pictures/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added assets/placeholder6.txt
Empty file.
46 changes: 46 additions & 0 deletions chess_pieces/_chess_piece.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#------------------------------------------------------------------------------
#CHESS PIECE
#------------------------------------------------------------------------------

#file containing the parent class for all chess pieces. this creates all of the attributes that can be individualised for each child chess piece

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#Chess piece class
#------------------------------------------------------------------------------
class chess_piece:

#attributes
def __init__(self, colour, p_ID, square):

#variable attributes
self.width, self.height = square.size #gets the size of the chess square so the piece can scale to fit it
self.colour = colour
self.p_ID = p_ID #p_ID is the piece ID. its used to identify different pieces for the algorithm to understand.

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #placeholder just to define in main class and give base image
self.image = pygame.transform.scale(self.image, (self.width*0.9, self.height*0.9)) #make the chess pieces a tiny bit smaller than the square
self.p_value = 0 #how much the chess piece is worth (for weighting). base value is 0 but will be different for all the child pieces

#list attributes for the chess piece
self.position = [] #coordinates for the chess piece
self.position_history = [] #history of where the piece has moved
self.legal_moves = [] #list of legal moves that the piece can make
self.defending = [] #list of pieces the piece is defending
self.attacking = [] #list of pieces the piece is attacking
self.defended_by = [] #list of pieces the piece is being defended by
self.attacked_by = [] #list of pieces the piece is being attacked by

#boolean states
captured = False
pinned = False
31 changes: 31 additions & 0 deletions chess_pieces/bishop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#------------------------------------------------------------------------------
#BISHOP
#------------------------------------------------------------------------------

#bishop chess piece class containing all animations and validation + frontend for bishop

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#file imports
#------------------------------------------------------------------------------
from _chess_piece import chess_piece

#------------------------------------------------------------------------------
#bishop class
#------------------------------------------------------------------------------
class bishop_p(chess_piece):
def __init__(self, colour, p_ID, square):
super().__init__(colour, p_ID, square) #stores paramaters the same as the parent class

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #change image to bishop image once created
self.p_value = 3 #how many points the bishop is worth
31 changes: 31 additions & 0 deletions chess_pieces/king.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#------------------------------------------------------------------------------
#KING
#------------------------------------------------------------------------------

#king chess piece class containing all animations and validation + frontend for the king

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#file imports
#------------------------------------------------------------------------------
from _chess_piece import chess_piece

#------------------------------------------------------------------------------
#king class
#------------------------------------------------------------------------------
class king_p(chess_piece):
def __init__(self, colour, p_ID, square):
super().__init__(colour, p_ID, square) #stores paramaters the same as the parent class

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #change image to king image once created
self.p_value = 10000 #how many points the king is worth. technically invaluable so a very big number is needed to value it
31 changes: 31 additions & 0 deletions chess_pieces/knight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#------------------------------------------------------------------------------
#KNIGHT
#------------------------------------------------------------------------------

#knight chess piece class containing all animations and validation + frontend for the knight

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#file imports
#------------------------------------------------------------------------------
from _chess_piece import chess_piece

#------------------------------------------------------------------------------
#knight class
#------------------------------------------------------------------------------
class knight_p(chess_piece):
def __init__(self, colour, p_ID, square):
super().__init__(colour, p_ID, square) #stores paramaters the same as the parent class

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #change image to knight image once created
self.p_value = 3 #how many points the knight is worth
31 changes: 31 additions & 0 deletions chess_pieces/pawn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#------------------------------------------------------------------------------
#PAWN
#------------------------------------------------------------------------------

#pawn chess piece class containing all animations and validation + frontend for the pawn

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#file imports
#------------------------------------------------------------------------------
from _chess_piece import chess_piece

#------------------------------------------------------------------------------
#pawn class
#------------------------------------------------------------------------------
class pawn_p(chess_piece):
def __init__(self, colour, p_ID, square):
super().__init__(colour, p_ID, square)

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #change image to pawn image once created
self.p_value = 1 #how many points the pawn is worth
31 changes: 31 additions & 0 deletions chess_pieces/queen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#------------------------------------------------------------------------------
#QUEEN
#------------------------------------------------------------------------------

#queen chess piece class containing all animations and validation + frontend for the queen

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#file imports
#------------------------------------------------------------------------------
from _chess_piece import chess_piece

#------------------------------------------------------------------------------
#queen class
#------------------------------------------------------------------------------
class queen_p(chess_piece):
def __init__(self, colour, p_ID, square):
super().__init__(colour, p_ID, square)

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #change image to queen image once created
self.p_value = 9 #how many points the queen is worth
31 changes: 31 additions & 0 deletions chess_pieces/rook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#------------------------------------------------------------------------------
#ROOK
#------------------------------------------------------------------------------

#rook chess piece class containing all animations and validation + frontend for the rook

#------------------------------------------------------------------------------
#libraries
#------------------------------------------------------------------------------
import pygame #GUI

#------------------------------------------------------------------------------
#initialisation
#------------------------------------------------------------------------------
pygame.init()

#------------------------------------------------------------------------------
#file imports
#------------------------------------------------------------------------------
from _chess_piece import chess_piece

#------------------------------------------------------------------------------
#rook class
#------------------------------------------------------------------------------
class rook_p(chess_piece):
def __init__(self, colour, p_ID, square):
super().__init__(colour, p_ID, square)

#attributes
self.image = pygame.image.load("assets/general pictures/placeholder.png").convert() #change image to rook image once created
self.p_value = 5 #how many points the rook is worth