ehulinsky / analogchess Goto Github PK
View Code? Open in Web Editor NEWChess but no grid
License: MIT License
Chess but no grid
License: MIT License
Sadly en passant (the funny move) is not implemented yet because I have no idea how it would work.
Maybe if a pawn passes through another pawn's line of attack, the pawn can choose to capture it?
Partially leaving this issue as a reminder to myself to look at code and see if I can even implement this
Thanks for the inspiration! My son and I wrote this in Typescript/React Native and it's now on the stores.
And a little about the build. I need to cleanup the repo a bit and figure out what keys and things are not supposed to be in a repo but we will make it public at some point.
This is a story of how Github Copilot can write some code.
Background: We're porting this to Javascript, and getting the initial piece function. You know, the one that goes
pieces = [Rook(0.5,0.5,white),
Rook(7.5,0.5,white),
Knight(1.5,0.5,white),
Knight(6.5,0.5,white),
Bishop(5.5,0.5,white),
Bishop(2.5,0.5,white),
King(4.5,0.5,white),
Queen(3.5,0.5,white),
... etc
I write
const initialGameState = [
{type: "pawn", color: "white", x:
COPILOT:
const gameState = [
{ type: "pawn", color: "white", x: 0, y: 1 },
...
No, that's not quite right. So I edit it and say x: 0.5
. And then it generates the next line
{type: "pawn", color: "white", x: 0.5, y: 1.5},
Great, let's keep going.
COPILOT:
{type: "pawn", color: "white", x: 0.5, y: 1.5},
{type: "pawn", color: "white", x: 1.5, y: 1.5},
Uh... this is looking uncanny. Let's see if it can do the rest.
COPILOT:
{type: "pawn", color: "white", x: 2.5, y: 1.5},
{type: "pawn", color: "white", x: 3.5, y: 1.5},
{type: "pawn", color: "white", x: 4.5, y: 1.5},
{type: "pawn", color: "white", x: 5.5, y: 1.5},
{type: "pawn", color: "white", x: 6.5, y: 1.5},
{type: "pawn", color: "white", x: 7.5, y: 1.5},
The back pieces are the hard part, right? And here's where it just completely goes wild and does everything like you'd expect.
COPILOT:
{type: "rook", color: "white", x: 0.5, y: 0.5},
{type: "knight", color: "white", x: 1.5, y: 0.5},
{type: "bishop", color: "white", x: 2.5, y: 0.5},
{type: "queen", color: "white", x: 3.5, y: 0.5},
{type: "king", color: "white", x: 4.5, y: 0.5},
{type: "bishop", color: "white", x: 5.5, y: 0.5},
{type: "knight", color: "white", x: 6.5, y: 0.5},
{type: "rook", color: "white", x: 7.5, y: 0.5},
{type: "pawn", color: "black", x: 0.5, y: 6.5},
{type: "pawn", color: "black", x: 1.5, y: 6.5},
{type: "pawn", color: "black", x: 2.5, y: 6.5},
{type: "pawn", color: "black", x: 3.5, y: 6.5},
{type: "pawn", color: "black", x: 4.5, y: 6.5},
{type: "pawn", color: "black", x: 5.5, y: 6.5},
{type: "pawn", color: "black", x: 6.5, y: 6.5},
{type: "pawn", color: "black", x: 7.5, y: 6.5},
{type: "rook", color: "black", x: 0.5, y: 7.5},
{type: "knight", color: "black", x: 1.5, y: 7.5},
{type: "bishop", color: "black", x: 2.5, y: 7.5},
{type: "queen", color: "black", x: 3.5, y: 7.5},
{type: "king", color: "black", x: 4.5, y: 7.5},
{type: "bishop", color: "black", x: 5.5, y: 7.5},
{type: "knight", color: "black", x: 6.5, y: 7.5},
{type: "rook", color: "black", x: 7.5, y: 7.5}
];
Copilot knows about analog chess!! ๐ฎ Literally all I did was type one line and then press tab to keep accepting the rest
.
Getting a bunch of errors like these in python 3.8.10+pygame 1.9.6:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
analogchessV4.py:47: DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
pygame.draw.polygon(surf, c, pts)
Traceback (most recent call last):
File "analogchessV4.py", line 1214, in <module>
piece.draw_paths(pieces)
File "analogchessV4.py", line 535, in draw_paths
draw_line_round_corners_polygon(see_through, to_screen_coords((self.start_x,self.start_y)), to_screen_coords(end_pos), RED_HIGHLIGHT, self.radius*2*640/8)
File "analogchessV4.py", line 48, in draw_line_round_corners_polygon
pygame.draw.circle(surf, c, p1, round(w / 2))
TypeError: integer argument expected, got float
It's easy to fix by converting all float lengths and coords to int
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.