我希望在一个特定的列表中找到一个条目序列,然后找到它的位置,这样我就可以在一个特定点之后的序列中添加一些额外的条目。我需要找出这一点,因为我正在为一个基于回合的游戏,我需要在任何必要的时候存储数据网格板工作
我的代码当前为:
CreateWorld.py:
global BaseHealth
BaseHealth = 10
global BaseHappiness
BaseHappiness = 10
global BaseIntelligence
BaseIntelligence = 10
global BaseProduction
BaseProduction = 10
global BaseWealth
BaseWealth = 10
global Tiles
Tiles = []
#The Process of Generating a Blank Map xAxis long and zAxis wide
def createLandscape(xAxis, zAxis):
#Sets the amount of createdRows to 0
createdRows = 0
#Calls createRow() the amount of times that the Map is Long
while createdRows < xAxis:
createRow(createdRows, zAxis)
createdRows += 1
#The Process of Generating a Blank Map Row zAxis Wide and with a Row Number of RowsCreated
def createRow(RowsCreated, zAxis):
#Sets the amount of createdTiles to 0
createdTiles = 0
createdRows = RowsCreated
#Calls createTile() the amount of times that the Row is wide
while createdTiles < zAxis:
createTile(createdRows, createdTiles)
createdTiles += 1
#The Process of Generating a Blank Map Tile in the
def createTile(RowsCreated, TilesCreated):
global Tiles
Tiles.append(RowsCreated)
Tiles.append(TilesCreated)
Tiles.append("end")
主文件:
import sys
sys.path.insert(1,'/BaseGame')
from Startup import Start
from Startup import MainMenu
from BaseGame import CreateWorld
global Tiles
#Start.start()
#MainMenu.listMenu_Main00()
CreateWorld.createLandscape(3, 3)
Tiles.insert()
print Tiles
我想能够采取一个列表的多个条目的
[x位置,z位置,任意,任意端,x位置,z位置,任意端,x位置,z位置,任意,任意,任意,任意端,等等]
然后在x的位置后面加上一个whatever,例如,32,z是50,这样就得到了
(。。。32,50,随便什么,结束)
对这类事情使用
dict
可能是有益的。例如,您可以使用全局Tiles
及其索引来访问特定的磁贴例如:
然后可以更新项目、添加到项目或从其他磁贴复制:
查找条目序列将取决于网格尺寸
在我的例子中,我使用的是1x3
为了找到一个系列,我将创建一个3x3,然后使用一个索引范围
`
相关问题 更多 >
编程相关推荐