编程之战_第一百二八章 地图压缩(中) 首页

字体:      护眼 关灯

上一章 目录 下一章

   第一百二八章 地图压缩(中) (第1/1页)

    “阿历克斯,再想想别的法子吧”,牛仔央求地说道。

    “唉,好吧”,杨成只好单手托腮,开始了思考。

    地图信息实例像这样:

    [true,true,true,false,true]

    [false,false,true,false,false]

    [true,false,true,false,true]

    [true,false,false,false,true]

    [true,true,true,true,true]

    这是一个5X5的矩阵。

    其中true代表可通行的区域,false标注的区域无法通行。

    那么,怎么把这个地图实例转为手机存储呢?

    一种最简单的方法,是把这个实例序列化为字符串,就像这样:

    “[[true,true,true,false,true],[false,false,true,false,false],[true,false,true,false,true],[true,false,false,false,true],[true,true,true,true,true]]“

    这种方法很有效,但缺点也很明显。

加入书签 我的书架

上一章 目录 下一章