Giter Site home page Giter Site logo

mazegenerator-cpp's Introduction

MazeGenerator-CPP

以前も書いた2次元迷路生成器をC++で書きました。

実行時間とか

計測データ

データ
各列の意味は
1辺の長さ:正方形の迷路を生成した場合の1辺のセル数
セル数:合計セル数(縦セル数×横セル数)
ループ数:While文の実行回数(計測値、平均)
実行時間:1つの迷路生成にかかった時間(秒、計測値、平均)
ループ数/セル数:そのまま
実行回数:ループ数、実行時間の平均を取るために実行した回数

ループ数

当然といえば当然ですが、ループ数(While文の実行回数)はセル数に比例しています。
セル数の増加に伴ってループ数も増加します。
ループ数

実行時間

実行時間はセル数に対して指数関数的に増加します。
セル数はループ数に比例するため、実行時間はループ数に対し指数関数的に増加するとも言えます。
仮に2秒以内に迷路生成を行いたいなら、セル数を30万程度に調整する必要があります。
実行時間

ループ数/セル数

セル数のおおよそ26%がループで処理されていることがわかります。
壁伸ばし法では座標が偶数のすべてのセル(全体の1/4)に対しどこに伸ばすかの処理を行うため、予想通りの結果でしょう。
セル数が少ないとき25%にかなり近いのは、拡張中の壁にぶつかった場合の処理の重い分岐に入る可能性が少ないから、
セル数の増加に伴いわずかに比率が上昇していくのは、セル数が増えるにつれ、拡張中の壁も長くなるため分岐に入る確率が増えるからだと考えられます。
ループ数セル数比

その他

計測値は正方形の迷路のものを使用したが、セル数が同じであれば縦横の比によらず実行時間はほぼ一定でした。
今後3次元への拡張をするつもりです。

参考

アルゴリズム:Algoful様(https://algoful.com/Archive/Algorithm/MazeExtend)

mazegenerator-cpp's People

Contributors

naohcodes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.