Table of Content
Here are the topics we are going to cover
- Modify the code for the tic-tac-toe game to cover edge cases like
- Bad input
- Reset game
- Quit game
- Break the code for the tic-tac-toe game to separate files
- Rewrite the code for the tic-tac-toe game in python class
- Create a graphic user interface (GUI) with
tkinter
- Modified tic-tac-toe code: base.py
- Test the
tkinter
library for GUI: try_tkinter.py
- Widgets in
tkinter
[source]Widget Class Description Label A widget used to display text on the screen Button A button that can contain text and can perform an action when clicked Entry A text entry widget that allows only a single line of text Text A text entry widget that allows multiline text entry Frame A rectangular region used to group related widgets or provide padding between widgets
- slides [TBD]
- Online resources
- Modify the code in the class demo [link] for the tic-tac-toe game such that:
- Player could quit the game with command "q" and type in "y" to confirm and quit the game
- If the player regrets and types in "n" to continue the game, he could still type in "q" to try to quit the game again without being treated as invalid input
- Do the same to reset the game in the middle, use the command "reset"
graph LR;
A[Start] --> B[Input];
B --> C[Restart];
B --> D[Quit];
B --> E[Valid Position?];
C --> |Reset Board|A;
D --> F[End Game]
E --> |NO|B;
E --> |YES|G[Update the Board];
G --> H[Display the Board];
H --> I[Check Win];
I --> |YES|F;
I --> |NO|J[Check Tie];
J --> |YES|F;
J --> |NO|B;
- Research the usage of the library
tkinter
and build a window interface, such that
(We haven't covered much on the library tkinter
, so you might need some online research to figure out question 2)