Share your repls and programming experiences

← Back to all posts
Play chess and listen to music
h
rediar (401)

Listen to the extremely relaxing and very quiet "ode to joy" while playing chess. Try playing chess while the chorus starts screaming.

Chess Note

Uses regular (FIDE) notation works like this: piece and where the piece went
. For example:

  • Pond from e2 to e4 is e4
  • Queen to h5 Qh5
    and so on! It now works, thanks for your support!

this project was done independently and works

Commentshotnewtop
snowboardsheep (22)

If only Ode to Joy played every time someone was waiting to install packages...

rediar (401)

@snowboardsheep yeah... katya you reading this?

[deleted]

I love this one! It's original and creative :)

katyadee (1227)

Chess + classical music = yes

AdrianHall (62)

After the first turn, it crashes if you give it an invalid command. This is because you have

try:
    chess_game()
except:
    print(sys.exc_info()[0])
chess_game()

The chess_game() is only being error-checked once. This will be fixed if you change the while loop at the end of chess_game to:

while True: # Instead of True, you can put a condition checking if the game has been won
    try:
        board=chess.Board(board.fen())
        move(board)
    except ValueError:
        print(colored('Move not recognized!', 'red'))

Also, you in general shouldn't define functions within a function. Right now inside def chess_game you include def statements for move, legal_move, loss, and tie. You can put these function definitions outside of the chess_game function definition and the code will work the same but with less chance for error and better speed and memory management.

Also, cool idea for using audio in a python project by embedding a repl within a repl. If only there were a way for the iframe to communicate with the webpage.

rediar (401)

@AdrianHall Yeah, but it doesn't crash if you give it a valid move. For me it jusg restarts the move, if you give it a invalid move, which is what I want. plus thanks!

AdrianHall (62)

@rediar No problem! It does restart the move, but only on the first move of the game! After that, it crashes if you make a typo.

rediar (401)

small problem, due to move detection, I use the board variable which results in a error if I move functions out, doesn't work with a global statement either. I will keep the code as is for [email protected]

AdrianHall (62)

@rediar I forked it a while back and it worked. Global statements should have solved the problems? Anyway, it works well enough as it is.

GrinInTheBin (16)

Didn't work for me, after second move it logs an error:

Traceback (most recent call last):
File "main.py", line 49, in <module>
chess_game()
File "main.py", line 41, in chess_game
move(board)
File "main.py", line 27, in move
if board.turn == True:
AttributeError: 'Move' object has no attribute 'turn'

rediar (401)

@GrinInTheBin Yeah, got that error, I'm working on it, thanks!

rediar (401)

@GrinInTheBin good news, bad news, I fixed that error, but a new one pops up, now you can make a thrilling 3 moves (white, black, white, crash)

GrinInTheBin (16)

@rediar Keep going, you are getting there :)

rediar (401)

@GrinInTheBin ok, I found the error, you can only move ponds. (not sure why)

rediar (401)

@duck132912 uh yeah the site is weird, heres the repl (no music) https://repl.it/@rediar/Chess#main.py right now not working because of poetry packaging errors... trying to get it fixed rn, but i think its a repl.it bug

rediar (401)

good news! its fixed! try it, if you know chess notation @duck132912 hope you enjoy