gui_c4
GUI module for the BitBully Connect-4 interactive widget.
Classes:
| Name | Description |
|---|---|
GuiC4 |
A class which allows to create an interactive Connect-4 widget. |
GuiC4
GuiC4(agents: dict[str, Connect4Agent] | Sequence[Connect4Agent] | None = None, *, autoplay: bool = False)
A class which allows to create an interactive Connect-4 widget.
GuiC4 is an interactive Connect-4 graphical user interface (GUI) implemented using Matplotlib, IPython widgets, and a backend agent from the BitBully engine. It provides the following main features:
- Interactive Game Board: Presents a dynamic 6-row by 7-column Connect-4 board with clickable board cells.
- Matplotlib Integration: Utilizes Matplotlib figures to render high-quality game visuals directly within Jupyter notebook environments.
- User Interaction: Captures and processes mouse clicks and button events, enabling intuitive gameplay via either direct board interaction or button controls.
- Undo/Redo Moves: Supports undo and redo functionalities, allowing users to navigate through their move history during gameplay.
- Automated Agent Moves: Incorporates BitBully, a Connect-4 backend engine, enabling computer-generated moves and board evaluations.
- Game State Handling: Detects game-over scenarios, including win/draw conditions, and provides immediate user feedback through popup alerts.
Attributes:
| Name | Type | Description |
|---|---|---|
notify_output |
Output
|
Output widget for notifications and popups. |
Examples:
Generally, you should this method to retreive and display the widget.
Methods:
| Name | Description |
|---|---|
destroy |
Destroy and release the acquired resources. |
get_widget |
Get the widget. |
Source code in src/bitbully/gui_c4.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
m_png
instance-attribute
m_png = {0: {'plain': png_empty, 'corner': png_empty_m, 'underline': png_empty_r}, 1: {'plain': png_yellow, 'corner': png_yellow_m}, 2: {'plain': png_red, 'corner': png_red_m}}
destroy
get_widget
Get the widget.
Examples:
Generally, you should this method to retreive and display the widget.
Returns:
| Name | Type | Description |
|---|---|---|
AppLayout |
AppLayout
|
the widget. |
Source code in src/bitbully/gui_c4.py
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | |