棋盘游戏扭曲(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/the-boardgame-twix-with-a-twist-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2423 个词 阅读量 0棋盘游戏扭曲(译文)
原文地址:https://www.codeproject.com/Articles/8598/The-Boardgame-Twix-with-a-Twist
原文作者:Alex A. Miller
译文由本站 robot-v1.0 翻译
前言
This is a strategy board game which I used to enjoy playing with my neighbour when I was a teen in the 80s that I developed in Java, then ported to C#.
这是一种战略棋盘游戏,我80年代青少年时喜欢和邻居一起玩,我用Java开发,然后移植到C#.
介绍(Introduction)
这是我对CodeProject的第一项贡献! Twix是一种策略棋盘游戏,在方形塑料板上播放,该塑料板上包含用于连接桥钉的钉孔网格.(This is my first contribution to CodeProject! Twix is a strategy board game that was played on a square plastic board containing a grid of holes for pegs with which you connect bridges.) 此游戏中有两名玩家试图将不间断的桥梁从棋盘的一侧连接到棋盘的另一侧.其中一个玩家尝试连接左边缘和右边缘,而另一个玩家尝试对顶部边缘和底部边缘进行相同操作.不可避免地存在冲突,而这正是游戏的策略所在.(There are two players in this game who would try to connect an uninterrupted bridge from one edge of the board to the opposite edge of the board. One of the players attempts to connect the left and right edges, while the other tries to do the same with the top and bottom edges. Inevitably, there is conflict and therein lies the strategy of the game.) 玩家轮流将钉子放到网格上.当两个钉子在一个或两个以上的网格位置时(如国际象棋中的骑士),可以在钉子的顶部放置一个桥.桥梁不能跨过其他桥梁!每个钉子最多可以有八个与周围钉子相连的桥,这些桥被放置在"有效"网格孔中.(Players take turns placing pegs onto the grid. When two pegs are in a grid position of one-over and two-away (like a knight in chess moves), a bridge may be placed atop the pegs. Bridges may not cross other bridges! Each peg may have up to eight bridges connected with pegs surrounding it that are placed in the ‘valid’ grid holes.) 玩家每次放置钉子时,都要分析钉子以确定是否应放置任何桥(最多八个).不必将销钉放置在任何可能的桥梁位置,即不必每次都放置桥梁并连接销钉.(Every time a player places a peg, the peg is analyzed to determine if any bridges should be placed (up to eight). It is not necessary to place a peg in any potential bridge location, i.e., it is not necessary to place bridges and connect pegs in every turn.) 桥放置在颜色相似的桩上.桥梁不得跨过其他桥梁,也将不被允许.(Bridges are placed on like-colored pegs. Bridges may not cross other bridges and will not be allowed.) 我做了一些增强:(Some enhancements I have made:)
- 强制执行该球员的计时器必须采取行动或放弃其回合.(Timer to enforce that player must make a move or forfeit their turn.)
- 一种基于时间和新桥梁的积分系统,奖励快速的玩家行动.(A credit system based on time and new bridges that reward a quick player move.)
- 生物被授予累积了足够积分的玩家(光标将改变以指示该生物可以被发射).该生物在棋盘上被分配了一个位置(处于战略位置的对手的钉子是个不错的选择).该生物将继续前进到该位置,如果有钉,将抓住它并将其重新放置到一个空的网格位置.(A creature is awarded to a player who has accumulated enough points (The cursor will change to indicate that a creature may be launched). This creature is assigned a location on the board (an opponent’s peg in a strategic location is a good one). The creature will work its way over to that location, and if a peg is there, will grab it and relocate it to an empty grid position.)
代码讨论(Code Discussion)
我从事此项目的原因:(The reasons I undertook this project:)
- 这是一个很酷的游戏,我再也找不到了.(It was a cool game that I can’t find anymore.)
- 这是一个有趣的问题.(It was an interesting problem to solve.)
- 这是一个很好的起点平台,为我的生物对象引入了一个有用的运动场.(It was a good starting platform to introduce a useful playing field for my creature object.) 开发该游戏最棘手的部分是网桥连接/阻塞检测.下一个困难的问题是获胜条件检测.后者需要递归,前者需要大量边界检查和周到的循环.(The trickiest part of developing this game was the bridge connection/blockage detection. The next difficult problem was the win condition detection. The latter required recursion, the former required a lot of boundary checking and thoughtful looping.) 这种生物是我将近十年前想出的一种我的专业.它学习如何通过随机摆动其附件直到确定"好"动作来向坐标迁移.一个好的举动是其肘部和脚部比其当前的肘部和脚部结构更靠近目的地.然后,该生物反复重复这两种配置(伸展手臂,用脚抓住脚部以及伸展和收缩肘部),直到到达目的地或距目的地的距离增加为止.我为这个小家伙感到非常自豪,并最终在游戏中发现了一个有趣的用途.(The creature is a specialty of mine that I came up with almost ten years ago. It learns how to migrate towards a coordinate by randomly flailing its appendages until a ‘good’ move is determined. A good move is one where its elbow and its feet are closer to the destination than its current elbow and feet configuration. Then the creature iterates through the two configurations repeatedly (extending its arms, grabbing with its feet, and extending and contracting its elbow) until its destination is reached, or its distance from the destination increases. I’m very proud of this little guy and finally found an interesting use for it in a game.) 游戏由Windows主窗体中的计时器运行.每次发生计时器事件时,都会调用一组列表对象来工作.有一个爆炸列表,一个臂列表,一个钉列表(包含桥列表)和板对象.将图形翻页以提供平滑外观.(The game is run by a timer in the main Windows form. Every time the timer event occurs, a set of list objects is called upon to do work. There is an explosion list, an arm list, a peg list (which contain bridge lists) and the board object. The graphics is page flipped to provide a smooth look.) 开裂(Crack open)*Globals.cs(Globals.cs)*在演示模式下更改棋盘大小,生物的速度,它们的生成速度等.(to change the board size, the speed of the creatures, their spawn rate in demo mode, etc.)
期望的未来增强功能(Desired Future Enhancements)
- 声音!!良好的环境背景以及随着玩家离胜利越来越近而增加的心跳会很酷.爆炸声,生物行走声,抓握声等.(Sound!! Nice ambient background and a heartbeat that increases as the players get closer to winning would be cool. Explosion sounds, creature walking sounds, grabbing sounds, etc.)
- 一种播放器模式的计算机AI.(Computer AI for one player mode.)
- 网络上的两个参与者非常棒,但是需要大量甚至可能是困难的代码重组.(Two players over the network would be awesome, but a significant and possibly difficult restructuring of the code is required.)
- 玩家需要争取的更有趣的事件和子目标(封装某些内容会导致某些情况发生,等等)(More interesting events and sub-goals for players to strive for (enclosing something causes something to occur, etc.))
- 移植到DirectX,DirectSound,DirectPlay.(Port to DirectX, DirectSound, DirectPlay.)
历史(History)
- 19(19)日(th)2004年10月:初始版本(October, 2004: Initial version)
执照(License)
本文没有附带任何明确的许可,但可能在文章文本或下载文件本身中包含使用条款.如有疑问,请通过下面的讨论区与作者联系.(This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.) 可以找到作者可能使用的许可证列表(A list of licenses authors might use can be found) 这里(here) .(.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C# Windows .NET .NET1.1 Visual-Studio GDI+ VS.NET2003 Dev 新闻 翻译