<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; 15 puzzle</title>
	<atom:link href="http://zhiqiang.org/blog/tag/15-puzzle/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>理工科背景的证券从业人员</description>
	<lastBuildDate>Sun, 05 Feb 2012 03:59:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>15 puzzle</title>
		<link>http://zhiqiang.org/blog/science/15-puzzle.html</link>
		<comments>http://zhiqiang.org/blog/science/15-puzzle.html#comments</comments>
		<pubDate>Fri, 07 Mar 2008 03:09:25 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[自然科学]]></category>
		<category><![CDATA[15 puzzle]]></category>
		<category><![CDATA[游戏]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/posts/15-puzzle.html</guid>
		<description><![CDATA[博客 » 自然科学 » 游戏 » 注：此游戏很有名，有同学问我其算法，我在网上找了一下，居然没多少中文资料，这里按照以前看过的一份答案回忆整理贴出。 游戏规则很简单，4*4的方格里有15个方格块，标记为1，2到15，有个位置是空的。每次方块可以滑动到旁边的空格中（与华容道类似）。问是否可以变成左下图这种状态？ 一个明确的问题是从右下图这种状态变到左下图的...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science">自然科学</a> » <a href='http://zhiqiang.org/blog/tag/%e6%b8%b8%e6%88%8f'>游戏</a>  » </p><p><font color="#808080">注：此游戏很有名，有同学问我其算法，我在网上找了一下，居然没多少中文资料，这里按照以前看过的一份答案回忆整理贴出。</font></p>
<p>游戏规则很简单，4*4的方格里有15个方格块，标记为1，2到15，有个位置是空的。每次方块可以滑动到旁边的空格中（与华容道类似）。问是否可以变成左下图这种状态？</p>
<p>一个明确的问题是从右下图这种状态变到左下图的标准状态。听说有人靠卖这个积木游戏赚了大钱，并且设定了一个高额奖金。</p>
<table style="text-align: center" align="center">
<tbody>
<tr>
<td>
<table style="margin: 10px; vertical-align: middle; width: 180px; height: 180px; text-align: center" cellspacing="1" cellpadding="1" summary="" border="1">
<tbody>
<tr>
<td>1</td>
<td bgcolor="#999999">2</td>
<td>3</td>
<td bgcolor="#999999">4</td>
</tr>
<tr>
<td bgcolor="#999999">5</td>
<td>6</td>
<td bgcolor="#999999">7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td bgcolor="#999999">10</td>
<td>11</td>
<td bgcolor="#999999">12</td>
</tr>
<tr>
<td bgcolor="#999999">13</td>
<td>14</td>
<td bgcolor="#999999">15</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td>
<table style="margin: 10px; vertical-align: middle; width: 180px; height: 180px; text-align: center" cellspacing="1" cellpadding="1" summary="" border="1">
<tbody>
<tr>
<td>1</td>
<td bgcolor="#999999">2</td>
<td>3</td>
<td bgcolor="#999999">4</td>
</tr>
<tr>
<td bgcolor="#999999">5</td>
<td>6</td>
<td bgcolor="#999999">7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td bgcolor="#999999">10</td>
<td>11</td>
<td bgcolor="#999999">12</td>
</tr>
<tr>
<td bgcolor="#999999">13</td>
<td>15</td>
<td bgcolor="#999999">14</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>定理：记空格为16。初始状态为<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_8910752a06909fea80740f7c2f0afe2d.gif' style='vertical-align: middle; border: none; ' class='tex' alt="1,2,\cdots, 16" /></span><script type='math/tex'>1,2,\cdots, 16</script>的一个排列<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\pi" /></span><script type='math/tex'>\pi</script>。方格黑白相隔染色。当且仅当<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\pi" /></span><script type='math/tex'>\pi</script>为偶排列且空格位于白色格 或者 <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\pi" /></span><script type='math/tex'>\pi</script>为奇排列且空格位于黑色格，可以移动到标准状态。</p>
<p>必要性：每次移动，<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\pi" /></span><script type='math/tex'>\pi</script>的奇偶性都改变，空格所在格子颜色亦发生改变。</p>
<p>充分性：按照1,2,3,4,5,9,13,6,7,8,10,14的顺序把格子移到正确的位置上即可。</p>
<p>推论：故从右上图是不可能变成左上图的。没有人能拿到奖金。</p>
<p>注1：一个排列<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_bbac17a41ad766e6eccf32356389137a.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="\pi_1, \pi_2, \cdots, \pi_n" /></span><script type='math/tex'>\pi_1, \pi_2, \cdots, \pi_n</script>的奇偶性定义为<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_8a562fcf32d0c326ce7eae18efee6968.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\prod_{i>j}(\pi_i-\pi_j)" /></span><script type='math/tex'>\prod_{i>j}(\pi_i-\pi_j)</script>的符号。正为偶排列，负为奇排列。任意调换两个数的位置都会改变其奇偶性。</p>
<p>注2：此结论和证明对<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_7ee5baf07aef80cee3140944ce0cf498.gif' style='vertical-align: middle; border: none; ' class='tex' alt="n\times n, n\geq 2" /></span><script type='math/tex'>n\times n, n\geq 2</script>的情形都有效</p>
<p>附录</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Fifteen_puzzle">15 puzzle@wikipedia</a>  </li>
<li>play online</li>
</ul>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/entertainment/fan-tan-game-empty-when-most-difficult-relationship.html">空当接龙中最难的关</a></li><li><a href="http://zhiqiang.org/blog/science/strategy-games-doctors-and-patients-i.html">策略游戏：医生和病人（I）</a></li><li><a href="http://zhiqiang.org/blog/science/theoritical-analysis-marfia-game.html">杀人的理论分析</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/most-windows-game-are-np-complete.html">Windows游戏中的NP完全问题</a></li><li><a href="http://zhiqiang.org/blog/science/rotate-coin-games.html">硬币游戏</a></li><li><a href="http://zhiqiang.org/blog/science/two-taking-coins-game.html">取硬币游戏</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/boxes-problem-on-static-data-structure-problems.html">摸箱子问题以及应用</a></li><li><a href="http://zhiqiang.org/blog/entertainment/cat-game.html">堵猫游戏</a></li><li><a href="http://zhiqiang.org/blog/entertainment/kerrigan-starcraft-ii.html">Kerrigan！</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2008. | <a href="http://zhiqiang.org/blog/science/15-puzzle.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/15-puzzle.html#comments">11 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/15-puzzle.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

