Coder Social home page Coder Social logo

maze-generalization's Introduction

前言

我的迷宫代码的实现受到liuyubobobo/Play-with-Algorithm-Visualization 的影响.

liuyubobobo 迷宫的实现: GUI部分使用 java Swing, 编程语言是 Java.
我的迷宫代码实现: GUI部分使用 Cocos Creator 游戏引擎, 编程语言是 TypeScript.

Cocos Creator 源码工程 : 在 project 目录下.

运行动画

非递归实现的随机地图生成过程演示:

非递归实现的随机地图生成寻路过程演示:

开发环境

迷宫定义

实现的迷宫是什么样子呢?

迷宫的定义如下:

  • 只有一个入口, 只有一个出口
  • 只有一个解
  • 路径是连续的
  • 绘制在一个方形的画布上: 不是其它图形, 圆形等
  • 墙和路径都占一个单元格

约定入口和出口: 入口在第2行第1列, 出口在最后一列的倒数第2行

算法与数据结构

迷宫的生成和寻路使用的算法:

涉及的数据结构的实现:
Script/algorithm 文件夹下:

  • List : 线性表, 队列和栈的一个接口定义
  • Queue : 队列, 广度优先遍历非递归实现需要用到
  • Stack : 栈, 深度优先遍历非递归实现需要用到
  • RandomQueue : 随机队列, 使生成的地图更加随机, 不过仍然有点像BFS
  • RandomQueue2 : 随机队列,RandomQueue的改进版, 地图更加随机了

代码的演示

代码的演示包含两个部分:

  1. 地图已经生成的情况下, 从入口开始寻路找到出口
  2. 如何生成地图, 在有迷雾的情况下动态演示地图生成过程.

共有 10 个演示, 可以在编辑器中通过 visualType 属性进行选择:

支持地图规模修改以及地图格子大小的修改:

maze-generalization's People

Contributors

imymirror 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.