AnalogChess
AnalogChess copied to clipboard
AI knows everything!!!
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