ab.com コミュニティ

ActiveBasicを通したコミュニケーション
現在時刻 - 2024年3月28日(木) 22:44

全ての表示時間は UTC+09:00 です




新しいトピックを投稿する  トピックへ返信する  [ 4 件の記事 ] 
作成者 メッセージ
 記事の件名: 頭の体操ゲームです
投稿記事Posted: 2007年10月10日(水) 00:03 
全然実践でもなんでもない、ちょっとしたゲームです。
高校でActiveBasicをはじめてまだ間もないので目も当てられんようなものなんですが
苦心して初心者なりの試行錯誤の末、簡単なものですが一応完成しました。
(アドバイス、補足修正等してくださる方いらっしゃったらぜひお願いします!)
元が結構有名なものなんですが、それをただActiveBasicで作ってみたいなと
思い立ったというだけのものなので、ゲームとしては楽しめると思います。
ただなにぶんコードにもある発案者に許可をとっていないので個人的に楽しむ範囲なんですが笑
雰囲気を出すために英語仕様にしてあるのでここに一応イントロなどのところの和文も載せておきます。

○Petals Around the Rose(バラの周りの花びら)○
これは実際、ゲームというより、むしろパズルや頭の体操の部類のものである。
挑戦してみる用意はあるだろうか?
<<導入>>
このゲームの名前は「Petals Around the Rose(バラの周りの花びら)」。
名前はこのゲームにおいて重要な要素である。
まずはじめに、プログラムは5つの采を投げる。
そして、プレイヤーはその5つの采を見て、それの示すスコアを推測する。
スコアは常に0点か、偶数となる。
プレイヤーは振られた5つの采からプログラムがどのようにスコアを算出しているかを解き明かさなければならない。
そしてその真相をつかんだプレイヤーだけが、Potentate of the Rose(バラの支配者)となれる。
エンターキーを押して采を振り、采の目の示すスコアを推測して入力すると、その推測の正誤、またプログラムの算出した正しいスコアが確認できる。
そしてまたエンターキーを押せばもう一度采が振られるし、またはただウィンドウを閉じてゲームをやめてもいい。

*ゲームを楽しむ前に*
このゲームの真相を暴くことに成功した人はPotentate of the Roseとなり
the Fraternity of Petals Around the Rose(Petals Around the Rose同好会)のメンバーとなることができる。
(http://www.borrett.id.au/computing/petals-frat.htm)
しかし、もしこの真相がわかってもそれをほかの人にばらしてしまうことは決して許されない。
心を鬼にして秘密を漏らさないと誓うことが要求される。
つまり自分の力でこの真相を解き明かすことのできる者たちだけが、このゲームの秘密を共有することができるのである。
プレイヤーたちの幸運を祈る。
コード:
#console

'---------------------------------------------
' Petals Around the Rose Ver0.01
'                           powered by AONIRO
' 2007 Lloyd Borrett. All rights reserved.
'                           www.borrett.id.au
'---------------------------------------------

Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long
Dim s As Long
Dim t As Long
Dim u As Long
Dim v As Long
Dim w As Long
Dim x As Long
Dim y As String

Print "●○●Petals Around the Rose●○●"
Print "Is Petals Around the Rose really a game? Well actually it's more of a puzzle or a brain teaser. Are you up to the challenge?"
Print "<<Introduction>>"
Print "The name of the game is Petals Around the Rose."
Print "The name of the game is important."
Print "The program will roll five dice and ask you to guess the score for the roll."
Print "The score will always be zero or an even number."
Print "Your mission is to work out how the program calculates the score and become a Potentate of the Rose."
Print "Push the enter key to start the game and enter your guess to check the result."
Print "Then either push the enter key for another turn, or simply close this window to stop playing."
Print ""
Print "*Please read the following before playing*"
Print "If you succeed in working out the secret to the challenge, you become a Potentate of the Rose and qualify to become a member of the Fraternity of Petals Around the Rose.(http://www.borrett.id.au/computing/petals-frat.htm)"
Print "However, you must pledge to be a cruel and heartless wretch who will never divulge the secret of the game to anyone else."
Print "Only those that can work it out for themselves should know the secret of Petals Around the Rose."
Print "Good luck!"
Print ""

Do

Input "[Roll Dice] :Please push the enter key.",s
If s = "" then
	Print "";
Else
	Print "";
EndIf

Randomize
'a,b,c,d,eはそれぞれ采の名前
'Rndは采の目に対応する6つの数字(0~5)を扱う
'それぞれ0は1の目、0は2の目、・・・5は采の目の6を表す
a = Fix(Rnd() * 6)
b = Fix(Rnd() * 6)
c = Fix(Rnd() * 6)
d = Fix(Rnd() * 6)
e = Fix(Rnd() * 6)

'一行目
Print "| ̄ ̄ ̄ ̄ ̄|| ̄ ̄ ̄ ̄ ̄|| ̄ ̄ ̄ ̄ ̄|| ̄ ̄ ̄ ̄ ̄|| ̄ ̄ ̄ ̄ ̄|"

'二行目 采a
If a = 0 then
	Print "|     |";
Elseif a => 1 and a =< 2  then
	Print "| ●   |";
Elseif a => 3 and a =< 5 then
	Print "| ● ● |";
	Endif
'二行目 采b
If b = 0 then
	Print "|     |";
Elseif b => 1 and b =< 2 then
	Print "| ●   |";
Elseif b => 3 and b =< 5 then
	Print "| ● ● |";
	Endif
'二行目 采c
If c = 0 then
	Print "|     |";
Elseif c => 1 and c =< 2 then
	Print "| ●   |";
Elseif c => 3 and c =< 5 then
	Print "| ● ● |";
	Endif
'二行目 采d
If d = 0 then
	Print "|     |";
Elseif d => 1 and d =< 2 then
	Print "| ●   |";
Elseif d => 3 and d =< 5 then
	Print "| ● ● |"; 
	Endif
'二行目 采e
If e = 0 then
	Print "|     |"
Elseif e => 1 and e =< 2 then
	Print "| ●   |"
Elseif e => 3 and e =< 5 then
	Print "| ● ● |"
	Endif

'三行目 采a
If a = 0 or a = 2 or a = 4 then
	Print "|  ●  |";
Elseif a = 1 or a = 3 then
	Print "|     |";
Elseif a = 5 then
	Print "| ● ● |";
	Endif
'三行目 采b
If b = 0 or b = 2 or b = 4 then
	Print "|  ●  |";
Elseif b = 1 or b = 3 then
	Print "|     |";
Elseif b = 5 then
	Print "| ● ● |";
	Endif
'三行目 采c
If c = 0 or c = 2 or c = 4 then
	Print "|  ●  |";
Elseif c = 1 or c = 3 then
	Print "|     |";
Elseif c = 5 then
	Print "| ● ● |";
	Endif
'三行目 采d
If d = 0 or d = 2 or d = 4 then
	Print "|  ●  |";
Elseif d = 1 or d = 3 then
	Print "|     |";
Elseif d = 5 then
	Print "| ● ● |";
	Endif
'三行目 采e
If e = 0 or e = 2 or e = 4 then
	Print "|  ●  |"
Elseif e = 1 or e = 3 then
	Print "|     |"
Elseif e = 5 then
	Print "| ● ● |"
	Endif

'四行目 采a
If a = 0 then
	Print "|     |";
Elseif a => 1 and a =< 2 then
	Print "|   ● |";
Elseif a => 3 and a =< 5 then
	Print "| ● ● |";
	Endif
'四行目 采b
If b = 0 then
	Print "|     |";
Elseif b => 1 and b =< 2 then
	Print "|   ● |";
Elseif b => 3 and b =< 5 then
	Print "| ● ● |";
	Endif
'四行目 采c
If c = 0 then
	Print "|     |";
Elseif c => 1 and c =< 2 then
	Print "|   ● |";
Elseif c => 3 and c =< 5 then
	Print "| ● ● |";
	Endif
'四行目 采d
If d = 0 then
	Print "|     |";
Elseif d => 1 and d =< 2 then
	Print "|   ● |";
Elseif d => 3 and d =< 5 then
	Print "| ● ● |";
	Endif
'四行目 采e
If e = 0 then
	Print "|     |"
Elseif e => 1 and e =< 2 then
	Print "|   ● |"
Elseif e => 3 and e =< 5 then
	Print "| ● ● |"
	Endif

'五行目
Print "|_____||_____||_____||_____||_____|"


If a+1 = 3 then
	u=u+2
Elseif a+1 = 5 then
	u=u+4
Endif

If b+1 = 3 then
	u=u+2
Elseif b+1 = 5 then
	u=u+4
Endif


If c+1 = 3 then
	u=u+2
Elseif c+1 = 5 then
	u=u+4
Endif

If d+1 = 3 then
	u=u+2
Elseif d+1 = 5 then
	u=u+4
Endif

If e+1 = 3 then
	u=u+2
Elseif e+1 = 5 then
	u=u+4
Endif

Input "[Your Guess]:",t
If t = u then
	Print "=YES= ";
	w=w+1
	v=v+1
	x=x+1
	Print "[Total]:";w;" ";
	Print "[Correct]:";v;" ";
	Print "[Run]:";x
Else
	Print "=NO= The score is";u;". ";
	w=w+1
	x=0
	Print "[Total]:";w;" ";
	Print "[Correct]:";v;" ";
	Print "[Run]:";x
Endif

If x = 6 then
	Print "Correct again! We think you've probably got it."
Elseif x = 10 then
	Print "Congratulations! We have another Potentate of the Rose."
Print "If you want to stop playing, please enter the key [n]."
Input "To continue playing, please push the enter key.",y
If y = "n" then
	Print "See you! (´・ω・`)";
	Sleep(750)
	Print "ノ";
	Sleep(500)
	Print "シ";
	Print " ";
	Exit Do
Endif
Endif

Print ""
u=0
Loop Until t=100

Sleep(1500)
End
[/code]


通報する
ページトップ
   
 記事の件名:
投稿記事Posted: 2007年10月10日(水) 00:54 
オフライン

登録日時: 2005年7月25日(月) 13:27
記事: 893
お住まい: 埼玉県東松山市
とりあえず、読みやすいソースコードがあるとどうしてもそっちを読んでしまうので、してみました。

今更無意味です。4.20以上でコンパイルできるはずです。(当方4.23)

_________________
Website→http://web1.nazca.co.jp/himajinn13sei/top.html
ここ以外の場所では「暇人13世」というHNを主として使用。

に署名を書き換えて欲しいと言われたので暇だしやってみるテスト。


通報する
ページトップ
投稿記事Posted: 2007年10月11日(木) 19:05 
あんなに長くてウンザリな感じだったコードがこんなに短くなるなんてプログラミングってすごいですね。
まだ見てもぜんぜん何がどうなってるのか私にはわかりませんが、すごく面白そうです。
暇ができたらこれぐらい書けるようになってみたいです。とても興味が沸きました。
ありがとうございました!


通報する
ページトップ
   
 記事の件名:
投稿記事Posted: 2007年10月11日(木) 21:42 
オフライン

登録日時: 2005年7月25日(月) 13:27
記事: 893
お住まい: 埼玉県東松山市
どういたしまして。

コードを短くする努力(単調な処理をまとめる程度の努力)は、したほうがいいとは思いますが、
読みにくいコードを書く努力はしなくてもいいと思います。

#コンパイラの限界を知っておくことは有意義だと思いますが。

_________________
Website→http://web1.nazca.co.jp/himajinn13sei/top.html
ここ以外の場所では「暇人13世」というHNを主として使用。

に署名を書き換えて欲しいと言われたので暇だしやってみるテスト。


通報する
ページトップ
期間内表示:  ソート  
新しいトピックを投稿する  トピックへ返信する  [ 4 件の記事 ] 

全ての表示時間は UTC+09:00 です


オンラインデータ

このフォーラムを閲覧中のユーザー: なし & ゲスト[5人]


トピック投稿:  可
返信投稿:  可
記事編集: 不可
記事削除: 不可
ファイル添付: 不可

検索:
ページ移動:  
cron
Powered by phpBB® Forum Software © phpBB Limited
Japanese translation principally by ocean