<星际迷航>-分析善恶与丑恶(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/startrek-analysis-of-the-good-the-bad-and-the-ugly-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 8 分钟阅读 - 3708 个词 阅读量 0<星际迷航>-分析善恶与丑恶(译文)
原文地址:https://www.codeproject.com/Articles/28828/StarTrek-Analysis-of-the-Good-the-Bad-and-the-Ugly
原文作者:Jason McBurney, nefar12
译文由本站 robot-v1.0 翻译
前言
A Discussion about our StarTrek implementation
关于我们的StarTrek实施的讨论
- 下载源代码13.45 KB(Download source code - 13.45 KB)
- 下载版本-224.35 KB(Download build - 224.35 KB)
- 下载最新版本的源代码(Google代码)(Download latest version of source code (Google Code))
- 下载最新版本的build(Google Code)(Download latest version of build (Google Code))
介绍(Introduction)
你猜到了;我是一个极客,很高兴参加星际迷航挑战!因此,在阅读了指南之后,我给我的合著者发送了电子邮件,因为电子邮件是掌握极客的最快方法,因此他和我决定为您带来StarTrek文本风格的世界.(You guessed it; I’m a geek and got excited to participate in the star trek challenge! So after reading the guidelines, I emailed my co-author, since email is the fastest way to get hold of a geek, and he and I made the decision to bring you the world of StarTrek, text style.) 迈克尔`伯肯(Michael Birken)先生说:" [星际迷航(StarTrek)是一种值得在每次交易时重新发明的游戏."((Mr. Michael Birken states “[StarTrek] is the kind of game that deserves to be reinvented every time it trades hands.”() startrek_1971_text.aspx(startrek_1971_text.aspx) )而且我完全同意!实际上,有趣的后续文章将是竞赛条目的摘要,其中显示了所有条目的特征矩阵.() And I could not agree more! In fact, an interesting follow-up article would be a summary of the competition entries, showing a feature matrix for all of the entries.) 多年来,我一直在谈论编写游戏,但我还没有完全实现这一目标.基于文本的冒险应该消除图形上的麻烦,并让我专注于游戏的核心设计.而且,这是我想制作一段时间的另一个游戏冒险的原型.让我们看看情况如何.(I have been talking about writing a game for years, and I just have not quite achieved that goal. A text based adventure should eliminate the graphic headaches and allow me to focus on the core design of the game. Moreover, this is a prototype for another game adventure that I have wanted to produce for some time now. Let’s see how that goes.) 该系统由三个主要子系统开发:船舶结构,世界结构和UI.因此,我们将研究应用程序中最有趣的部分(当然不是UI).(The system is developed with three major sub-systems: ship structures, the world structures, and the UI. Therefore, we will be investigating the most interesting parts of the application (and it is certainly not the UI).)
目录(Table Of Contents)
- 面向对象的船舶设计–好的,坏的和丑陋的(The Object Oriented Ship Design – the good, bad and the ugly)
- 世界代表(The World Representation)
的(The)面向对象的船舶设计–好,坏和丑(Object Oriented Ship Design – The Good, Bad and the Ugly)
我在将来的游戏中想要的飞船设计将更类似于所发现的讨论(The ship design that I want in my future game would closer resemble the discussion found) 这里(here) 通过为每种类别的对象创建接口,船舶可以更好地与其他插件组件进行交互.在我的世界中,我只有一艘有趣的零件-武器.请注意,这种武器的定义有点不合常规,因为进攻性和防御性武器都可以算作.例如,红色警报也是一种武器.(by creating interfaces for each category of object the ship could better interact with additional plug-in components. In my world, I have only one interesting part to a ship, the weapons. Note this definition of weapons is a little unconventional, as both offensive and defensive weapons count. Red alert, for example, is also a weapon.) 该模型提供了合理的职责分离–特定的攻击性武器仅知道如何计算损害,而特定的目标舰船则了解如何应用该损害.例如,想象一下反抗者正在与猛禽战斗.当Defiant损坏时,由于它很小,因此很可能发生故障的频率更高,而具有更多表面积系统的企业应该具有较低的故障率,因为这些系统装在船上的密度较小.这种设计的关键是,发射武器不在乎损失的分布方式,而舰船不在乎损失的计算方式.(The model provides a reasonable separation of duties – A specific offensive weapon only knows how to calculate damage, while the specific targeted ship understands how to apply that damage. For example, imagine the Defiant is in a battle against a Bird of Prey. When the Defiant gets damaged, because it is so small it would most likely have a higher frequency of failing systems, while the enterprise with more surface area systems should have a lower failure rate because the systems are less densely packed into the ship. The key to this design is the firing weapon does not care how the damage is distributed, and the ship does not care how the damage is calculated.) 移相器系统背后的技术如何工作?好吧,我很高兴你问.相位器根据距离,能量和效率这三个主要因素来计算损坏.如果将移相器注册为3个单元的80%,那么对于目标所用的每个能量,当目标距离3个单元时,它将执行80%的能量.移相器背后的理论是,它们是声波,并且会发生色散.因此,如果目标超出了武器的射程,它将造成更少的伤害.同样,如果目标距离较近,那么它所造成的伤害将超过预期的损失.(How does the technology behind the phaser system work? Well I am glad that you asked. The phaser calculates damage based on three primary factors, distance, energy, and efficiency. If the phaser is registered at 80% for 3 units, then for each unit of energy used, it will perform 80% of the energy when the target is 3 units away. The theory behind phasers is that they are sound waves and subject to dispersion; therefore, if the target is beyond the range of the weapon, it will do less damage. Similarly, if the target is closer then it should do more than the expected damage.)
PhaserDamagePesudoCode(Eff, RecommedRange, AppliedEnergy)
{
Let d = EculadianDistance(SourceSector, TargetSector)
Eff += ((d – RecommedRange) * Penalty)
Return AppliedEnergy * Eff
}
哪里(Where) Penalty
是指在建议的距离内一个单元效率低下的成本,在本地实施中使用10%.(is the cost of inefficiency for one unit over the recommended distance, 10% is used in the local implementation.)
相反,光子系统要简单得多.它需要许多导弹和建议的射程.如果玩家将目标对准光子范围以外的船只,则认为导弹无法成功对准目标,因此它会对目标造成随机伤害,范围是从0到武器的最大伤害.(In contrast, the Photon system is much simpler; it requires a number of missiles and a recommended range. If the player targets a vessel beyond the range of the photon, it is assume the missile cannot be as successful at targeting the vessel so it does a random amount of damage to the target from 0 to the max damage of the weapon.)
PhotonDamagePesudoCode(RemainingMissiles, MaxDamage)
{
If RemainingMissiles <= 0, Return 0
RemainingMissiles = RemainingMissiles - 1
Let d = EculadianDistance(SourceSector, TargetSector)
Let Damage = MaxDamage
If d > MaxDistance
Damage = randomNumberBetween(0, MaxDamage)
Return Damage
}
最后,船能够对其自身造成损害.尽管此版本中只有一种实现方式,但有可能采用其他方式对船舶造成损坏:(Lastly, the ship is able to apply damage to itself. While there is only one implementation in this version, it is possible to have some other way of applying damage to a vessel:)
- 首先,防护罩被损坏,因为它们是第一道防线.(First the shields are damaged, since they are the first line of defence.)
- 如果还有剩余的损坏,可能会损坏某些武器系统;我想象到,当盾牌将船只的一部分暴露给对手时,会发生二次爆炸和其他故障.(If there is remaining damage, it could damage certain weapon systems; I imaged having secondary explosions and other failures when the shields exposed parts of the vessel to the opponent.)
- 最后,由于没有其他防御措施,因此会对船舶的船体造成损害.(Finally, damage is applied to the hull of the ship, since there is no other defence.)
的(The)世界代表(World Representation)
如前所述,世界结构是三大子系统之一.世界由单例模式表示,该模式在首次使用时将从配置XML文件加载星系,该文件包含有关世界的外观,形状,内容以及当然还有Kligons的所有相关信息. .(As mentioned before, the world structure is one of the three major sub-systems. The world is represented by a Singleton pattern, which upon the first use will load the galaxy from a configuration XML file, which contains all of the relevant information about what the world looks like, the shape, the contents and, of course, the Kligons.) 我想说的是,我宁愿使用序列化和反序列化方法来构建我的世界.但是,多维数组不能使用XML进行序列化,并且我对二进制序列化不感兴趣,因为播放器或开发人员不容易对其进行编辑.游戏内部的安全性不是设计考虑因素.我一直在寻找灵活性和一致性.(I would like to say, I would have preferred to use serialization and deserialization methodology to construct my world; however, multidimensional arrays cannot be serialized using XML and I was not interested in binary serialization, as that cannot be easily edited by the player or developer. Security of the game internals was not a design consideration. I was looking for flexibility and consistency.) 使用JetBrains dotTrace对世界表示进行了一些快速分析之后,我的内存使用效率非常低.超过200 Meg占用了6,265个唯一的SpaceUnit实例,这些实例代表空白空间.没什么!请注意以下几行:(After performing some quick analysis of the world representation, using JetBrains dotTrace, my memory usage is very inefficient. Over 200 Meg is being occupied with 6,265 unique SpaceUnit instances, which represent empty space. That’s a whole lot of nothing! Note the following lines:)
private static Galaxy LoadWorldXML(FileInfo target)
{
//Fill nulls with space locations.
for (int i = 0; i < size.X; i++)
{
for (int j = 0; j < size.Y; j++)
{
for (int k = 0; k < size.Z; k++)
{
//Create a null Quadrant if null
if (rVal.cGalaxy[i, j, k] == null)
rVal.AddItem(i, j, k, Quadrant.FromString(new string('0', 64)));
}
}
}
return rVal;
}
那为什么我需要6000个呢?因为在这种设计中,行进的定义只是改变了行车路线的内容.(So why do I need 6000 of these? Because, in this design, the definition of traveling is simply altering the contents of the) iSpaceItem.PresentShip
变量.如果系统是基于笛卡尔的,则可以排除这些大部分未使用的对象.(variable. If the system was more Cartesian based, these mostly unused objects could be factored out.)
相比之下,这种设计很简单–我们具有树状结构,其根植于星系,分支成象限,而留下(In contrast, this design is simple – we have a tree-like structure, rooted with a galaxy, branched with Quadrants, and leaved with) iSpaceItems
.如果要在此实现中添加黑洞,则实现接口大约需要10分钟,将其添加到配置文件中大约需要3-5分钟,而将其添加到builder函数中则需要1分钟.(. If you want to add black-holes to this implementation, that should take approximately 10 minutes to implement the interface and 3-5 to add it to the configuration file, and one minute to add it to the builder function) BuildSpaceUnit
.(.)
未来见解(Future Insights)
- 尽管船舶设计是"方向正确的",但必须提高其坚固性,以便可以更好地模拟真实的复杂船舶设计.(Although the ship design is “directionally correct”, it must improve on its robustness so it can better simulate a real complex ship design.)
- 向船舶模型添加访客模式以进行渲染和损坏计算将是朝正确方向迈出的一步(Adding a visitor pattern to the ship model for rendering and damage calculations would be a step in the right direction)
- 还实施了通知系统,以便船舶可以与其他感兴趣的对象进行通信.(Also implementing a notification system so the ship can communicate with other interested objects.)
- 世界配置很好.但是,较差的内存使用量是将来版本中需要解决的问题.(The world configuration is nice; however, the poor memory usage is something that needs to be addressed in future versions.)
- 某些地形应该具有一定的智能,行星应该能够绕星或其他地形物体(可能是黑洞)运行.(Some Terrain should have some intelligence, a planet should be able to orbit a star or other terrain object (a black hole maybe).)
- 空间站应该是一艘船,而不是地形的一部分.克林贡人无法在一块地形上打仗,这很无聊.此外,进入克林贡人正在与联邦空间站作战的领域,将是一个壮观的景象.(The Space Station should be a vessel rather than an element of terrain. The Klingons cannot go to war with a piece of terrain, and that’s no fun. Moreover warping into the sector where the Klingons were battling a federation space station would be a spectacular sight.)
历史(History)
- 2008年8月25日:初始上传(Aug-25, 2008: Initial upload)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C#3.0 C# C#2.0 Windows Design 新闻 翻译