marcusbuffett / command-line-chess

A python program to play chess against an AI in the terminal.
MIT License
496 stars 156 forks source link

New CLI #31

Closed ClasherKasten closed 1 year ago

ClasherKasten commented 1 year ago

Right now the CLI looks like this:

try:
    if len(sys.argv) >= 2 and sys.argv[1] == "--two":
        twoPlayerGame(board)
    else:
        playerSide = askForPlayerSide()
        board.currentSide = playerSide
        print()
        aiDepth = askForDepthOfAI()
        opponentAI = AI(board, not playerSide, aiDepth)
        printBoard(board)
        startGame(board, playerSide, opponentAI)
except KeyboardInterrupt:
    sys.exit()

I think it would be a cool idea to switch to argparse.ArgumentParser which would make it more readable and easier to add new features to it. A few feature proposals:

If you want to propose other new features you would like to see, please leave a comment or create an issue.

GauthamBellamkonda commented 1 year ago

Hello @ClasherKasten,

I have largely understood the issue, and would love to contribute to it.

Could you please elaborate what you meant by the second point?

  • Options to set colors (Fixed set of colors / completely variable)

Do you want to give the users an option to customise colours (from the red-blue combination currently being used) in the terminal? Could you give a format of how the chess program should be run with such options?

ClasherKasten commented 1 year ago

Hey @GauthamBellamkonda,

first: cool that you are so interested in the project. :+1:

Yes, to begin with, a simple option would be to let the user customize the colors for black and white pieces and if they don't specify one, we could always fall back to the red-blue combination that exists right now. Some more advanced option could also be to let the user specify a background-color and/or a theme for the chess-board (this would require a kinda big change in the board rendering because we would need to render black and white tiles differently what the program doesn't do at the time).

Because we are talking about a CLI, i think the options should roughly look like this as an example:

chess --white="#123456" --black="#9abcde"

and if it accepts these long names for option, it probably should also support the short form:

chess -w "#123456" -b "#9abcde"

But these two are just my ideas, if you have an idea that you think looks better or provides a better user experience, feel free to contribute those instead.

If you have any further questions, feel free to ask.

GauthamBellamkonda commented 1 year ago

Thanks for the response @ClasherKasten. Will start working on this. Can you assign this issue to me?

GauthamBellamkonda commented 1 year ago

@ClasherKasten, what I have noticed is that termcolor supports only few standard colors and cannot take hex codes as an input. To give full flexibility of colors to the user, perhaps we should use a different python library which has support for hex codes. What do you say?

ClasherKasten commented 1 year ago

@ClasherKasten, what I have noticed is that termcolor supports only few standard colors and cannot take hex codes as an input.

By reviewing your PR I noticed that too.

To give full flexibility of colors to the user, perhaps we should use a different python library which has support for hex codes. What do you say?

Definitely, it would be a very good idea too look out for another library which could replace termcolor and provide more flexibility for the user.