拆迁通知
嗯,目前的情况不允许我做钉子户,为了爱与正义、为了和谐,我不得不搬家到自己的主机空间了,新BLOG使用wordpress,域名是www.limboy.com, RSS不变。
今后的更新都会在新的BLOG进行,而这里将会在GOOGLE的搜索结果中永垂不朽!(好罢这话太猥琐了……)
感谢Blogger这几个月来带给我的诸多乐趣。
See you Google Blogger, sometime somewhere
这里既空虚又充实,没有规则,没有约束。在这里,创造来自思考,现实源自梦想,生存依赖想像
嗯,目前的情况不允许我做钉子户,为了爱与正义、为了和谐,我不得不搬家到自己的主机空间了,新BLOG使用wordpress,域名是www.limboy.com, RSS不变。
今后的更新都会在新的BLOG进行,而这里将会在GOOGLE的搜索结果中永垂不朽!(好罢这话太猥琐了……)
感谢Blogger这几个月来带给我的诸多乐趣。
See you Google Blogger, sometime somewhere
作者: Dexter.Yy 发表于 4/05/2007 01:49:00 上午 18 条评论
标签: end
以前在龙骑士城堡提过一种想法,就是用GOOGLE MAPS来做桌面游戏玩家的主题地图。当时推荐的是EEMAP的服务,然则这个网站的注册一直需要邀请码,很不方便,而且界面难看,速度也很慢……
当时就想过自己来做一个GOOGLE MAPS API的应用,但一直没时间看API文档。这几天总算有空闲(辞职就是好哑),把想象中的东西基本上做出来了,我把它叫作Free Map Folio v1.0(取自DND设定集的名字),可以像维基百科那样自由编辑,前端是静态的HTML,数据库用xml,方便部署,而交互操作的程序完全用Javascirpt来写,只需要打开一个HTML页面,然后整个使用过程都不需要刷新页面,也不需要从外部获取数据(只用AJAX提交数据)。
演示:桌面游戏玩家主题地图(乱加东西要记得删掉)——
以前在龙骑士城堡提过一种想法,就是用GOOGLE MAPS来做桌面游戏玩家的主题地图。当时推荐的是EEMAP的服务,然则这个网站的注册一直需要邀请码,很不方便,而且界面难看,速度也很慢……
当时就想过自己来做一个GOOGLE MAPS API的应用,但一直没时间看API文档。这几天总算有空闲(辞职就是好哑),把想象中的东西基本上做出来了,我把它叫作Free Map Folio v1.0(取自DND设定集的名字),可以像维基百科那样自由编辑,前端是静态的HTML,数据库用xml,方便部署,而交互操作的程序完全用Javascirpt来写,只需要打开一个HTML页面,然后整个使用过程都不需要刷新页面,也不需要从外部获取数据(只用AJAX提交数据)。
演示:桌面游戏玩家主题地图(乱加东西要记得删掉)——http://www.ntrpg.org/yy/maps/
Javascirpt的主要代码有700行,都写在一个对象里(yymap),我本来想把每个单独的功能都封装起来,避免重复代码(DRY原则?),不过后来页面右侧栏加入了“地点列表”之后,程序就改复杂了……………以后有空要做一下重构……
用户只需要访问一个静态的HTML页面,唯一一次从外部获取数据是在地图加载的时候,用了API提供的XmlHttpRequest对象,非常方便,比如GXml.parse可以把responseText获得的文本转换成XML DOM。不过用GXmlHttp和GDownloadUrl的时候,IE7都会遇到一个缓存问题(IE6没试过):刷新页面后,不会重新下载XML文件,因此页面上的数据不会更新。解决方法是在xml文件的地址后面加随机参数(感谢tinyfool的帮助):
var ramnum = parseInt(100000*Math.random());
var request = GXmlHttp.create();
request.open("GET", "db.xml?x="+ramnum, true);
标记(Marker)的样式可以自定义,所以我做了一个选择图标的功能,先建立所有图标的基本属性(yymap.baseIcon),包括阴影图片和各种尺寸,然后在创建新标记时,根据用户选择的图标,把地址传给icon.image就行了。其实还可以做一个自定义图片的功能,允许用户在编辑器里上传自己的图片(比如照片)当作图标,只是必须把图片处理成固定大小的32位PNG……
点击标记弹出的信息窗口是最麻烦的东西,因为页面里同时只能存在一个信息窗口,而信息窗口里的内容也不能保存在标记的对象里,所以要修改某个标记对应的信息窗内容,就只能修改它的点击事件:
GEvent.addListener(marker, "click", function()
{
yymap.whenClickMarker(marker,info,point,icon.image);
});
我在点击事件里传了4个参数:点击的标记对象 , 信息窗的内容, 标记的经纬度, 标记使用的图标, 除了用来显示信息窗,也是为了把它们传给全局变量(因为编辑这个标记的时候会用到)。
为了让右侧栏列表与地图上的图标一一对应,我在列表的每个链接上设了跟标记对应的ID,每次做添加、编辑或删除的操作时,除了修改标记本身的点击事件,还要用ID找到列表上对应的链接,修改链接的点击事件…………总之,感觉这个侧栏列表很添乱……却又是必要的功能……
在我写这篇文章时,还有一个搜索地名的功能没做好。本来API提供了地理译码的功能,可以把符合格式的地名转换成JSON数据(用JS对象来传递数据的格式),但这么方便的东西我却享受不了——地理译码还没有支持中国的地名…………在地图上就能很明显的看到:周围日本、印度,都有详细的城市名字,放大后还有交通信息,而中国是一片空白…………
因此对于不熟悉地理的用户来说,要在这样的中国地图上找到某个城市可能太难了,搜索地名是必须的功能。由于没有地理译码,目前使用GOOGLE MAPS API的网站,比如EEMAP,都是自己建立地名和经纬度对应的数据库。我找到了一个很全的“乡镇级中国行政区划地标”,是GOOGLE EARTH用的KMZ文件,但其实就是压缩过的XML,用WINRAR打开就能看到一个KML文件,可以直接拿来当搜索数据库。我考虑过两种实现方法:把用户输入的中文地名用AJAX发给PHP,让PHP搜索这个XML文件里匹配的标签,然后返回相应的经纬度;或者直接用GXmlHttp下载XML,然后用JS的DOM方法来搜索相应的标签,第二种方法很合我的胃口,不需要借道PHP,遗憾的是…………这意味着搜索时要用AJAX获得19M的XML数据……更新:地名搜索已经完成了,模糊搜索范围包括省会、地级市、县城、村镇……足行匹配,搜索对象在KML文件里排名越靠后,搜索时间越长,不过最多应该不超过5秒……
我刚才测试了一下,搜索不到结果时4.36s,搜索最后一个地名“番阳”需要4.02s,搜索北京1.16s,搜索克拉玛依只需要华丽的328ms
php是由以前的同事Skylin帮忙写的,由于PHP只负责根据AJAX提交的数据,修改XML文件,所以内容很少……然则Skylin不肯用PHP5自带的XML类,而是自己写正则……最后代码只有几十行……果然是高手风范……
比如,这是remove.php:<?php
include "./globals.php";
$file_content = join('',file("../db.xml"));
if(preg_match("/<marker>\r\n<id>".intval($_POST['id'])."<\/id>.*<\/marker>\r\n\r\n/isU",$file_content,$array))
{
$file_content = str_replace($array[0],'',$file_content);
}
$fp = fopen("../db.xml","w+");
flock($fp,LOCK_EX);
fputs($fp,$file_content);
flock($fp,LOCK_UN);
fclose($fp);
?>
不过正则也容易出现问题,例如:在我最初做的XML数据库里面,标签的前面都有缩进,大概因为有的缩进是TAB,有的是空格,导致正则一直出错,只好把XML里的缩进全部删掉了……
目前已经全部完工,可能还有一些小BUG需要修改,比如:在简介里输入全角字符(比如·和——),会导致后面的字符都无法保存。P.S. 单引号、双引号和"&"容易引起JS错误,我把它们都屏蔽了-_____-b
作者: Dexter.Yy 发表于 3/13/2007 04:10:00 下午 10 条评论
今天是大年十四……现在来写年终总结和展望之类的东西,确实晚了一点。年前一直在策划一个很大的项目,做基础的框架,忙的没时间写,本来以为在年后项目进入实际开发阶段,会消耗更多精力,所以假期里也一直在抓紧时间休息。
记得去年的三月,正是我离开学校开始找工作的时候,在那之前似乎是假期,我在家里玩DDO(龙与地下城在线),是一名敏捷16智力18的翻滚系法师,从欧服的内测玩到国内的内测,被盛大DDO项目组的某人拉去当人物卡比赛活动的评委(虽然什么都没做),靠着几十个内测帐号撑腰,在NTRPG创建了DDO班。更早之前,我每天都在学校附近的网吧里玩WOW,是Lilium公会的兽人术士伊鲁亚夏(是的,就是犬夜叉的意思),帮忙做安其拉开门任务,在希利苏斯的沙漠里打虫皮、杀联盟败狗,多次深夜通宵后终于推倒了住在黑石塔山顶的耐法利安,遗憾的是FD时间比联盟晚了很多——以上采用的是倒叙手法。
今天是大年十四……现在来写年终总结和展望之类的东西,确实晚了一点。年前一直在策划一个很大的项目,做基础的框架,忙的没时间写,本来以为在年后项目进入实际开发阶段,会消耗更多精力,所以假期里也一直在抓紧时间休息。
记得去年的三月,正是我离开学校开始找工作的时候,在那之前似乎是假期,我在家里玩DDO(龙与地下城在线),是一名敏捷16智力18的翻滚系法师,从欧服的内测玩到国内的内测,被盛大DDO项目组的某人拉去当人物卡比赛活动的评委(虽然什么都没做),靠着几十个内测帐号撑腰,在NTRPG创建了DDO班。更早之前,我每天都在学校附近的网吧里玩WOW,是Lilium公会的兽人术士伊鲁亚夏(是的,就是犬夜叉的意思),帮忙做安其拉开门任务,在希利苏斯的沙漠里打虫皮、杀联盟败狗,多次深夜通宵后终于推倒了住在黑石塔山顶的耐法利安,遗憾的是FD时间比联盟晚了很多——以上采用的是倒叙手法。
回到去年三月这个时间点来,在神秘力量的影响下,我突然从网络中的RPG世界回到了现实中的RPG世界,开始为自己在现实中扮演的人物做一些打算。那时我曾一度觉得游戏策划是最适合自己的职业,因为游戏会涉及到大量领域:视觉表现、流行文化、中古历史、军事战争、音乐、建筑、SF/F、文明…………我觉得只有这个职业才能发挥自己全部的能力,不浪费自己的每一点积累。我到现在仍然不确定这个想法是不是正确,因为当时只去了一家游戏公司——法国GAMELOFT(上海),据说是最大的手机游戏研发企业,隶属于Ubi,在NTRPG某位强者的介绍下,填写了一份表格,就直接去上海面试+笔试了,非常天真的只呆了一天就回家等结果,结果出乎意料,手机游戏的关卡设计似乎跟我所注重的某些游戏性存在矛盾,笔试的关卡图修改了2次,最终没有通过。于是我赶忙在本地找了一家做WEB的公司——出发去上海前就接到了他们的OFFER。
前天我从那家公司辞职了,写辞职信这种事从来没做过,试过之后发现其实不比写BLOG难多少。这一年的时间比预想的长,却和一年前计划的一样,在技术上提高很多,Planescape:Torment里的吉斯泽莱人Dakkon有一句话用来形容这一年很贴切:Endure. In enduring, grow strong.
Dakkon还说过:” When a mind does not know itself, it is flawed. When a mind is flawed, the man is flawed. When a man is flawed, that which he touches is flawed. It is said that what a flawed man sees, his hands make broken ”.
现在的我已经没有做游戏策划的念头了,因为我现在可以确认自己最擅长、最想做的事情。在短暂的人生中,有些东西也许永远只能作为兴趣,而某些东西能让人成为真正的强者——其实这仍然跟游戏中的人物成长一样,比如说在EVE里就不可能平均的提升每种技能——因为时间和点卡都有限。Dakkon:『知道』自己是一条艰苦的道路。
The Nameless One: 知道后,我知道再过不久我要到那里去。时间和命运即将临到,我不会再留在这里。
现在我准备离开家去开始新的冒险,当我把这件事告诉家人和同学时,他们的眼中都带着一丝怀疑,但我知道这其实就像命运一样必然。就好像在WOW里,人类不能永远呆在艾尔文森林,在魔法门7里,你的四人小队不能永远留在翡翠岛或哈蒙代尔,在博德之门里,你不能永远生活在烛堡。
前段时间在动漫贩上看到BLEACH的TV动画已经结束了原创剧情,回到了漫画的破面篇,于是我赶忙去从110话开始下载,看了之后虽然觉得剧情节奏控制的很不好,但仍然很高兴BLEACH的回归。巧合的是,在同一个字幕组的BT发布页面里我还看到了这样的标题:『火影忍者_Naruto』『220·启程』,于是把它和220-221话也拖下来,发现NARUTO也刚刚回到了漫画剧情,进入“疾风篇”(起这样的名字大概是因为沙忍的出场次数多),虽然新篇章的音乐让我有些顾虑(好像没有増田俊郎参与),但片头曲却棒的没话说,画面的节奏感同样让人震撼,在youtube的评论里,大部分人都跟我抱有同样的想法,认为这是NARUTO至今为止最棒的OP。
我很高兴现在又可以看热血的少年战斗系动画,它们跟我一样,在新的一年里开始新的篇章。
NARUTO的新OP“Hero's come back”的视频:
作者: Dexter.Yy 发表于 3/03/2007 08:56:00 下午 4 条评论
标签: CRAP
做这个导航栏的初衷,是想在公司产品的后台界面里,模仿MAC OS X系统的dock效果,所谓dock,就是OS X桌面底部那条显眼的工具栏,我的UBUNTU桌面里也有类似的效果……
实际上我也没用过MAC,所以是凭想象做的,演示页面在此:
http://www.ntrpg.org/yy/yy/demo/iconmenu.htm
右上角的导航栏是默认的效果,鼠标滑过时图标变大,会推挤旁边的图标。
下面第一排去掉了推挤效果。
第二排加入了左右移动的功能,图标的数量远远超出页面的宽度,只显示其中一部分,在导航栏上左右移动鼠标时,整个导航栏会向相反方向滑动,显示出隐藏的图标。
第三排把移动的操作改到了左右两侧的箭头,鼠标停留在箭头上时,导航栏就会向对应的方向滑动,鼠标离开箭头时滑动停止,当滑动到最末端的图标时,自动停止。
做这个导航栏的初衷,是想在公司产品的后台界面里,模仿MAC OS X系统的dock效果,所谓dock,就是OS X桌面底部那条显眼的工具栏,我的UBUNTU桌面里也有类似的效果……
实际上我也没用过MAC,所以是凭想象做的,演示页面在此:
http://www.ntrpg.org/yy/yy/demo/iconmenu.htm
右上角的导航栏是默认的效果,鼠标滑过时图标变大,会推挤旁边的图标。
下面第一排去掉了推挤效果。
第二排加入了左右移动的功能,图标的数量远远超出页面的宽度,只显示其中一部分,在导航栏上左右移动鼠标时,整个导航栏会向相反方向滑动,显示出隐藏的图标。
第三排把移动的操作改到了左右两侧的箭头,鼠标停留在箭头上时,导航栏就会向对应的方向滑动,鼠标离开箭头时滑动停止,当滑动到最末端的图标时,自动停止。
先实现导航栏的默认效果,HTML如下:
<!-- ICON menu -->
<div class="iconbarout">
<div id="iconbar0" class="iconbar" >
<ul style="margin-left:0px;">
<li>
<a href="#">
<img src="images/icon7.png" style="width:68px;height:68px;" onload="alphaPNG(this);" onmouseover="largeIcon(this);" onmouseout="reIcon(this);" />
<span>link7</span>
</a>
</li>
<li>
<a href="#">
<img src="images/icon6.png" style="width:68px;height:68px;" onload="alphaPNG(this);" onmouseover="largeIcon(this);" onmouseout="reIcon(this);" />
<span>link6</span>
</a>
</li>
</ul>
</div>
</div>
<!-- ICON menu end -->
为了追求立体感,图标不能有背景色,所以必须用透明PNG图片,这里用<img>标签插入图片,是因为要实现图标的缩小放大效果(CSS背景里的图片只能控制位置,不能改变大小),图标的长宽要写在元素的style属性里,方便JS程序控制。
由于IE6不支持PNG的透明背景,必须用滤镜来做HACK才能达到一样的效果,而滤镜只能写在CSS的背景属性里…………为了解决这个矛盾,就要依靠JS了:
function alphaPNG(png)
{
var aVersion=navigator.appVersion.split("MSIE");
var version=parseInt(aVersion[1]);
var pp=png.parentNode;
if( (version>=5.5) && (version<7) && (document.body.filters) )
{
var mout=png.onmouseout.toString();
var mover=png.onmouseover.toString();
alphaHTML="<span style=\"cursor:pointer;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='"+png.src+"');display:block;width:"+png.style.width+";height:"+png.style.height+";\" onmouseover=\""+mover.substring(mover.indexOf("{")+1,mover.lastIndexOf("}"))+"\" onmouseout=\""+mout.substring(mout.indexOf("{")+1,mout.lastIndexOf("}"))+"\" ></span>";
png.outerHTML=alphaHTML;
}
}
这个函数已经写在图片的onload事件里了,会在IMG标签的内容加载完后触发(这个事件虽好,也不能到处乱用,根据伟大的犀牛书V5,onload只支持body, frameset, img),函数先判断浏览器类型和版本(IE7支持透明PNG),先创建一个span元素,IMG标签的所有属性、事件都原样COPY到SPAN上,而PNG图片则放到SPAN的背景里,用滤镜处理成透明,注意滤镜属性里必须要有sizingMethod=scale。最后用outerHTML(只有IE支持)把该IMG替换成span。
导航栏的样式:
/* icon menu */
.iconbarout
{
width:770px;
position:absolute;
top:40px;right:10px;
}
.iconbar{
overflow:hidden;
float:left;
}
.iconbar li{
float:right;
padding:0px;
width:auto;
text-align:center;
margin:0 16px 0 0px;
}
.iconbar li span{
color:#333;
font-weight:600;
width:auto;
display:block;
float:none;
margin:0px auto;
}
.iconbar li a img{
margin:0px auto;
float:none;
}
.iconbar li a{
text-align:center;
float:none;
margin:0px auto;
}
.iconbar li img{
border:0px;
float:left;
}
这样就在IE和Firefox里实现一样的视觉效果了(这里存在一个问题,为了保证图标放大后的清晰度,初始的图标都是缩小的,在IE7和Firefox里都会看到一点锯齿,而IE6由于用了滤镜,缩小的图标边缘仍然是平滑的-_____-b)
接下来做鼠标滑过的放大缩小效果。JS的动画效果一般是利用setTimeout或setInterval的延迟功能,反复循环来实现的。为了避免这些图标在运行函数时发生冲突,我把缩放的动画效果封装到了一个类里:
/* zoom class by Dexter.Yy
********************************************************/
function animeZoom(ico,gWidth,gHeight,nWidth,nHeight)
{
this.png=ico;
this.iheight=nHeight;
this.iWidth=nWidth;
this.goWidth=gWidth;
this.goHeight=gHeight;
this.rico;
}
animeZoom.prototype.zoomEvent=function()
{
if(this.iWidth<this.goWidth)
{
this.goEnlarge();
}
else if(this.iWidth>this.goWidth)
{
this.goReduce();
}
}
animeZoom.prototype.goEnlarge=function()
{
this.png.style.width=this.goWidth+"px";
this.png.style.height=this.goWidth+"px";
}
animeZoom.prototype.goReduce=function()
{
var obj=this;
var h=parseInt(this.png.style.height);
var w=parseInt(this.png.style.width);
if(w>this.goWidth)
{
this.png.style.width=w-2+"px";
this.png.style.height=h-2+"px";
this.rico=setTimeout(function(){obj.goReduce();},30);
}
else
{
window.clearTimeout(this.rico);
}
}
使用时要传5个参数:目标对象、期望达到的宽度、期望达到的高度、原始宽度、原始高度,像这样:
function largeIcon(png)
{
var lIco=new animeZoom(png,91,91,68,68);
lIco.zoomEvent();
}
function reIcon(png)
{
var rIco=new animeZoom(png,68,68,91,91);
rIco.zoomEvent();
}
OK完工……如果是在FLASH里做这种推挤效果,可能还要写一大堆AS,但这里有CSS的浮动属性帮忙,就很省事……
作者: Dexter.Yy 发表于 3/03/2007 04:00:00 上午 3 条评论
标签: CODER
看到一篇强文:Quantum mechanics and Tomb Raider
原文地址,看到wordpress.com这个域名,你可能就知道这个BLOG需要用代理访问了……
原文我也看不明白,然则NTRPG论坛上的Ross老爷就华丽的把它翻译出来了哑!赞!经译者授权,转帖于此:我们要讨论的是,在这样一款游戏中,存在一个“里世界”,即Lara所存在的游戏世界;以及一个 “表世界”,即玩家通过电脑操纵Lara的现实世界。当游戏运行的时候,这两个世界或多或少是相互平行的。但是某种操作,特别是“保存游戏”和“读取游戏”的行为,会破坏表世界和里世界的关系。这种行为对处于表世界的我们来说是再正常不过的事情了。但是,如果我们从Lara的角度,即里世界的角度来看,就会发现事情会变得有趣起来。
看到一篇强文:Quantum mechanics and Tomb Raider
原文地址:http://terrytao.wordpress.com/2007/02/26/quantum-mechanics-and-tomb-raider/
看到wordpress.com这个域名,你可能就知道这个BLOG需要用代理访问了……
原文我也看不明白,然则NTRPG论坛上的Ross老爷就华丽的把它翻译出来了哑!赞!经译者授权,转帖于此:量子力学导致了很多匪夷所思的结论,这里我们只着重讨论其中三点:
一、物体可以同时表现粒子性和波动性;
二、那些描述量子力学的方程式是确定的,但关于这些方程的解的标准解释却是概然的;
三、如果用量子力学法则来解释宏观现象,那就得要求宇宙本身必须分割成为多个互不相同的“世界”的叠加体。
为了通过传统的概念模型来描绘量子力学的非常现象,我们决定使用电脑游戏来帮助我们进行分析。具体选择哪款游戏并不重要,就让我们用古墓丽影—一款十多年以前就开始流行的游戏来进行我们的讨论吧。在这款游戏中,Lara Croft是女主人公,她致力于在各种古墓和地城中探险,经受迷题和陷阱的考验,只为得到她所心仪的宝贝。要知道,在游戏中,Lara死掉是一件稀松平常的事情,很可能一个陷阱就要了她的性命。
我们要讨论的是,在这样一款游戏中,存在一个“里世界”,即Lara所存在的游戏世界;以及一个 “表世界”,即玩家通过电脑操纵Lara的现实世界。当游戏运行的时候,这两个世界或多或少是相互平行的。但是某种操作,特别是“保存游戏”和“读取游戏”的行为,会破坏表世界和里世界的关系。这种行为对处于表世界的我们来说是再正常不过的事情了。但是,如果我们从Lara的角度,即里世界的角度来看,就会发现事情会变得有趣起来。
首先想象一下,Lara碰到了游戏中的某个迷题,此时操作Lara的玩家选择在尝试之前先保存一下游戏。接下来会发生的事情可能是:Lara的第一次尝试失败,死掉了;玩家读取之前的存档,这次Lara成功了。
现在,从Lara的角度来看,情况会有什么不同呢?在游戏的记录点,Lara的世界变成了两种互不干扰的可能分支的重叠,在其中一个分支里,她尝试失败而死掉了;在另一个分支里,她成功地活下来。(就像薛定谔的猫)她的未来变得不确定起来。如果她在记录点以前向先知询问她是否能活下来,先知能给她的唯一的正确回答就是50%可能死掉,50%可能活下来。
这个简单的例子表明,表世界中的结果十分确定,但里世界的结果却可以是不确定的。然而,这个例子无法完全说明量子力学的匪夷所思之处。在这两个分支世界中的Lara都无法了解关于另一个分支世界中的情况,因此Lara只能得到她是活在一个“传统的、结果确定的世界”中这样一个结论。
那么,让我们把这个游戏变得更有趣一些。我们假设,Lara每次死后,都会在死亡地点留下尸体,而且未来的Lara可以碰到这些尸体。那么Lara就会注意到以下现象:无论她何时开始解决游戏中的迷题,她都会碰到一定数量的自己的尸体。我们无法用传统的确定的现实模型来向Lara解释这些奇怪的现象。我们能给她的最简单的解释就是现实由多元世界构成,而包含每各种可能性的世界之间部分关联。另一个可能的解释是:每当Lara通过一个记录点的时候,她的确定的粒子性发散成为各种可能性的波形叠加,然后在她通过迷题的瞬间,描述她的命运的各种可能性的波函数立刻坍缩成为一个确定的结果。
在现实世界中,只有微观物体,例如电子,才会体现出量子性。而宏观物体,比如你和我,则无法体会 Lara在游戏世界中所遭遇的那种现象,我们也无法去采访单个电子,询问它的切身体会。不过,通过对微观物体行为的统计,我们可以经由实验和理论推测间接得出它们的量子性质。让我们再一次用古墓丽影来分析一下这个问题。设想在古墓丽影中并非只有Lara一个主人公,而有很多角色可以使用。他们都像Lara 一样喜欢冒险。我假设,在游戏世界中也有一个科学家——就让我们叫她Jacqueline——专门研究这些冒险者的行为。但是她不会亲自去体验在古墓中探险活动,她甚至也不跟这些冒险者有任何接触。每一座古墓只有一个冒险者进入,无论这个冒险者死掉或是活着完成探索,都不会有其他冒险者再进入这座古墓。
Jacqueline 尝试考察她世界中的一些不同类型的古墓,并且收集了冒险者门在不同类型的古墓中幸存下来的数据。她发现,对于一个给定类型的古墓,都有一个确定的幸存概率 ——比如类型A的古墓所对应的幸存率固定为20%,而类型B则固定为50%——但是却无法确定,一个给定的冒险者在一个给定的古墓中是否能幸存下来。到目前为止,这些现象都可以通过传统理论来解释:每一座墓地中都有若干致命的陷阱,冒险者能否成功通过这些陷阱都由一个随机几率决定。
但是,Jacqueline此刻会遇到神秘的量子现象:不同类型古墓的幸存几率不外乎以下一些数字:
100%、50%、33.3%、25%、20%……
换句话说就是,每一座古墓的幸存几率固定为某个整数的倒数1/n。这种现象在传统理论中难以解释,因为就随机效应来说,幸存率的分布应该是一条连续的曲线。
这就是说,Lara为了能在某种类型的古墓中幸存下来,她需要叠加一定数量的自己的尸体来到达某个临界点。如果她无法跃迁到一定的干涉能级来抵达那个临界点,她就会在冒险中死掉。古墓的类型决定了具体需要多少尸体才能抵达临界点——比如A类型的墓地需要四具尸体。这样控制Lara的玩家就必须让Lara失败四次才能成功通过这个古墓。以Jacqueline的角度来看,Lara的幸存纪律就是20%。在承载着每一个可能性的游戏世界中,只有一个Lara进入了古墓中。但是Lara的幸存几率却是因为多个重叠世界相互干涉而决定的。
这种量子效应的一个类似的例子是,每一种原子只能发射出特定波长的可见光波,比如钠原子的光谱线就是黄色的,而氖原子的光谱线是蓝色的。在这些原子中的电子为了能发射出这样的光波,从某种意义上来说就是爬着它们自己的尸体抵达被激发的临界点。通常的解释是,在原子内部的电子以波的形式存在,并以某个固定的频率震荡。
最后我们再次利用古墓丽影来解释一下为什么微观物体能体现出量子效应而宏观物体却没有。我们假设古墓丽影是一个双人合作游戏,两个玩家分别控制两个人物(这两个人物就叫Lara和 Indiana),她们可以同时探索她们世界的不同部分。玩家可以保存和读取游戏。读取游戏的时候Lara和Indiana都会回到记录点的状态。
此时,游戏依然会有Lara和Indiana遭遇到她们自己尸体的奇怪现象。然而,我们假设,Lara和Indiana通过以下方式纠缠:如果Lara探索墓地A而Indiana探索墓地B,只有Lara和Indiana两人都在上一次记录游戏中分别死在墓地A和墓地B,那么Lara和Indiana才会各自碰到自己在上一次记录游戏中的尸体。如果在上一次记录游戏中,Lara死在墓地A而Indiana死在墓地C,那么她们这次就不会看到任何尸体。因为这种纠缠,量子效应减少了。Lara和Indiana如果同时在这个世界中进行不同的探险活动,将比Lara单独进行探险活动要遇到更少的尸体。如果同时有大量的冒险者分别进行探索,那么量子效应基本上为0。
原文:Quantum mechanics and Tomb Raider
Monday, February 26th, 2007 in non-technical
This post is derived from an interesting conversation I had several years ago with my friend Jason Newquist on trying to find some intuitive analogies for the non-classical nature of quantum mechanics. It occurred to me that this type of informal, rambling discussion might actually be rather suited to the blog medium, so here goes nothing…
Quantum mechanics has a number of weird consequences, but here we are focusing on three (inter-related) ones:
1. Objects can behave both like particles (with definite position and a continuum of states) and waves (with indefinite position and (in confined situations) quantised states);
2. The equations that govern quantum mechanics are deterministic, but the standard interpretation of the solutions of these equations is probabilistic; and
3. If instead one applies the laws of quantum mechanics literally at the macroscopic scale, then the universe itself must split into the superposition of many distinct “worlds”.
In trying to come up with a classical conceptual model in which to capture these non-classical phenomena, we eventually hit upon using the idea of using computer games as an analogy. The exact choice of game is not terribly important, but let us pick Tomb Raider - a popular game from about ten years ago (back when I had the leisure to play these things), in which the heroine, Lara Croft, explores various tombs and dungeons, solving puzzles and dodging traps, in order to achieve some objective. It is quite common for Lara to die in the game, for instance by failing to evade one of the traps. (I should warn that this analogy will be rather violent on certain computer-generated characters.)
The thing about such games is that there is an “internal universe”, in which Lara interacts with other game elements, and occasionally is killed by them, and an “external universe”, where the computer or console running the game, together with the human who is playing the game, resides. While the game is running, these two universes run more or less in parallel; but there are certain operations, notably the “save game” and “restore game” features, which disrupt this relationship. These operations are utterly mundane to people like us who reside in the external universe, but it is an interesting thought experiment (which others have also proposed :-) ) to view them from the perspective of someone like Lara, in the internal universe. (I will eventually try to connect this with quantum mechanics, but please be patient for now.) Of course, for this we will need to presume that the Tomb Raider game is so advanced that Lara has levels of self-awareness and artificial intelligence which are comparable to our own.
Imagine first that Lara is about to navigate a tricky rolling boulder puzzle, when she hears a distant rumbling sound - the sound of her player saving her game to disk. From the perspective of the player, what happens next is the following: Lara navigates the boulder puzzle but fails, being killed in the process; then the player restores the game from the save point and then Lara successfully makes it through the boulder puzzle.
Now, how does the situation look from Lara’s point of view? At the save point, Lara’s reality diverges into a superposition of two non-interacting paths, one in which she dies in the boulder puzzle, and one in which she lives. (Yes, just like that cat.) Her future becomes indeterministic. If she had consulted with an infinitely prescient oracle before reaching the save point as to whether she would survive the boulder puzzle, the only truthful answer this oracle could give is “50% yes, and 50% no”.
This simple example shows that the internal game universe can become indeterministic, even though the external one might be utterly deterministic. However, this example does not fully capture the weirdness of quantum mechanics, because in each one of the two alternate states Lara could find herself in (surviving the puzzle or being killed by it), she does not experience any effects from the other state at all, and could reasonably assume that she lives in a classical, deterministic universe.
So, let’s make the game a bit more interesting. Let us assume that every time Lara dies, she leaves behind a corpse in that location for future incarnations of Lara to encounter. (This type of feature was actually present in another game I used to play, back in the day.) Then Lara will start noticing the following phenomenon (assuming she survives at all): whenever she navigates any particularly tricky puzzle, she usually encounters a number of corpses which look uncannily like herself. This disturbing phenomenon is difficult to explain to Lara using a purely classical deterministic model of reality; the simplest (and truest) explanation that one can give her is a “many-worlds” interpretation of reality, and that the various possible states of Lara’s existence have some partial interaction with each other. Another valid (and largely equivalent) explanation would be that every time Lara passes a save point to navigate some tricky puzzle, Lara’s “particle-like” existence splits into a “wave-like” superposition of Lara-states, which then evolves in a complicated way until the puzzle is resolved one way or the other, at which point Lara’s wave function “collapses” in a non-deterministic fashion back to a particle-like state (which is either entirely alive or entirely dead).
Now, in the real world, it is only microscopic objects such as electrons which seem to exhibit this quantum behaviour; macroscopic objects, such as you and I, do not directly experience the kind of phenomena that Lara does and we cannot interview individual electrons to find out their stories either. Nevertheless, by studying the statistical behaviour of large numbers of microscopic objects we can indirectly infer their quantum nature via experiment and theoretical reasoning. Let us again use the Tomb Raider analogy to illustrate this. Suppose now that Tomb Raider does not only have Lara as the main heroine, but in fact has a large number of playable characters, who explore a large number deadly tombs, often with fatal effect (and thus leading to multiple game restores). Let us suppose that inside this game universe there is also a scientist (let’s call her Jacqueline) who studies the behaviour of these adventurers going through the tombs, but does not experience the tombs directly, nor does she actually communicate with any of these adventurers. Each tomb is explored by only one adventurer; regardless of whether she lives or dies, the tomb is considered “used up”.
Jacqueline observes several types of trapped tombs in her world, and gathers data as to how likely an adventurer is to survive any given type of tomb. She learns that each type of tomb has a fixed survival rate - e.g. a tomb of type A has a 20% survival rate, while a tomb of type B has a 50% survival rate - but that it seems impossible to predict with any certainty whether any given adventurer will survive any given type of tomb. So far, this is something which could be explained classically; each tomb may have a certain number of lethal traps in them, and whether an adventurer survives these traps or not may entirely be due to random chance.
But then Jacqueline encounters a mysterious “quantisation” phenomenon: the survival rate for various tombs are always one of the following numbers:
100\%, 50\%, 33.3\ldots\%, 25\%, 20\%, \ldots;
in other words, the “frequency” of success for a tomb is always of the form 1/n for some integer n. This phenomenon would be difficult to explain in a classical universe, since the effects of random chance should be able to produce a continuum of survival probabilities.
Here’s what is going on. In order for Lara (say) to survive a tomb of a given type, she needs to stack together a certain number of corpses together to reach a certain switch; if she cannot attain that level of “constructive interference” to reach that switch, she dies. The type of tomb determines exactly how many corpses are needed - suppose for instance that a tomb of type A requires four corpses to be stacked together. Then the player who is playing Lara will have to let her die four times before she can successfully get through the tomb; and so from her perspective, Lara’s chances of survival are only 20%. In each possible state of the game universe, there is only one Lara which goes into the tomb, who either lives or dies; but her survival rate here is what it is because of her interaction with other states of Lara (which Jacqueline cannot see directly, as she does not actually enter the tomb).
A familiar example of this type of quantum effect is the fact that each atom (e.g. sodium or neon) can only emit certain wavelengths of light (which end up being quantised somewhat analogously to the survival probabilities above); for instance, sodium only emits yellow light, neon emits blue, and so forth. The electrons in such atoms, in order to emit such light, are in some sense clambering over skeletons of themselves to do so; the more commonly given explanation is that the electron is behaving like a wave within the confines of an atom, and thus can only oscillate at certain frequencies (similarly to how a plucked string of a musical instrument can only exhibit a certain set of wavelengths, which incidentally are also proportional to 1/n for integer n). Mathematically, this “quantisation” of frequency can be computed using the bound states of a Schrödinger operator with potential. (Now, I am not going to try to stretch the Tomb Raider analogy so far as to try to model the Schrödinger equation! In particular, the complex phase of the wave function - which is a fundamental feature of quantum mechanics - is not easy at all to motivate in a classical setting, despite some brave attempts.)
The last thing we’ll try to get the Tomb Raider analogy to explain is why microscopic objects (such as electrons) experience quantum effects, but macroscopic ones (or even mesoscopic ones, such as large molecues) seemingly do not. Let’s assume that Tomb Raider is now a two-player co-operative game, with two players playing two characters (let’s call them Lara and Indiana) as they simultaneously explore different parts of their world (e.g. via a split-screen display). The players can choose to save the entire game, and then restore back to that point; this resets both Lara and Indiana back to the state they were in at that save point.
Now, this game still has the strange feature of corpses of Lara and Indiana from previous games appearing in later ones. However, we assume that Lara and Indiana are entangled in the following way: if Lara is in tomb A and Indiana is in tomb B, then Lara and Indiana can each encounter corpses of their respective former selves, but only if both Lara and Indiana died in tombs A and B respectively in a single previous game. If in a previous game, Lara died in tomb A and Indiana died in tomb C, then this time round, Lara will not see any corpse (and of course, neither will Indiana). (This entanglement can be described a bit better by using tensor products: rather than saying that Lara died in A and Indiana died in B, one should instead think of \hbox{Lara } \otimes \hbox{ Indiana} dying in \left|A\right> \otimes \left|B\right>, which is a state which is orthogonal to \left|A\right> \otimes \left|C\right>.) With this type of entanglement, one can see that there is going to be significantly less “quantum weirdness” going on; Lara and Indiana, adventuring separately but simultaneously, are going to encounter far fewer corpses of themselves than Lara adventuring alone would. And if there were many many adventurers entangled together exploring simultaneously, the quantum effects drop to virtually nothing, and things now look classical unless the adventurers are somehow organised to “resonate” in a special way.
One might be able to use Tomb Raider to try to understand other unintuitive aspects of quantum mechanics, but I think I’ve already pushed the analogy far beyond the realm of reasonableness, and so I’ll stop here. :-)
作者: Dexter.Yy 发表于 3/03/2007 03:46:00 上午 0 条评论
标签: GEEK