Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have 2 eight balls, cheater.</p> <p>In the given example, the solution takes 2 moves:</p> <p>2-5, 3-8<br> 3-4, 11-12</p> <p>An optimal solution is best found by configuring the problem for <a href="http://en.wikipedia.org/wiki/Dynamic_programming" rel="nofollow">dynamic programming</a> (DP). Since the problem is multi-stage with fixed costs and no uncertainties, a DP matrix will exist that optimally solves the problem.</p> <p>To create the matrix: note that accounting for symmetries the 8-ball can be in one of 9 positions. The solids can be arranged in about (14 choose 7)/2=1716 different ways. That means the total number of rack configurations is about 1716 * 9 = 15,444. Thus, you have 15,444 different possible states. Calculate the cost to go from any one of these states to any other. This results in a matrix with 15,444 * 15,444 cells, or about a quarter of a billion cells. Identify all the end-state cells. To solve the matrix you breadth search forwards from the starting state until you reach an end state (or until you reach a cost total greater than your current minimum cost). By doing this you will have provably found all the least cost paths.</p> <p>Note that the above solution is somewhat naive and can be optimized in various ways to yield a smaller matrix. For example, you can use rotational symmetry to reduce the number of cells and add a cost of 1 (for rotating the rack) to paths that are correct except for having the 8-ball in one of the low-center positions.</p> <pre><code>Pseudocode: Create DP Matrix: (1) determine number of possible arrangements, A, of balls (2) for each arrangement, make a list of possible unique moves ---- the possible moves are: ------- rotating right ------- rotating left ------- exchanging any pair of balls ------- exchanging any two pairs of adjacent balls (3) for each move in A store a pointer to the resulting arrangement (4) for each arrangment make an attribute indicating whether it is an end state Solve Problem (5) goto arrangement for starting position S (6) set best-cost-so-far (BCSF) variable to infinity (6) breadth search from S, accumulating current cost CC as +1 for each transition (7) if you reach an end state CC &lt; BCSF, then set BCSF = CC and make solution list contain only the current path (8) if you reach an end state CC = BCSF, then add path to solution list (9) if CC &gt; BCSF abandon branch and try next branch The result will be a list of all possible solutions and the minimum cost BCSF. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload