![]() |
BitBully 0.0.74
|
Public Member Functions | |
| None | __init__ (self, dict[str, Connect4Agent]|Sequence[Connect4Agent]|None agents=None, *, bool autoplay=False) |
| AppLayout | get_widget (self) |
| None | destroy (self) |
Public Attributes | |
| m_logger = logging.getLogger(self.__class__.__name__) | |
| dict | m_png |
| m_n_row | |
| int | m_n_col = 6, 7 |
| m_height = np.zeros(7, dtype=np.int32) | |
| float | m_board_size = 3.5 |
| bool | is_busy = False |
| autoplay = bool(autoplay) | |
| dict | agents = {} |
| str | yellow_player = "human" |
| str | red_player = self._agent_names[0] if self._agent_names else "human" |
| str | eval_agent_choice = "auto" |
| list | m_movelist = [] |
| list | m_redolist = [] |
| bool | m_gameover = False |
| dd_yellow | |
| dd_red | |
| cb_autoplay | |
| dd_eval_agent | |
| player_select_row | |
| m_status_label | |
| m_active_player_label | |
| m_time_row | |
| ta_moves | |
| btn_copy_pos | |
| btn_copy_moves_ag | |
| move_list_row | |
| list | ims |
| dict | m_control_buttons = {} |
| list | m_eval_labels |
| m_eval_row | |
| output = Output() | |
| m_fig = fig | |
| m_axs = axs | |
| list | m_insert_buttons |
Static Public Attributes | |
| widgets | notify_output = widgets.Output() |
Protected Member Functions | |
| None | _create_player_selectors (self) |
| None | _create_status_bar (self) |
| None | _create_move_list_ui (self) |
| str | _position_string (self) |
| str | _moves_ag_string (self) |
| None | _update_move_list_ui (self) |
| None | _copy_to_clipboard (self, str text) |
| None | _copy_position_string (self) |
| None | _copy_moves_ag (self) |
| int | _current_player (self) |
| str | _controller_for_player (self, int player) |
| Connect4Agent|None | _agent_for_player (self, int player) |
| Connect4Agent|None | _agent_for_evaluation (self) |
| None | _reset (self) |
| npt.NDArray[np.float64] | _get_fig_size_px (self) |
| None | _create_control_buttons (self) |
| None | _create_eval_row (self) |
| None | _clear_eval_row (self) |
| None | _evaluate_board (self) |
| None | _computer_move (self) |
| None | _create_board (self) |
| None | _popup (self, str text) |
| Board | _board_from_history (self) |
| None | _insert_token (self, int col, bool reset_redo_list=True) |
| None | _redo_move (self) |
| None | _undo_move (self) |
| None | _update_insert_buttons (self) |
| int | _get_img_idx (self, int col, int row) |
| None | _paint_token (self) |
| None | _create_buttons (self) |
| HBox | _create_column_labels (self) |
| None | _on_field_click (self, mpl_backend_bases.Event event) |
| None | _maybe_autoplay (self) |
| None | _check_winner (self, Board board) |
Protected Attributes | |
| list[str] | _agent_names = list(self.agents.keys()) |
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:
notify_output (widgets.Output): Output widget for notifications and popups.
Examples:
Generally, you should this method to retreive and display the widget.
```pycon
>>> %matplotlib ipympl
>>> c4gui = GuiC4()
>>> display(c4gui.get_widget())
```
| None bitbully.gui_c4.GuiC4.__init__ | ( | self, | |
| dict[str, Connect4Agent] | Sequence[Connect4Agent] | None | agents = None, | ||
| * | , | ||
| bool | autoplay = False ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| None bitbully.gui_c4.GuiC4.destroy | ( | self | ) |
| AppLayout bitbully.gui_c4.GuiC4.get_widget | ( | self | ) |
|
protected |
| bitbully.gui_c4.GuiC4.btn_copy_moves_ag |
| bitbully.gui_c4.GuiC4.btn_copy_pos |
| bitbully.gui_c4.GuiC4.cb_autoplay |
| bitbully.gui_c4.GuiC4.dd_eval_agent |
| bitbully.gui_c4.GuiC4.dd_red |
| bitbully.gui_c4.GuiC4.dd_yellow |
| bitbully.gui_c4.GuiC4.m_active_player_label |
| list bitbully.gui_c4.GuiC4.m_eval_labels |
| bitbully.gui_c4.GuiC4.m_eval_row |
| bitbully.gui_c4.GuiC4.m_height = np.zeros(7, dtype=np.int32) |
| bitbully.gui_c4.GuiC4.m_logger = logging.getLogger(self.__class__.__name__) |
| dict bitbully.gui_c4.GuiC4.m_png |
| bitbully.gui_c4.GuiC4.m_status_label |
| bitbully.gui_c4.GuiC4.m_time_row |
| bitbully.gui_c4.GuiC4.move_list_row |
|
static |
| bitbully.gui_c4.GuiC4.player_select_row |
| str bitbully.gui_c4.GuiC4.red_player = self._agent_names[0] if self._agent_names else "human" |
| bitbully.gui_c4.GuiC4.ta_moves |