汉mura拉比(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/hammurabi-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2392 个词 阅读量 0汉mura拉比(译文)
原文地址:https://www.codeproject.com/Articles/30058/Hammurabi
原文作者:BillLange1968
译文由本站 robot-v1.0 翻译
前言
A C# port of the classic Hammurabi game
经典Hammurabi游戏的C#端口
介绍(Introduction)
Michael Birken在<星际迷航>中的文章再次激发了我对经典BASIC游戏的兴趣.(Michael Birken’s Star Trek article rekindled my interest in classic BASIC games.) 小时候,我花了很多时间输入来自诸如Antic,Analog和Compute!等杂志的程序,以及来自诸如David Ahl的BASIC Computer Games(1978)和More BASIC Computer Games(1979)等各种书籍的程序.键入程序并使其成功运行之后,下一步就是进行更改,修改代码,添加功能等.(As a kid, I spent many hours typing in programs from magazines such as Antic, Analog, and Compute!, as well as from various books such as David Ahl’s BASIC Computer Games (1978) and More BASIC Computer Games (1979). After typing in a program and getting it to successfully run, the next step would be to make changes, modify code, add features, etc.) Hammurabi最初是由Richard Merrill在DEC PDP-8计算机上以FOCAL形式写为" The Sumer Game"(1969).稍后,它被移植到PDP-8 BASIC. David Ahl将此版本的Hammurabi移植到BASIC,并添加了10年的性能评估.(Hammurabi was originally written as ‘The Sumer Game’ (1969) in FOCAL on a DEC PDP-8 computer, by Richard Merrill. Sometime later, it was ported to PDP-8 BASIC. David Ahl ported this version of Hammurabi to BASIC, and added the 10-year performance assessment.) 回到那天,我还玩了Atari的Kingdom游戏程序,该程序随盒带提供.在查看了Hammurabi的BASIC列表之后,Atari的王国似乎是Hammurabi的直接港口,经过修改以使用Atari的屏幕功能.(Back in the day, I also played Atari’s Kingdom game program which came on cassette. After looking at the BASIC listing for Hammurabi, Atari’s Kingdom seems to be a direct port of Hammurabi, modified to use the Atari screen capabilities.)
移植(Porting)
我从1982年开始使用Atari 400家用计算机开始.当时,我有时发现使通用BASIC程序(例如BASIC Computer Games和More BASIC Computer Games中的程序)正常工作是一个挑战. Atari BASIC处理(I started out with an Atari 400 home computer back in 1982. At the time, I sometimes found it a challenge to get generic BASIC programs such as the programs in BASIC Computer Games and More BASIC Computer Games to work correctly. Atari BASIC handled) STRING
阵列与那个时代的其他8位机器不同. Atari BASIC也丢失了(arrays differently than other 8-bit machines of that era. Atari BASIC was also missing) FNA()
,(,) FNB()
,(,) FNC()
必须转换为子例程的语句类型.幸运的是,Hammurabi不需要任何这些更改.(types of statements which had to be converted to subroutines. Fortunately, Hammurabi did not require any of these changes.)
正如Michael Birken的文章所指出的,将BASIC程序移植到C#相当容易.若要Birkenize一个BASIC列表,请按照下列步骤操作:(As Michael Birken’s article points out, it is fairly easy to port BASIC programs to C#. To Birkenize a BASIC listing, follow these steps:)
例如:(For example:)
551 REM *** STARVE ENOUGH FOR IMPEACHMENT?
552 D=P-C:IF D>.45*P THEN 560
553 P1=((Z-1)*P1+D*100/P)/Z
555 P=C:D1=D1+D:GOTO 215
变成:(becomes:)
_551: ; // REM *** STARVE ENOUGH FOR IMPEACHMENT?
_552: D = P - C; if (D > .45 * P) goto _560;
_553: P1 = ((Z - 1) * P1 + D * 100 / P) / Z;
_555: P = C; D1 = D1 + D; goto _215;
例如:(For example:)
229 PRINT "A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED."
230 PRINT "POPULATION IS NOW"P
232 PRINT "THE CITY NOW OWNS"A"ACRES."
235 PRINT "YOU HARVESTED"Y"BUSHELS PER ACRE."
250 PRINT "RATS ATE"E"BUSHELS."
260 PRINT "YOU NOW HAVE"S"BUSHELS IN STORE.":PRINT
变成:(becomes:)
_229: Console.WriteLine("A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED.");
_230: Console.WriteLine("POPULATION IS NOW " + P.ToString());
_232: Console.WriteLine("THE CITY NOW OWNS " + A.ToString() + " ACRES.");
_235: Console.WriteLine("YOU HARVESTED " + Y.ToString() + " BUSHELS PER ACRE.");
_250: Console.WriteLine("RATS ATE " + E.ToString() + " BUSHELS.");
_260: Console.WriteLine("YOU NOW HAVE " + S.ToString() +
" BUSHELS IN STORE."); Console.WriteLine();
- 将BASIC行号更改为C#标签:(Change BASIC line numbers to C# labels:)
- 变更基本(Change BASIC)
GOSUB
方法调用的语句.(statements to method calls.) - 变更基本(Change BASIC)
PRINT
陈述(statements to)Console.Write[**Line**]
方法调用.(method calls.) - 由于C#使用基于零的索引,而BASIC使用基于一的索引,因此对于数组结构,要么修改数据以添加未使用的第零元素数据,要么修改代码以从现有索引逻辑中减去一个.(As C# uses zero-based indexing and BASIC uses one-based indexing, for array structures, either modify the data to add an unused zeroth element datum, or modify the code to subtract one from the existing indexing logic.)
- 审查剩余的陈述;修改代码,变量和逻辑以在C#中进行编译.(Review remaining statements; modify code, variables, and logic to compile in C#.)
玩(Playing)
在Hammurabi游戏中,您将指导Sumeria Hammurabi的管理员如何管理城市.在游戏开始时,Sumeria最初拥有1,000英亩土地,100人的人口和3,000蒲式耳的粮食储备.(In the game of Hammurabi, you direct the administrator of Sumeria, Hammurabi, how to manage the city. At the start of the game, Sumeria initially has 1,000 acres of land, a population of 100 people, and 3,000 bushels of grain in storage.) 您可以在附近的城市州购买和出售蒲式耳谷物.土地价格将在每英亩17至26蒲式耳之间变化.您还必须使用谷物来养活自己的人民,并作为播种明年作物的种子.(You may buy and sell land with your neighboring city-states for bushels of grain. The price of land will vary between 17 and 26 bushels per acre. You also must use grain to feed your people and as seed to plant the next year’s crop.) 您会很快发现,一定数量的人只能照看一定数量的土地,如果没有足够的粮食,人们就会挨饿.您也有意想不到的挑战,例如瘟疫,老鼠毁坏了储存的谷物以及收成不定.(You will quickly find that a certain number of people can only tend a certain amount of land, and that people starve if they are not fed enough. You also have the unexpected to contend with such as a plague, rats destroying stored grain, and variable harvests.) 您还将发现,在一个游戏周期(例如十年)内,仅管理该游戏中的少量资源并不是一件容易的事.人口密度危机非常迅速地抬起头来.(You will also find that managing just the few resources in this game is not a trivial job over a period, of say, ten years. The crisis of population density rears its head very rapidly.)
参考文献(References)
- 星际迷航1971文字游戏(Star Trek 1971 Text Game)
- 基本电脑游戏(BASIC Computer Games)
- 更多BASIC计算机游戏(More BASIC Computer Games)
- 汉mura拉比文章(Hammurabi article)
- 维基百科(Wikipedia)
- 邓宁顿(Dunnington) (链接断开)((Broken Link)) 回溯机(Wayback Machine) 条目(entry)
- BASIC源代码(BASIC source code) (链接断开)((Broken Link)) 回溯机(Wayback Machine) 条目(entry)
- Hammurabi的另一篇文章(Another Hammurabi article)
历史(History)
- 19(19)日(th)2016年2月:初始版本(February, 2016: Initial version)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C#3.0 C# C#2.0 .NET VS2010 VS2008 Dev 新闻 翻译