凪瀬 Blog
Programming SHOT BAR

目次

Blog 利用状況
  • 投稿数 - 260
  • 記事 - 0
  • コメント - 43925
  • トラックバック - 192
ニュース
広告
  • Java開発者募集中
  • 経歴不問
  • 腕に自信のある方
  • 富山市内
  • (株)凪瀬アーキテクツ
アクセサリ
  • あわせて読みたい
凪瀬悠輝(なぎせ ゆうき)
  • Java技術者
  • お茶好き。カクテル好き。
  • 所属は(株)凪瀬アーキテクツ
  • Twitter:@nagise

書庫

日記カテゴリ

 

何を見てもアルゴリズムを考えてしまうのがプログラマの職業病といったところです。
私は結構ゲーム好きなんですが、ついついアルゴリズムを考えてしまうんですね。 バグを発見したときなどは楽しくてたまりません。 そのほつれからプログラムのコードが透けて見えるのです。

本日のターゲットは2001年、匠から発売されたアーケードゲーム「ナイトレイド」です。 ジャンルはシューティングなのですが、変なシステムを採用した、あまり見栄えのしないゲームでした。 このゲーム、非常にマイナーです。多分、名前を聞いて分かる人の方が少数派ですね。 ちなみにプレイステーションに移植されています。
アーケード版公式ページ
PS版公式ページ

このゲームには非常に致命的なバグがあり一部界隈では有名です。
自機を画面左上に移動させると敵が弾を撃たなくなるのです!
なぜこんなことが起こるのでしょうか?

矩形の衝突判定

ところで矩形(ようするに四角形のこと。プログラム用語。「くけい」と読む)同士の衝突判定はどうやるか分かりますか?

矩形の衝突判定

図のようにA,Bふたつの矩形があるとします。 Aの左上角の座標から見て右下にBの右下角があり(図の黒矢印)、 Aの右下角の座標から見て左上にBの左上角がある(図の赤矢印)場合にふたつの矩形は重なっているのです。

// 矩形Aの座標
// (ax1, ay1)───────────┐
//      └───────────(ax2, ay2)
// 矩形Bの座標
// (bx1, by1)───────────┐
//      └───────────(bx2, by2)
if (((ax1 < bx2&& (ay1 < by2))
    && ((ax2 > bx1&& (ay2 > by1))){
  // 衝突!
}

シューティングゲームでは敵に近くから弾を撃たれて即死しないように配慮して、 敵が自機に近い場合は弾を撃たないようにしているものがあります(ゲーマー用語で弾封じといいます)。

このナイトレイドでは自機と敵が重なってもミスとはならない仕様なのですが、 重なった状態から弾を撃たれると理不尽だろうという配慮でしょうか、 この弾封じの判定が実装されているわけです。

そして、あろうことか、弾封じのための矩形の衝突判定で条件式の"<"と">"を 間違えるというコーディングミスをしてしまったのです!

// 矩形Aの座標
// (ax1, ay1)───────────┐
//      └───────────(ax2, ay2)
// 矩形Bの座標
// (bx1, by1)───────────┐
//      └───────────(bx2, by2)
if (((ax1 < bx2&& (ay1 < by2))
    && ((ax2 < bx1&& (ay2 < by1))){
  // 衝突?
}

そして、誰もこのことに気づかないままゲームは出荷されたのでした。境界値テストは重要ですね。

投稿日時 : 2007年8月5日 18:28
コメント
  • # ゲームのバグにみるアルゴリズム - GameOver
    凪瀬 Blog
    Posted @ 2007/09/12 20:51
    ゲームのバグにみるアルゴリズム - GameOver
  • # re: ある期間が他の期間と重なっているかを調べるには?
    The road to C# master trapemiya
    Posted @ 2008/03/24 15:40
    re: ある期間が他の期間と重なっているかを調べるには?
  • # hkHtKWSaxBwcm
    https://amzn.to/365xyVY
    Posted @ 2021/07/03 2:27
    you can look here How do you password protect a Blogger blog on a custom domain?
  • # Illikebuisse agivs
    www.pharmaceptica.com
    Posted @ 2021/07/03 11:08
    erectile vasoconstriction https://www.pharmaceptica.com/
  • # erectile massage therapy
    hydrocholoroquine
    Posted @ 2021/07/07 22:02
    hydroxycloraquin https://plaquenilx.com/# hydrochlorique
  • # re: ??????????????? - ????
    hydroxchloroquine
    Posted @ 2021/07/10 12:12
    chloroquinolone https://chloroquineorigin.com/# hydroxychloroquine sulfate tablets
  • # re: ??????????????? - ????
    plaquenil hydroxychloroquine sulfate
    Posted @ 2021/07/16 15:46
    premature babies wikipedia https://chloroquineorigin.com/# hydroxychloronique
  • # re: ??????????????? - ????
    hydroxychloroquine 200 mg side effects
    Posted @ 2021/08/08 12:54
    chloroquinne https://chloroquineorigin.com/# hydroxychloroquine 400 mg
  • # I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
    I am actually delighted to glance at this blog pos
    Posted @ 2021/08/31 20:35
    I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
  • # I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
    I am actually delighted to glance at this blog pos
    Posted @ 2021/08/31 20:36
    I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
  • # I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
    I am actually delighted to glance at this blog pos
    Posted @ 2021/08/31 20:37
    I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
  • # I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
    I am actually delighted to glance at this blog pos
    Posted @ 2021/08/31 20:38
    I am actually delighted to glance at this blog posts which includes tons of valuable facts, thanks for providing such data.
  • # Hello would you mind stating which blog platform you're using? I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most
    Hello would you mind stating which blog platform y
    Posted @ 2021/09/02 7:10
    Hello would you mind stating which blog platform you're using?

    I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I'm looking for something unique.
    P.S My apologies for being off-topic but I had to ask!
  • # Hello would you mind stating which blog platform you're using? I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most
    Hello would you mind stating which blog platform y
    Posted @ 2021/09/02 7:11
    Hello would you mind stating which blog platform you're using?

    I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I'm looking for something unique.
    P.S My apologies for being off-topic but I had to ask!
  • # Hello would you mind stating which blog platform you're using? I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most
    Hello would you mind stating which blog platform y
    Posted @ 2021/09/02 7:12
    Hello would you mind stating which blog platform you're using?

    I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I'm looking for something unique.
    P.S My apologies for being off-topic but I had to ask!
  • # Hello would you mind stating which blog platform you're using? I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most
    Hello would you mind stating which blog platform y
    Posted @ 2021/09/02 7:13
    Hello would you mind stating which blog platform you're using?

    I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I'm looking for something unique.
    P.S My apologies for being off-topic but I had to ask!
  • # Amazing! Its actually amazing post, I have got much clear idea regarding from this article.
    Amazing! Its actually amazing post, I have got muc
    Posted @ 2021/09/02 12:52
    Amazing! Its actually amazing post, I have got
    much clear idea regarding from this article.
  • # These are in fact enormous ideas in regarding blogging. You have touched some fastidious factors here. Any way keep up wrinting.
    These are in fact enormous ideas in regarding blog
    Posted @ 2021/09/05 18:46
    These are in fact enormous ideas in regarding blogging. You
    have touched some fastidious factors here.
    Any way keep up wrinting.
  • # These are in fact enormous ideas in regarding blogging. You have touched some fastidious factors here. Any way keep up wrinting.
    These are in fact enormous ideas in regarding blog
    Posted @ 2021/09/05 18:47
    These are in fact enormous ideas in regarding blogging. You
    have touched some fastidious factors here.
    Any way keep up wrinting.
  • # These are in fact enormous ideas in regarding blogging. You have touched some fastidious factors here. Any way keep up wrinting.
    These are in fact enormous ideas in regarding blog
    Posted @ 2021/09/05 18:48
    These are in fact enormous ideas in regarding blogging. You
    have touched some fastidious factors here.
    Any way keep up wrinting.
  • # These are in fact enormous ideas in regarding blogging. You have touched some fastidious factors here. Any way keep up wrinting.
    These are in fact enormous ideas in regarding blog
    Posted @ 2021/09/05 18:49
    These are in fact enormous ideas in regarding blogging. You
    have touched some fastidious factors here.
    Any way keep up wrinting.
  • # I quite like reading through an article that will make people think. Also, thanks for allowing for me to comment! part time jobs hired in 30 minutes https://parttimejobshiredin30minutes.wildapricot.org/
    I quite like reading through an article that will
    Posted @ 2021/10/22 20:03
    I quite like reading through an article that will make people think.
    Also, thanks for allowing for me to comment!

    part time jobs hired in 30 minutes https://parttimejobshiredin30minutes.wildapricot.org/
  • # If you would like to improve your knowledge simply keep visiting this web site and be updated with the most up-to-date information posted here.
    If you would like to improve your knowledge simply
    Posted @ 2021/10/26 1:21
    If you would like to improve your knowledge simply keep visiting this web site and be updated with the
    most up-to-date information posted here.
  • # When someone writes an paragraph he/she keeps the plan of a user in his/her mind that how a user can be aware of it. Thus that's why this piece of writing is great. Thanks!
    When someone writes an paragraph he/she keeps the
    Posted @ 2021/10/26 17:47
    When someone writes an paragraph he/she keeps the plan of a user in his/her mind that
    how a user can be aware of it. Thus that's why this piece of writing is great.
    Thanks!
  • # When someone writes an paragraph he/she keeps the plan of a user in his/her mind that how a user can be aware of it. Thus that's why this piece of writing is great. Thanks!
    When someone writes an paragraph he/she keeps the
    Posted @ 2021/10/26 17:48
    When someone writes an paragraph he/she keeps the plan of a user in his/her mind that
    how a user can be aware of it. Thus that's why this piece of writing is great.
    Thanks!
  • # When someone writes an paragraph he/she keeps the plan of a user in his/her mind that how a user can be aware of it. Thus that's why this piece of writing is great. Thanks!
    When someone writes an paragraph he/she keeps the
    Posted @ 2021/10/26 17:49
    When someone writes an paragraph he/she keeps the plan of a user in his/her mind that
    how a user can be aware of it. Thus that's why this piece of writing is great.
    Thanks!
  • # When someone writes an paragraph he/she keeps the plan of a user in his/her mind that how a user can be aware of it. Thus that's why this piece of writing is great. Thanks!
    When someone writes an paragraph he/she keeps the
    Posted @ 2021/10/26 17:50
    When someone writes an paragraph he/she keeps the plan of a user in his/her mind that
    how a user can be aware of it. Thus that's why this piece of writing is great.
    Thanks!
  • # I feel that is one of the such a lot vital info for me. And i'm happy studying your article. However wanna commentary on some common things, The site taste is wonderful, the articles is in reality great : D. Good task, cheers
    I feel that is one of the such a lot vital info fo
    Posted @ 2021/11/12 15:23
    I feel that is one of the such a lot vital info for me.
    And i'm happy studying your article. However wanna commentary
    on some common things, The site taste is wonderful, the articles
    is in reality great : D. Good task, cheers
  • # I feel that is one of the such a lot vital info for me. And i'm happy studying your article. However wanna commentary on some common things, The site taste is wonderful, the articles is in reality great : D. Good task, cheers
    I feel that is one of the such a lot vital info fo
    Posted @ 2021/11/12 15:23
    I feel that is one of the such a lot vital info for me.
    And i'm happy studying your article. However wanna commentary
    on some common things, The site taste is wonderful, the articles
    is in reality great : D. Good task, cheers
  • # I feel that is one of the such a lot vital info for me. And i'm happy studying your article. However wanna commentary on some common things, The site taste is wonderful, the articles is in reality great : D. Good task, cheers
    I feel that is one of the such a lot vital info fo
    Posted @ 2021/11/12 15:24
    I feel that is one of the such a lot vital info for me.
    And i'm happy studying your article. However wanna commentary
    on some common things, The site taste is wonderful, the articles
    is in reality great : D. Good task, cheers
  • # I feel that is one of the such a lot vital info for me. And i'm happy studying your article. However wanna commentary on some common things, The site taste is wonderful, the articles is in reality great : D. Good task, cheers
    I feel that is one of the such a lot vital info fo
    Posted @ 2021/11/12 15:25
    I feel that is one of the such a lot vital info for me.
    And i'm happy studying your article. However wanna commentary
    on some common things, The site taste is wonderful, the articles
    is in reality great : D. Good task, cheers
  • # Its like you learn my mind! You appear to grasp a lot about this, like you wrote the guide in it or something. I feel that you can do with a few % to pressure the message house a bit, however instead of that, that is wonderful blog. A great read. I'll ce
    Its like you learn my mind! You appear to grasp a
    Posted @ 2022/03/23 5:10
    Its like you learn my mind! You appear to grasp a lot about
    this, like you wrote the guide in it or something.
    I feel that you can do with a few % to pressure the message house a bit,
    however instead of that, that is wonderful blog. A
    great read. I'll certainly be back.
  • # Its like you learn my mind! You appear to grasp a lot about this, like you wrote the guide in it or something. I feel that you can do with a few % to pressure the message house a bit, however instead of that, that is wonderful blog. A great read. I'll ce
    Its like you learn my mind! You appear to grasp a
    Posted @ 2022/03/23 5:11
    Its like you learn my mind! You appear to grasp a lot about
    this, like you wrote the guide in it or something.
    I feel that you can do with a few % to pressure the message house a bit,
    however instead of that, that is wonderful blog. A
    great read. I'll certainly be back.
  • # Its like you learn my mind! You appear to grasp a lot about this, like you wrote the guide in it or something. I feel that you can do with a few % to pressure the message house a bit, however instead of that, that is wonderful blog. A great read. I'll ce
    Its like you learn my mind! You appear to grasp a
    Posted @ 2022/03/23 5:12
    Its like you learn my mind! You appear to grasp a lot about
    this, like you wrote the guide in it or something.
    I feel that you can do with a few % to pressure the message house a bit,
    however instead of that, that is wonderful blog. A
    great read. I'll certainly be back.
  • # Its like you learn my mind! You appear to grasp a lot about this, like you wrote the guide in it or something. I feel that you can do with a few % to pressure the message house a bit, however instead of that, that is wonderful blog. A great read. I'll ce
    Its like you learn my mind! You appear to grasp a
    Posted @ 2022/03/23 5:13
    Its like you learn my mind! You appear to grasp a lot about
    this, like you wrote the guide in it or something.
    I feel that you can do with a few % to pressure the message house a bit,
    however instead of that, that is wonderful blog. A
    great read. I'll certainly be back.
  • # fusdwzebggjg
    kjjbmuss
    Posted @ 2022/06/01 20:10
    http://erythromycin1m.com/# erythromycin cream for acne
  • # I every time used to study post in news papers but now as I am a user of net thus from now I am using net for content, thanks to web.
    I every time used to study post in news papers but
    Posted @ 2022/11/29 0:37
    I every time used to study post in news papers but now as I am a user
    of net thus from now I am using net for content, thanks to
    web.
タイトル  
名前  
Url
コメント