controller: Interact between views and models to handle
user input and update data structures
listener: Trigger when event (e.g. player clicks) happens
model: Hold data structures and handle game logics
view: Render the GUI interfaces and display on screen
Note: Despite of the naming, the project does NOT strictly follow the MVC design pattern for simplicity.
Randomly choose a piece, and randomly move to one of the available square...
Reference: https://github.com/aimacode/aima-java
......
Implement the java.io.Serializableinterface in the model classes
When saving, dump the object to file using ObjectOutputStream
Upon loading, load the object from file using ObjectInputStream
Store the data in yamlor json format
Or use databases like SQLite or MySQL
It also works in browser!
After program started
Main Thread: Generated by JVM executing main() method
AWT-Windows: Listen to UI events from AWT windows
AWT-Shutdown: Handle termination of AWT windows
AWT-EventQueue-0: Event dispatching thread, manage event processing
DestroyJavaVM: Cleanup work for JVM after program exits
Why we need multi-threading?
Avoid user interface not responding when program is busy
Reference: Lecture 5 Multi-threaded Swing
No response after clicking buttons
User can perform other operations with background tasks running
Processing content which may require long waiting
Loading and decoding the saved game
Waiting for network in client or server
Calculating AI moves
Playing background music or sound effects
SwingWorker< T, V >
SwingUtilitiesalso provides helper functions
......