我正在考虑在Python中构建基于回合制的策略“游戏引擎”。 我想使用数据库来保存有关游戏对象和ORM的信息以支持游戏逻辑。 我几乎没有ORM经验,但我对SQL很有经验。
数据库可能是:
有很多数据但结构简单 - 只需几个关系和外键,没什么复杂的 数据库的更新将在每个回合中“批量”,但我需要保留每个回合数据库状态的历史记录 - 所以我可以查看过去的任何游戏回合状态我想要:
写得越少越好 - 最好能够使用隐式构造函数和有用的隐式打印 通过添加或删除列或更改关系而无需一切崩溃,无需更新轮次之间的数据库结构,最好只更新类什么ORM会满足我的需求? 它甚至有意义吗?
澄清:
历史 - 转牌#5球员看到他认为不对的东西。 它可能发生在几个回合之前。 我希望能够在转牌#2和#3看到比赛状态进行双重检查。 我想我可以每回合创建一个数据库备份,但我在想是否有更优雅的解决方案。
更新数据库结构 - 假设我有类Unit,它有两个属性, attack和defense 。 我创建了许多Unit类型的对象并将其存储在数据库中。 在转向#25时,我意识到我还需要属性morale 。 我想用最少的工作添加它,让数据库为我更新表。 我该怎么办?
I am thinking about building turn-based strategy "game engine" in Python. I would like to use a database to hold information about game objects and ORM to support game logic. I have next to none experience with ORMs but I am experienced with SQL.
The database is probably going to be:
With a lot of data but with simple structure - just a few relations and foreign keys, nothing complex Updates to the database will be in "batches" for each turn, but I need the history of each turn database state retained - so I can look at any game turn state in pastI would like to:
Write as less as possible - preferably be able to use implicit constructors and useful implicit prints Seamlessly update the database structure between turns by adding or removing columns or changing relations without everything falling apart, preferably by just updating the classesWhat ORM would meet my needs? Does it even make sense?
Clarifications:
History - At turn #5 player spots something which he does not think is right. It probably happened few turns ago. I would like to be able to see the game state at turn #2 and #3 to double check. I guess I can create a backup of the database each turn but I was thinking if there is more elegant solution.
Updating the database structure - Lets say I have class Unit with two attributes, attack and defense. I create a lot of objects of type Unit and store it in the database. Around turn #25 I realize that I also need attribute morale. I would like to add it with minimal work and let the database update the tables for me. How would I do that?
最满意答案
SQLAlchemy满足您的大部分要求,除此之外
“,但我需要保留每个回合数据库状态的历史记录 - 所以我可以看看过去的任何游戏转弯状态”
我不确定你打算在这里打算做什么。
SQLAlchemy meets most of your requirements, except this
", but I need the history of each turn database state retained - so I can look at any game turn state in past"
I am not sure what you intend here.
更多推荐
发布评论