sir-lancebot
sir-lancebot copied to clipboard
Sudoku command
Description
I would like to make a Sudoku game command for Lancebot. Here are the rules for playing Sudoku, in case you don't know: https://sudoku.com/how-to-play/sudoku-rules-for-complete-beginners/
Reasoning
Sudoku is one of the most popular puzzle games in the world currently and it provides a good challenge for your brain.
Proposed Implementation
- The bot will print an embed with a 6x6 Sudoku board, like so:
- The grid will have the columns numbered and rows alphabetized, like so:
- User will simply enter their input for the game by typing the coordinates of the square that they want to enter a number in (ex. A3), then the number they want to input (ex. 8). So in this case, what the user would type is:
A3 8
. If the user guesses correctly, then the bot will automatically update the original embed with the correct guess added. If the user wishes to edit their guess, they may do so by simply editing the message. If the user wants to remove a number from a square, they can type something like this:A3 X
. - Make 2 buttons, one called "Hint" and the other "Give Up". I think it's obvious what I want those buttons to do :)
- To avoid spam of the "Hint" button, I'm going to record the last time the button is pressed using the built-in
time
module in Python and count 3 minutes from that time and after that time elapses, allow the user to click that button again. Then the process repeats. - I am also considering the possibility of the bot generating puzzles with multiple or no solutions. The way I'm going to prevent this from happening is by using the backtracking method. I did some research online and I will be using this website as a guide.
Would you like to implement this yourself?
- [ ] I'd like to implement this feature myself
- [x] Anyone can implement this feature
Sudoku is fun, but I'm not sure it's well suited to be played in discord. An average Sudoku game takes about 20 minutes to play which seems quite a long time for a discord mini game. What about a mini Sudoku in a 4x4 grid?
Sudoku is fun, but I'm not sure it's well suited to be played in discord. An average Sudoku game takes about 20 minutes to play which seems quite a long time for a discord mini game. What about a mini Sudoku in a 4x4 grid?
Ok, maybe you're right about the game being too long, but how would a 4x4 grid work? @Sn4u
The rules are the same, just with less numbers
The rules are the same, just with less numbers
Ok, if that's the case, then I can do that.
As we were talking about on discord, by reducing the size to a 4x4, we could use buttons for the user interface instead Although, a 4x4 seems kind of small for a sudoku game, it should be fun enough.
However, if using buttons, it would not be possible to expand it any larger, so it would be a tradeoff that we would need to make.
As we were talking about on discord, by reducing the size to a 4x4, we could use buttons for the user interface instead Although, a 4x4 seems kind of small for a sudoku game, it should be fun enough.
However, if using buttons, it would not be possible to expand it any larger, so it would be a tradeoff that we would need to make.
I think 4x4 should be fine with buttons. Not sure what you mean by "tradeoff" @onerandomusername
Given we can only have 5x5 buttons in total as discord limitation, if we use buttons we cannot ever grow beyond that size.
Given we can only have 5x5 buttons in total as discord limitation, if we use buttons we cannot ever grow beyond that size.
Ah, I see. To be honest, now that I think about this, I feel like 4x4 would a bit too easy. Another thought I had was to make this game thread based so it's not taking up the entire channel but they haven't been enabled on PyDis yet, so I'm not sure if that's possible, at least without making this issue stalled.
Its not possible right now to use threads, no. I do know that you would be able to get some nice colours out of the codeblock by setting the codeblock language.
The main reason I was on buttons is because the suggested input does not seem the most user-friendly--but only if there's a better option.
r[insert row #]c[insert column #]v[insert # (value)]
This looks complicated to me, although its probably the best way to input a number. We maybe could try something with selects and buttons... but this works so...
What about an image of the board that we edit every time the player makes a move? Could be done with PIL
What about an image of the board that we edit every time the player makes a move? Could be done with PIL
See https://github.com/python-discord/sir-lancebot/pull/956#issuecomment-997322591
I'm not familar with PIL myself, either
Its not possible right now to use threads, no. I do know that you would be able to get some nice colours out of the codeblock by setting the codeblock language.
The main reason I was on buttons is because the suggested input does not seem the most user-friendly--but only if there's a better option.
r[insert row #]c[insert column #]v[insert # (value)]
This looks complicated to me, although its probably the best way to input a number. We maybe could try something with selects and buttons... but this works so...
Yeah, I think that is the best option for the input because the bot needs to know exactly what row and column the user is inputting a number so I think I'm going to stick with that.
About the button implementation, I'm honestly at odds as to what the best way to implement this is. I did have the idea of using modified images with PIL, but I'm not really that good at it (i.e. I don't really understand how it works, just like I said in the comment that arl linked). I'm going to think about this more and write up my thoughts here. If anyone else has any ideas as to how best to implement this, please let me know. Thanks!
@onerandomusername Actually, I did end up thinking of another way to implement the user input that's better than what I had originally proposed. We could have the user enter their input like so:
row #, col #, #
(one message)
Or:
row #
col #
#
(^ separate messages, and maybe have the bot send an embed saying "Enter row #" then enter row # then another embed, etc.) What do you think?
it's possible, yeah.
I think it's safe to implement it now as it is, but write a separate method to get the input so we can continue to bikeshed it and make it easier to change in the future.
it's possible, yeah.
I think it's safe to implement it now as it is, but write a separate method to get the input so we can continue to bikeshed it and make it easier to change in the future.
So are you saying it's fine to implement the user input the way I originally proposed? @onerandomusername
I'm thinking that's the input style we should use for now unless someone has a really really really great fantastic user input idea
I'm thinking that's the input style we should use for now unless someone has a really really really great fantastic user input idea
Alright, sounds good. I mean, the only other thing I can think of (and you mentioned this yourself I believe) is that I could use dropdowns. Do you think I should do that or just stick with the original proposal? @onerandomusername
Its not possible right now to use threads, no. I do know that you would be able to get some nice colours out of the codeblock by setting the codeblock language. The main reason I was on buttons is because the suggested input does not seem the most user-friendly--but only if there's a better option.
r[insert row #]c[insert column #]v[insert # (value)]
This looks complicated to me, although its probably the best way to input a number. We maybe could try something with selects and buttons... but this works so...
Yeah, I think that is the best option for the input because the bot needs to know exactly what row and column the user is inputting a number so I think I'm going to stick with that.
About the button implementation, I'm honestly at odds as to what the best way to implement this is. I did have the idea of using modified images with PIL, but I'm not really that good at it (i.e. I don't really understand how it works, just like I said in the comment that arl linked). I'm going to think about this more and write up my thoughts here. If anyone else has any ideas as to how best to implement this, please let me know. Thanks!
Ok, so I think I have made my final thoughts about this.
Here's my opinion: I think I should 1) not use 4x4 because as I said earlier, it's a bit too easy and may make the game not as interesting to play and 2) wait until PyDis supports threads (if it's not too far from now), that way the game doesn't block the entire sir-lancebot-playground channel and also allow me to make the game the original 9x9 game.
If none of you like that idea, then I think it's safe to say this won't be possible, unless you guys have other ideas. (cc @Sn4u @onerandomusername )
Ok, so based off this discussion (starts there), I have (hopefully) made my final decisions as to how I (and others) want this implemented.
- Instead of a 4x4 (or 9x9 for that matter), I will be making a 6x6 grid generator instead
- I will not be adding the embed that says whether a user's input is right or wrong
- I will also be numbering each column and alphabetizing each row as shown below:
That way, I can make it so that user can guess by entering something like
B6 8
. If the user wishes to edit their guess, they will simply edit the message with their guess. If they wish to remove a number from the board, the user would edit the message to sayB6 X
.
I believe those are the main takeaways from that conversation I linked. @onerandomusername @Sn4u Let me know if I missed anything.
Lastly, just to make sure: @jb3, do you still approve of this happening with those changes I mentioned above (in this comment)?
Quick update on this: I am still working on this, just haven't opened a PR yet - I don't think I'm ready to do that yet. I'm planning on getting it to a state where I will feel comfortable opening a PR sometime between now and the end of August. (Yes I know that's a large timeframe, but this turned out to be a lot harder than I initially thought but I like the challenge so I'm going to keep working on this for now.)
I do not wish to continue working on this (you can see the code I wrote so far here), feel free to ask to be assigned to this issue if you would like to work on it. Thanks!!
@DMFriends I would like to have a go at this.
@DMFriends I would like to have a go at this.
Go ahead! Good luck!
@n0Oo0Oo0b I've assigned you.
Given there have been a few different proposals for how this could be done here, could you clarify what you are working on? (e.g. what size, how it will be displayed to the user, how the user will enter guesses)
- For grid size, I will start with a 4x4 but I might also add a 6x6 option later
- The grid will be displayed as an image
-
.sudoku start
to start,.sudoku [location] [number]
to enter guesses. If the guess is correct, the board will be updated (most likely edit the original message). If the guess is incorrect, the bot will indicate it (perhaps a:x:
reaction) and leave the board unchanged.
Sounds good 👍
@n0Oo0Oo0b Hello. Just wondering if there has been any progress on this feature. I'd like to see it get implemented. Thanks!
@n0Oo0Oo0b Hello. Just wondering if there has been any progress on this feature. I'd like to see it get implemented. Thanks!
I did have some progreess on the board generation but this has been on my backburner for a while. I'll be able to work on it soon once my exams are over and I'll open a draft PR once the board generation is done.