|
1 | 1 | { |
2 | 2 | "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "# notebooks live under notebooks/; run from the repo root so that\n", |
| 10 | + "# `from aima import ...` and the cwd-relative aima-data/ and images/ paths resolve.\n", |
| 11 | + "import os, sys\n", |
| 12 | + "if os.path.basename(os.getcwd()) == 'notebooks':\n", |
| 13 | + " os.chdir('..')\n", |
| 14 | + "if os.getcwd() not in sys.path:\n", |
| 15 | + " sys.path.insert(0, os.getcwd())" |
| 16 | + ] |
| 17 | + }, |
3 | 18 | { |
4 | 19 | "cell_type": "markdown", |
5 | 20 | "metadata": {}, |
|
628 | 643 | "source": [ |
629 | 644 | "## N-QUEENS\n", |
630 | 645 | "\n", |
631 | | - "The N-queens puzzle is the problem of placing N chess queens on an N\u00d7N chessboard in a way such that no two queens threaten each other. Here N is a natural number. Like the graph coloring problem, NQueens is also implemented in the csp module. The **NQueensCSP** class inherits from the **CSP** class. It makes some modifications in the methods to suit this particular problem. The queens are assumed to be placed one per column, from left to right. That means position (x, y) represents (var, val) in the CSP. The constraint that needs to be passed to the CSP is defined in the **queen_constraint** function. The constraint is satisfied (true) if A, B are really the same variable, or if they are not in the same row, down diagonal, or up diagonal. " |
| 646 | + "The N-queens puzzle is the problem of placing N chess queens on an N×N chessboard in a way such that no two queens threaten each other. Here N is a natural number. Like the graph coloring problem, NQueens is also implemented in the csp module. The **NQueensCSP** class inherits from the **CSP** class. It makes some modifications in the methods to suit this particular problem. The queens are assumed to be placed one per column, from left to right. That means position (x, y) represents (var, val) in the CSP. The constraint that needs to be passed to the CSP is defined in the **queen_constraint** function. The constraint is satisfied (true) if A, B are really the same variable, or if they are not in the same row, down diagonal, or up diagonal. " |
632 | 647 | ] |
633 | 648 | }, |
634 | 649 | { |
|
2775 | 2790 | "version_minor": 0 |
2776 | 2791 | }, |
2777 | 2792 | "text/plain": [ |
2778 | | - "interactive(children=(IntSlider(value=0, description='iteration', max=20), Output()), _dom_classes=('widget-in\u2026" |
| 2793 | + "interactive(children=(IntSlider(value=0, description='iteration', max=20), Output()), _dom_classes=('widget-in…" |
2779 | 2794 | ] |
2780 | 2795 | }, |
2781 | 2796 | "metadata": {}, |
|
2789 | 2804 | "version_minor": 0 |
2790 | 2805 | }, |
2791 | 2806 | "text/plain": [ |
2792 | | - "interactive(children=(ToggleButton(value=False, description='Visualize'), ToggleButtons(description='Extra Del\u2026" |
| 2807 | + "interactive(children=(ToggleButton(value=False, description='Visualize'), ToggleButtons(description='Extra Del…" |
2793 | 2808 | ] |
2794 | 2809 | }, |
2795 | 2810 | "metadata": {}, |
|
2924 | 2939 | "version_minor": 0 |
2925 | 2940 | }, |
2926 | 2941 | "text/plain": [ |
2927 | | - "interactive(children=(IntSlider(value=0, description='iteration', max=473, step=0), Output()), _dom_classes=('\u2026" |
| 2942 | + "interactive(children=(IntSlider(value=0, description='iteration', max=473, step=0), Output()), _dom_classes=('…" |
2928 | 2943 | ] |
2929 | 2944 | }, |
2930 | 2945 | "metadata": {}, |
|
2938 | 2953 | "version_minor": 0 |
2939 | 2954 | }, |
2940 | 2955 | "text/plain": [ |
2941 | | - "interactive(children=(ToggleButton(value=False, description='Visualize'), ToggleButtons(description='Extra Del\u2026" |
| 2956 | + "interactive(children=(ToggleButton(value=False, description='Visualize'), ToggleButtons(description='Extra Del…" |
2942 | 2957 | ] |
2943 | 2958 | }, |
2944 | 2959 | "metadata": {}, |
|
3008 | 3023 | "version_minor": 0 |
3009 | 3024 | }, |
3010 | 3025 | "text/plain": [ |
3011 | | - "interactive(children=(IntSlider(value=0, description='iteration', max=27, step=0), Output()), _dom_classes=('w\u2026" |
| 3026 | + "interactive(children=(IntSlider(value=0, description='iteration', max=27, step=0), Output()), _dom_classes=('w…" |
3012 | 3027 | ] |
3013 | 3028 | }, |
3014 | 3029 | "metadata": {}, |
|
3022 | 3037 | "version_minor": 0 |
3023 | 3038 | }, |
3024 | 3039 | "text/plain": [ |
3025 | | - "interactive(children=(ToggleButton(value=False, description='Visualize'), ToggleButtons(description='Extra Del\u2026" |
| 3040 | + "interactive(children=(ToggleButton(value=False, description='Visualize'), ToggleButtons(description='Extra Del…" |
3026 | 3041 | ] |
3027 | 3042 | }, |
3028 | 3043 | "metadata": {}, |
|
0 commit comments