<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Bubble Breaker in Python / Javascript\n",
    "\n",
    "The key 'board' data structure is a ```numpy``` array, which is (for efficiency) stored on its side (with the bottom-right phone cell being the board[0,0] cell):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from model.game import crush\n",
    "from model.game import crush_ui\n",
    "\n",
    "import importlib\n",
    "importlib.reload(crush)\n",
    "importlib.reload(crush_ui)\n",
    "\n",
    "crush.new_board(10, 14, n_colours=5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Key trick for this notebook is the ability for Jupyter to go 'round-trip' from Python back-end to Javascript in the browser, and back again.  There's a block of helper javascript in the (Python) file ```crush-ui```:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "from IPython.display import HTML\n",
    "\n",
    "#HTML(crush_ui.javascript_test)\n",
    "HTML(crush_ui.javascript_base)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Having imported that base code, we can now create UI elements for javascript to manipulate :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "javascript = \"\"\"\n",
    "<div id=\"board_10_14_trial\"></div>\n",
    "<script type=\"text/Javascript\">create_board(\"#board_10_14_trial\",10,14,5);</script>\n",
    "\"\"\"\n",
    "HTML(javascript)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And, now initialise a board and display it:"
   ]
  },
  {<commit_msg>Quick demo to MY<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Bubble Breaker in Python / Javascript\n",
    "\n",
    "The key 'board' data structure is a ```numpy``` array, which is (for efficiency) stored on its side (with the bottom-right phone cell being the board[0,0] cell):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from model.game import crush\n",
    "from model.game import crush_ui\n",
    "\n",
    "import importlib\n",
    "importlib.reload(crush)\n",
    "importlib.reload(crush_ui)\n",
    "\n",
    "crush.new_board(10, 14, n_colours=5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Key trick for this notebook is the ability for Jupyter to go 'round-trip' from Python back-end to Javascript in the browser, and back again.  There's a block of helper javascript in the (Python) file ```crush-ui```:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "from IPython.display import HTML\n",
    "\n",
    "#HTML(crush_ui.javascript_test)\n",
    "HTML(crush_ui.javascript_base)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Having imported that base code, we can now create UI elements for javascript to manipulate :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "javascript = \"\"\"\n",
    "<div id=\"board_10_14_trial\"></div>\n",
    "<script type=\"text/Javascript\">create_board(\"#board_10_14_trial\",10,14,5);</script>\n",
    "\"\"\"\n",
    "HTML(javascript)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And, now initialise a board and display it:"
   ]
  },
  {
{'fraction_non_alphanumeric': 0.19040767386091126, 'fraction_numerical': 0.009592326139088728, 'mean_word_length': 2.826605504587156, 'pattern_counts': {'":': 70, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4879071', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1495, 'n_words': 361}