'プチコンmkII' 上で動作するマインスイーパの QR コード公開、新しい iPad 購入。

プチコンmkII’ 上で動作するマインスイーパの QR コードを下記 URL で公開します。

Yoshiaki's HomePage - プチコンmkII
プチコンmkII版マインスイーパ Version 1.0.0
http://kyoshiaki.sakura.ne.jp/osx/petitcom.html

良かったら、遊んでみてください。

Twitterハッシュタグ #ptcmqr でいろいろな ‘プチコンmkII’ の QR コードが公開されていますが、

SHOHD
QRコード32枚
投稿プログラム : ホラーダンジョン - プチコンまとめWiki
http://wiki.hosiken.jp/petc/?Toukou%2F%A5%DB%A5%E9%A1%BC%A5%C0%A5%F3%A5%B8%A5%E7%A5%F3
GN_TRK03
StarTrek for Petitcom
http://www2.u-netsurf.ne.jp/~ozawa/startrek/startrek.html
コマンドの詳しい解説は
Star Trek
http://www.dunnington.u-net.com/public/startrek/
で紹介されているリンク先ファイル TREK.DOC [ http://www.dunnington.u-net.com/public/startrek/TREK.DOC ] が参考になります。
KYMTREK
スタートレック
http://www1.odn.ne.jp/beni/petitcom/trek/list.html
SPEHURRI
SPECTACLE HURRICANE
『プチコン』のページ
http://www1.ocn.ne.jp/~tabby/games/ds_kkoj.html
http://www1.ocn.ne.jp/~tabby/games/ds_knaj.html
RE201
Reflect EDGE Ver2.01
http://www.geocities.jp/sp1_ssr/ReflectEDGE1.htm
TINYKITT
プチコンmkII用「ナンジグライダー」
プチコン関連
http://www.geocities.jp/tiny_yarou/petitcom/index.html
(Safari で見る場合は、メニュー/表示/テキストエンコーディング:日本語 (EUC) を選択してください。)
DROPPZL
ありそうで無かった「逆テ○リス?」
http://www.ma.mctv.ne.jp/~miche/ptc/hare/index.html
GRPSHP2P
お絵描きツール
mkII - 湯飲実験室 (QRコードと操作説明)
http://www.sotohane.com/2012/03/mkii.html#more
QRコード
http://twitpic.com/8y4hgw
G2MMLEX
G2MMLSMP
プチコンmkIIのMMLをマクロ対応にするプログラム
http://www.gradius2.com/index.php?UID=1332082863
OCHAOSP
自動歌唱ソフト OSP
OCHAOSP2
棒歌ロイド OSP2
http://ww5.tiki.ne.jp/~ochame/petitcom/1page.htm#osp
MRPLAY
MML音色試聴ツール
http://twitpic.com/8zrzq2
S51PTCL3
投稿プログラム : PetitcoLOID - プチコンまとめWiki
http://wiki.hosiken.jp/petc/?Toukou%2FPetitcoLOID

がお勧めです。後、プログラムの中断は ‘SELECT ボタン’ を押してください。

Apple が 2012年3月7日(水)AM10時 (PST) [日本時間 2012年3月8日(木)AM3時] より、米カリフォルニア州サンフランシスコの Yerba Buena Center for the Arts(YBCA)でスペシャルイベントを開催しました。新しい iPadiOS 5.1が発表されました。早速、iOS 5.1にアップデートしました。iPhone 4S を持っていないので Siri を試せないのが、残念です。

初代 iPad は、購入しました。しかし iPad 2 は Retina Display に対応していなかったので、見送りました。新しい iPad は、発表があってからすぐに ‘ホワイト WiFiモデル 32GB’ を予約しました。16日に到着しました。拙作 iYKRSSHD [ http://itunes.com/apps/iYKRSSHD ] になるべく早く対応したいです。iCloud を勉強中なので、アプリに活かしてみたいですね!

Mac OS X、Ubuntu、Cygwin、MinGW のターミナル上で動作するプチコン準拠 BASIC インタプリタ basic を公開。

Mac OS XUbuntuCygwinMinGW のターミナル上で動作する BASIC インタプリタ basic を下記 URL で公開します。

basic version 1.0.0
http://kyoshiaki.sakura.ne.jp/osx/index.html

BASIC の文法は、

プチコン
http://smileboom.com/special/petitcom/

に準拠します。ただし、スプライト、BGスクリーン、256色グラフィック、ファイルと通信、音楽などに関するステートメントと関数は、対応していません。

あくまでも、実験的に作成したものです。メモリの解放なども省いています。flex、bison、C 言語で作成され、ソースも含まれています。

実用性に乏しいですが、良かったらダウンロードしてください。

BASIC インタプリタだけだと寂しいので、Land of Lisp から

Land of LISP: Learn to Program in Lisp, One Game at a Time!

Land of LISP: Learn to Program in Lisp, One Game at a Time!

orc-battle.lisp
robots.lisp
evolution.lisp

を移植してみました。evolution.lisp の移植には、かなり苦労しました。自分で言うのも、おこがましいのですが、力作です。
後、BASIC で再帰処理とローカル変数を実現するのには無理があるので、dice_of_doom_v1.lisp はあきらめました。

Boot Camp 上に Windows 7 はインストールしてありますが、Windows プログラミングについて、ほとんど知識がありません。

Cygwin
http://www.cygwin.com/
MinGW | Minimalist GNU for Windows
http://www.mingw.org/

CygwinMinGW で何とかビルドができるように対応してみました。ただし、MinGW については、日本語表示(半角カタカナ)とエスケープシーケンスに問題があります。Cygwin がお勧めです。本当は、CygwinMinGW のインストールも説明すべきなのですが、よくわからないので省きました。ごめんなさい。

robots.bas.txt、evolution.bas.txt を実行した動画を添付しておきます。

robots.bas.txt

evolution.bas.txt

Apple Education Event、Land of Lisp

随分遅くなりましたが、本年も宜しくお願いします。

Apple Education Event, January 2012
http://events.apple.com.edgesuite.net/1201oihbafvpihboijhpihbasdouhbasv/event/index.html
Apple Keynotes - iTunes Podcast
http://itunes.apple.com/jp/podcast/apple-keynotes/id275834665

1月19日、Apple はニューヨークで開催したメディアイベントで、「iBook 2」、電子書籍作成アプリ「Books Author」、iOS向けに「iTunes U」のアプリを発表しました。

早速、iBooks Author をダウンロードし、試してみました。ウィジェットを追加できる仕組みは、可能性を感じますね。OS 純正の Calculator.wdgt を追加して遊んでみました。ウィジェクト作成ソフト Dashcode も随分進歩しています。すっかり、使い方を忘れてしまったので、

ヘルプ/Dashcode User Guide
▼ デュアルプロダクトWebアプリケーションチュートリアル
▼ プロジェクトを開始する
▼ ウィジェットまたはWebアプリケーションのユーザインターフェイスをデザインする
▼ テストする/共有する
Webアプリケーションを動作形式で保存する

を拾い読みし、基本操作を学びました。

Dashcode で Dashboard のテンプレートから、カスタムを選びます。プロジェクトウインドウ左側 (ナビゲータ) の ‘実行と共有’ をクリックします。ウインドウ右下に ‘ディスクに保存…’ ボタンが現れるのでクリックすると、拡張子が wdgt 形式のファイルで保存されます。iBooks Author では、中央の ‘ウィジェット‘ ボタンから ‘HTML’ を選択します。現れたエリアにウィジェットをドラッグ・ドロップすれば追加できます。プレビューするには、iPad が必要になります。拙作 YKMinesweeper.wdgt を作り直してみたいですね!

Land of LISP: Learn to Program in Lisp, One Game at a Time!

Land of LISP: Learn to Program in Lisp, One Game at a Time!

以前にも書いたように、Land of Lisp [ asin:1593272812 ] を読書中です。サンプル orc-battle.lispsbcl で実行してみました。sbcl については Homebrew

brew update
brew install sbcl

を利用してインストールしました。

sbcl を起動し、 load 関数で orc-battle.lisp を読み込み、(orc-battle) で実行しました。

~ $ sbcl
This is SBCL 1.0.53, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (load "~/lisp/Land of Lisp/orc-battle.lisp")
T
* (orc-battle)
You are a valiant knight with a health of 30, an agility of 30, and a strength of 30
Your foes:
1. (Health=3) A fierce BRIGAND
2. (Health=6) A malicious hydra with 6 heads.
3. (Health=2) A fierce BRIGAND
4. (Health=6) A slime mold with a sliminess of 4
5. (Health=6) A wicked orc with a level 6 club
6. (Health=7) A fierce BRIGAND
7. (Health=1) A wicked orc with a level 8 club
8. (Health=8) A fierce BRIGAND
9. (Health=10) A malicious hydra with 10 heads.
10. (Health=4) A slime mold with a sliminess of 5
11. (Health=7) A malicious hydra with 7 heads.
12. (Health=4) A fierce BRIGAND

キーの入力状態になるのですが、入力状態の前に出力した文字列が表示されません。sbcl の場合 (read) を呼ぶ前に (force-output) を呼ぶ必要があります。

orc-battle.lisp の場合

(defun player-attack ()
(fresh-line)
(princ "Attack style: [s]tab [d]ouble swing [r]oundhouse:")
(force-output)
(case (read)
(s (monster-hit (pick-monster)
(+ 2 (randval (ash *player-strength* -1)))))
(defun pick-monster ()
(fresh-line)
(princ "Monster #:")
(force-output)
(let ((x (read)))

上記のように (read) の前に、(force-output) を2箇所、追加しました。これで正しく動作しました。

* (orc-battle)
You are a valiant knight with a health of 30, an agility of 30, and a strength of 30
Your foes:
1. (Health=3) A fierce BRIGAND
2. (Health=6) A malicious hydra with 6 heads.
3. (Health=2) A fierce BRIGAND
4. (Health=6) A slime mold with a sliminess of 4
5. (Health=6) A wicked orc with a level 6 club
6. (Health=7) A fierce BRIGAND
7. (Health=1) A wicked orc with a level 8 club
8. (Health=8) A fierce BRIGAND
9. (Health=10) A malicious hydra with 10 heads.
10. (Health=4) A slime mold with a sliminess of 5
11. (Health=7) A malicious hydra with 7 heads.
12. (Health=4) A fierce BRIGAND
Attack style: [s]tab [d]ouble swing [r]oundhouse:

終了するには、(sb-ext:quit) を実行します。

 You have been killed. Game Over.
NIL
* (sb-ext:quit)
~ $ 

sbcl ではなく clisp も試したくなったのですが、Homebrew でインストールするとビルドに失敗します。llvm-gcc ではなく gcc が必要なようです。
自分で gcc をビルドするのは大変なので

kennethreitz/osx-gcc-installer - GitHub
https://github.com/kennethreitz/osx-gcc-installer

の osx-gcc-installer を利用しました。Xcode をインストールした状態で osx-gcc-installer をインストールしたので、問題があるかもしれません。

Homebrew で gcc を使ってビルドするには、環境変数 CC を設定するのではなく

brew install clisp --use-gcc

オプション –use-gcc を使うと良いようです。

clisp を使って orc-battle.lisp を実行するには、sbcl のような (force-output) を追加する必要はありません。

~ $ clisp
i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
I I I I I I I      8     8   8           8     8     o  8    8
I  \ `+' /  I      8         8           8     8        8    8
\  `-+-'  /       8         8           8      ooooo   8oooo
`-__|__-'        8         8           8           8  8
|            8     o   8           8     o     8  8
------+------       ooooo    8oooooo  ooo8ooo   ooooo   8
Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>
Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2010
Type :h and hit Enter for context help.
[1]> (load "~/lisp/Land of Lisp/orc-battle.lisp")
;; Loading file /Users/yoshiaki/lisp/Land of Lisp/orc-battle.lisp ...
;; Loaded file /Users/yoshiaki/lisp/Land of Lisp/orc-battle.lisp
T
[2]> (orc-battle)
You are a valiant knight with a health of 30, an agility of 30, and a strength of 30
Your foes:
1. (Health=8) A wicked orc with a level 1 club
2. (Health=9) A malicious hydra with 9 heads.
3. (Health=1) A fierce BRIGAND
4. (Health=9) A slime mold with a sliminess of 3
5. (Health=9) A malicious hydra with 9 heads.
6. (Health=8) A wicked orc with a level 1 club
7. (Health=2) A slime mold with a sliminess of 5
8. (Health=7) A malicious hydra with 7 heads.
9. (Health=5) A fierce BRIGAND
10. (Health=2) A slime mold with a sliminess of 4
11. (Health=5) A malicious hydra with 5 heads.
12. (Health=5) A slime mold with a sliminess of 5
Attack style: [s]tab [d]ouble swing [r]oundhouse:
NIL
[3]> (exit)
Bye.
~ $ 

clisp を終了するに、(exit) を使ってください。

orc-battle.lisp は、簡単なプログラムです。それで、ゲームに勝つのもそんなに難しくないと思っていました。ところが、なかなか勝つことができません。それで、ソースを熟読して攻撃パターンや、ヘルスポイントの計算方法を理解し、ようやく勝てるようになりました。単純なゲームですが、熱中してしまいました。絶妙なバランスです。ソースの熟読には、別の理由もあったのですが!

orc-battle.lisp で勝利した動画を添付しておきます。後、おまけとして、最近取り組んでいたプログラムの動作模様も公開します。( 04 分 01 秒から始まります。)

現在、Kindle 版 Land of Lisp

IV. Lisp is Science
15. Dice of Doom, a Game Written in the Function Style
Implementing Dice of Doom, Version 1
P312
Location 7551
Calculating Passing Moves

まで読んだのですが、Common Lisp を理解するには、最良の本ですね!Practical Common Lisp も持っているのですが、Land of Lisp の方が基本的な知識を得ることができます。Practical Common Lisp では、途中で投げ出してしまったので、気付かなかったのですが、Common Lisp では、構造体も使えるのですね!

P163
Location 4314
Common Lisp Structures
> (defstruct person
name
age
waist-size
favorite-color)
PERSON
> (defparameter *bob* (make-person :name "Bob"
:age 35
:waist-size 32
:favorite-color "blue"))
> *bob*
#S(PERSON :NAME "Bob" :AGE 35 :WAIST-SIZE 32 :FAVORITE-COLOR "blue")
> (person-age *bob* )
35
> (setf (person-age *bob* ) 36)
> (person-age *bob* )
36