随机地图生成 [英] Random Map Generation

查看:81
本文介绍了随机地图生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个基于浏览器的战争游戏,我将使用PHP

。游戏需要一张大地图,我想随机生成这个

,因为这需要手动完成很多工作。


我的第一个原型这样做并没有给出好的结果,地图

太随意了,有人可以帮帮我或者给我一个好的

资源吗?


地图需要有海洋,理想情况是河流以及通常的地形,城市,森林,丘陵,平原等。


谢谢!

I''m wanting to write a browser based wargame and am going to use PHP
to it. The game requires a big map and I want to generate this
randomly as it will be a lot of work to do it manually.

My first prototype for doing this doesn''t give good results, the map
being far too random, can someone help me out or point me to a good
resource please?

The map will need to have sea in it and ideally rivers as well as the
usual terrain, cities, forest, hills, plains etc.

Thanks!

推荐答案

sk ********** @ googlemail.com 写道:

我想要的写一个基于浏览器的战争游戏,我将使用PHP

。游戏需要一张大地图,我想随机生成这个

,因为这需要手动完成很多工作。


我的第一个原型这样做并没有给出好的结果,地图

太随意了,有人可以帮帮我或者给我一个好的

资源吗?


地图需要有海洋,理想情况是河流以及通常的地形,城市,森林,丘陵,平原等。


谢谢!
I''m wanting to write a browser based wargame and am going to use PHP
to it. The game requires a big map and I want to generate this
randomly as it will be a lot of work to do it manually.

My first prototype for doing this doesn''t give good results, the map
being far too random, can someone help me out or point me to a good
resource please?

The map will need to have sea in it and ideally rivers as well as the
usual terrain, cities, forest, hills, plains etc.

Thanks!



i认为你应该写下你的算法算法

就像每10英里打印一个湖泊并靠近它是一个城市

把你必须遵循的逻辑放在纸上,然后尝试解决它上面的

问题,然后继续使用php

i think you should write your how algorithm
like every 10 miles print a lake and close to it a city
put on paper the logic you have to follow and then try to resolve the
problem on it before go on php


sk**********@googlemail.com 已写:
sk**********@googlemail.com wrote:

我做这个的第一个原型并没有给出好的结果,地图

太随意了,有人可以帮帮我或者给我一个好的

资源吗?
My first prototype for doing this doesn''t give good results, the map
being far too random, can someone help me out or point me to a good
resource please?



真正的地理位置不是随机的。


首先,取一个网格,比如1001x1001就是大小。现在找到

的中间方格,并将其设置为海拔1米的高度。现在从

那个方块螺旋出来,使用这样的算法为每个方格创建一个高度:


1.查看相邻的方块,但只有那些

你已经指定了一个高度!

2.找到那些高度的平均值(平均值)并称之为

Real geography is not random.

First, take a grid, say 1001x1001 is size. Now find the middle square of
it and set it to have a height of 1m above sea level. Now spiral out from
that square, creating a height for each square using an algorithm like this:

1. Look at the adjacent squares, but only the ones that
you''ve already assigned a height to!
2. Find the average (mean) of height those and call it


h。

3.现在我们在这里添加一些随机性:


if(rand(1,2)== 1)
h.
3. Now here''s where we add a bit of randomness:

if (rand(1,2)==1)


这篇关于随机地图生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆