- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我必须制作一个奥赛罗游戏板,我想知道如何制作它才能正确打印板。这是我目前的代码。
import collections
NONE = 0
BLACK = 'B'
WHITE = 'W'
BOARD_COLUMNS = int(input('How many board columns? '))
BOARD_ROWS = int(input('How many board rows? '))
class OthelloGameState:
def _new_game_board() -> [[int]]:
board = []
for col in range(BOARD_COLUMNS):
board.append([])
for row in range(BOARD_ROWS):
board[-1].append(NONE)
return board
print (_new_game_board())
我使用打印来查看电路板的外观,结果如下:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0 , 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0 , 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
我该如何让它成为它应该的样子?
最佳答案
import pprint
board = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
pprint.pprint(board)
输出:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
查看以上内容的完整运行: https://ideone.com/6buCwM
关于python - 打印 2D 游戏板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37307825/
我们将 Azure Boards(与敏捷流程相关的项目)定义为“功能”>“史诗”>“任务”>“用户故事”。 在我们的Azure Boards(Boards >Board)中,它仅显示Epic和Feat
我正在编写一个 C++ 井字游戏,这是我目前拥有的: #include using namespace std; int main() { board *b; b->draw();
这是一个足够简单的问题。 看完documentation for ion-pane它指出: A simple container that fits content, with no side eff
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 4年前关闭。 Improve this
我正在用 javascript 对 arduino 开发板进行编程。我正在尝试使用 johnny-five 库连接多个 arduino 板。我关注了johnny-five documentation我
在我的 Java 类(class)中,我们正在学习《Java 基础知识》一书的第 4 章。我正在做项目 4-11,它是一个黑色和红色的棋盘格,但是我得到随机颜色,我试图按照本书教我们使用 ColorP
我正在制作一个数独板 GUI,它应该看起来像这样 http://www.sudoku.4thewww.com/Grids/grid.jpg 由于某种原因,它只显示最后一个 3*3 板。如果有人能告诉我
我正在开发一款带有二维阵列(游戏板)的新游戏。每个单元格/图 block 都有一定数量的点。 我想实现的是一个算法能找到核心最高的最短路径。 所以我首先实现了 Dijkstra 算法(下面的源代码)来
更新:(2015-10-16)[已解决!]-使用trigger()并通过slice()限制为50个引脚固定。 非常感谢Abhas Tandon通过提供使用 $(this).trigger('click
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 7年前关闭。 Improve this questi
var size = 8; var board = ""; for (var y = 0; y x= (x+y) % 2 = 关于javasc
我正在制作一个简单的游戏,需要我创建一个由用户定义大小的棋盘。 我一直在编写一个函数,该函数应该返回我将在我的游戏中使用的棋盘(矩阵),但我似乎无法让它工作。 我尝试使用嵌套的 for 循环方法在 m
我正在尝试让板模板引擎与 express.js 一起工作。我最初的尝试是这样的: app.register('.html', { compile: function (str, options
我正在测试 Azure Boards Rest API。我目前可以成功创建、删除和获取项目,但我似乎无法在列之间移动它们。 这是我的要求https://{{AzureBoardsToken}}@{{A
我想用 trello api 归档一个板/列表,但我找不到解决方案。 与 https://trello.com/docs/api/list/#post-1-lists-idlist-archiveal
我上传了 sketch到一个 Arduino Uno,它的循环是这样的: void loop(){ Serial.println("Hello, World!"); } 所以,现在,我无法再上
我想要进行一个查询,显示结构 Epic -> 功能 -> 发布 -> 用户故事 -> 任务,以及特定迭代路径下的所有待处理任务 我尝试使用工作项树,但它只显示到 mu 用户故事 我的 Azure De
我在 python 中使用来自 Opencv 的 Charuco 标记。我之前使用的是 Aruco 开发板,我可以选择创建一个带有 id 偏移量(例如:偏移量为 40)的开发板。 from cv2 i
我不知道如何将另一个 View 中的辅助 Anchorpane 设置到主 View 的边界(在 fxml 代码中,它将是名为 holderPane 并且有灰色区域),这样当窗口展开时,它也会随之拉伸(
如何使用包含列、行和堆栈(包含 4、3、2、1)的 3D 通用数组制作一 block 板。 这是我声明的: private int row, col, stack; int[][][] array3D
我是一名优秀的程序员,十分优秀!