简体   繁体   English

多维列表和 Arrays

[英]Multi-Dimension Lists and Arrays

i have decided to study Python.我决定研究 Python。 I am working on a framework that will support 3 sports manager games: Basketball, Hockey, Soccer.我正在开发一个支持 3 种体育经理游戏的框架:篮球、曲棍球、足球。

After some reading (books, net, videos), i have decided to go with OOP (Class and Instances) to simulate my games.经过一些阅读(书籍、网络、视频),我决定用 go 和 OOP(类和实例)来模拟我的游戏。 Even though i still need to read a bit, i understand the mechanics that will allow me to make something realistic.尽管我仍然需要阅读一些内容,但我了解可以让我做出现实的机制。 Now, i am thinking about how to make my players 'intelligent'.现在,我正在考虑如何让我的球员“聪明”。 I would like to use various grids that will duplictate the playing surface.我想使用各种网格来复制游戏表面。 The first grid will be used to track the movement of the ball / puck, and the position of the players.第一个网格将用于跟踪球/冰球的运动,以及球员的 position。 This will be update in a class GamePlay.这将在 class GamePlay 中更新。 As for the decision making process of each player, i need them to look at where each players are, but also to consider their current assigment (offensive player, defensive player, left side defense, etc...).至于每个球员的决策过程,我需要他们看每个球员的位置,还要考虑他们目前的分配(进攻球员、防守球员、左侧防守等......)。 I would then need to create various grids with scores inserted into each box.然后,我需要创建各种网格,并将分数插入每个框中。 I would probably need to have 15-20 such grids to make the game realistic.我可能需要 15-20 个这样的网格才能使游戏变得逼真。 How should i go about it?我应该如何处理它? I can create each grid into Excel and then export it into CSV files.我可以将每个网格创建到 Excel 中,然后将其导出到 CSV 文件中。 But i would need to process them each time the program is running.但是每次程序运行时我都需要处理它们。 Or should i create them manually i lists?或者我应该手动创建它们我列出?

Use numpy array to make a multi dimension array.使用 numpy 数组制作多维数组。

import numpy as np
array_ = np.zeros((20,10))
array_[1,5] = 50
print (array_)

You can assign anything to the elements of the array您可以将任何内容分配给数组的元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM