我花了几个小时研究这个问题,但我仍然感到困惑。请发现我的无知很迷人。
我正在构建一个 python 程序,它允许我在战舰游戏中让两个 AI 相互对抗。
这是我的目录结构:
.
??? ais_play_battleship
? ??? game.py
? ??? __init__.py
? ??? player.py
? ??? ship.py
??? LICENSE
??? README.md
??? tests
??? ship_test.py
2 directories, 7 files
Run Code Online (Sandbox Code Playgroud)
目前,我正在尝试编写ship_test.py,但似乎无法导入ais_play_battleship.ship. 我得到了可怕的“ModuleNotFoundError”
以下是我的研究告诉我有关我的问题的内容:
__init__.py在ais_play_battleship.python3 tests/ship_tests.py从根目录运行来启动我的测试。以下是我的具体问题:
请原谅我,因为我不太擅长在 StackOverflow 上提问。请告诉我如何改进。
我希望能够处理像 C++ 中的表格之类的东西。我的意思是“excel 电子表格”或“R dataFrame”中的表格。然而,我的解决方案不需要那么强大。我不需要在运行时添加列,但我将添加行来创建平均值。我正在从单个数据点构建此表,并且将在程序的其他地方读取此表以进行数据分析。我觉得像 SQLite 这样的解决方案有点矫枉过正。我怎样才能简单地表示这种数据?
为了更轻松地讨论选项,请考虑以下海洋温度表,我们将其称为data:
| DataType | DateTime | Location | Temperature |
| ----------- | ---------------- | --------- | ----------- |
| Observation | 2020-07-03_1325 | buoy 3882 | 18.1 |
| Observation | 2020-07-03_1512 | buoy 3882 | 16.6 |
| Observation | 2020-07-03_1701 | buoy 3882 | 15.8 |
| DailyAvg | 2020-07-03_0000 | buoy 3882 | 16.8 |
Run Code Online (Sandbox Code Playgroud)
重要的是,我能够访问基于任何属性的数据,以便我可以(在某种程度上)快速收集来自特定位置的所有点、具有相同日期的所有点等。
我已经考虑过制作一个二维数组(类似于std::vector< std::vector<boost::any> >),但这要求用户记住保存他们想要的数据的列的位置。(例如,对于第二个数据点的温度,用户必须使用data[1][3])。我还考虑过制作一个看起来像这样的结构:
struct DataPoint {
ObservationType …Run Code Online (Sandbox Code Playgroud) I am reading an array in parallel using openmp. Below is a minimal reproducible example:
#include <cstdint>
#include <cstdlib>
#include <immintrin.h>
#include <iostream>
#include <memory>
#include <omp.h>
int main(int argc, char* argv[]){
// align to cache line, which is 512 bits or 64 bytes
size_t actualSize = 2048;
uint8_t* array = static_cast<uint8_t *>(aligned_alloc(64, actualSize));
for(size_t i = 0; i < actualSize; i++){
// initialize values
array[i] = rand() % 256;
}
__m256i sum_v = _mm256_setzero_si256 ();
#pragma omp parallel for …Run Code Online (Sandbox Code Playgroud)