Collatz 予想を BulletML で (ちゅーとはんぱ)

BulletML は実はすごいんだよ。

http://ll.jus.or.jp/2006/blog/doukaku2

の g(n) を求めるプログラムを BulletML で書きました。飛んでくる弾数が g(n) の値になっています。ランクがちょうど 0-100 まで選べますから、適当にランクで引数を調整して下さい。100までの中で最大を探すのはヒジョーに面倒そうなので諦めます…

要は条件分岐が肝。 dead_or_alive っていう action がそれで、ありえん速度に達してから引数時間だけ wait 。よって引数 $1 > 0 なら画面の外に出るのでその弾は消えて、そうでないなら次のアクションができる、ということで条件分岐が実現できます。

まぁ剰余無いので偶奇の判定とかがめんどうだったです。

<?xml version="1.0" ?>
<!DOCTYPE bulletml SYSTEM "../bulletml.dtd">
<bulletml>

<action label="dead_or_alive">
 <changeSpeed>
  <speed>10000</speed>
  <term>1</term>
 </changeSpeed>
 <wait>$1</wait>
</action>

<fire label="g2next">
 <bullet> <action>
  <actionRef label="dead_or_alive">
   <param>150-$2*100</param>
  </actionRef>

  <fireRef label="g2">
   <param>$1</param>
   <param>$2-2</param>
  </fireRef>

  <vanish/>
 </action> </bullet>
</fire>

<fire label="g4even">
 <bullet> <action>
  <actionRef label="dead_or_alive">
   <param>$2*100-50</param>
  </actionRef>

  <actionRef label="g">
   <param>$1/2</param>
  </actionRef>

  <vanish/>
 </action> </bullet>
</fire>

<fire label="g4odd">
 <bullet> <action>
  <actionRef label="dead_or_alive">
   <param>50-$2*100</param>
  </actionRef>

  <actionRef label="g">
   <param>$1*3+1</param>
  </actionRef>

  <vanish/>
 </action> </bullet>
</fire>

<fire label="g3">
 <bullet> <action>
  <actionRef label="dead_or_alive">
   <param>$2*100-150</param>
  </actionRef>

  <fireRef label="g4even">
   <param>$1</param>
   <param>$2</param>
  </fireRef>

  <fireRef label="g4odd">
   <param>$1</param>
   <param>$2</param>
  </fireRef>

  <vanish/>
 </action> </bullet>
</fire>

<fire label="g2">
 <bullet> <action>
  <fireRef label="g2next">
   <param>$1</param>
   <param>$2</param>
  </fireRef>

  <fireRef label="g3">
   <param>$1</param>
   <param>$2</param>
  </fireRef>

  <vanish/>
 </action> </bullet>
</fire>

<fire label="g1">
 <speed>0</speed>
 <bullet> <action>
  <wait>10</wait>

  <actionRef label="dead_or_alive">
   <param>150-100*$1</param>
  </actionRef>

  <fire>
   <direction type="aim">0</direction>
   <speed>1</speed>
   <bullet/>
  </fire>

  <fireRef label="g2">
   <param>$1</param>
   <param>$1-2</param>
  </fireRef>

  <vanish/>
 </action> </bullet>
</fire>

<action label="g">
 <fireRef label="g1">
  <param>$1</param>
 </fireRef>
</action>

<action label="top">
 <actionRef label="g">
  <param>$rank*100</param>
 </actionRef>
 <wait>10000</wait>
</action>

</bulletml>
なにかあれば下記メールアドレスへ。
shinichiro.hamaji _at_ gmail.com
shinichiro.h