学习绘图/检查(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/learning-draughts-checkers-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 21 分钟阅读 - 10033 个词 阅读量 0学习绘图/检查(译文)
原文地址:https://www.codeproject.com/Articles/10442/Learning-Draughts-Checkers
原文作者:pseudonym67
译文由本站 robot-v1.0 翻译
前言
A Draughts Game that learns
学习的草稿游戏
介绍(Introduction)
“从总体上讲,我们很清楚需要什么样的模型,因为社会昆虫群落的基本特征已经很明显了.遵循简单的本地规则的个体就可以产生群落的成就."(“In a very general way it is clear what kind of models we need, because one basic feature of the organization of social insect colonies is already obvious. Individuals following simple local rules, generate the achievements of colonies.")
黛博拉`戈登(Deborah Gordon).蚂蚁在工作.(Deborah Gordon. Ants At Work.)
在"连接四人"的文章中,我编写了一款软件,该软件使用随机移动及其历史记忆来玩游戏.的确,程序中存在验证移动的代码,但是移动是由内存决定的还是随机决定的,这意味着在很大程度上,移动不是由逻辑过程引起的,而是由程序的记忆过往的演奏方式.该程序是对"连接四"代码中尝试过的思想的扩展,代表了半步前进,半步前进的方法,尽管该代码从未完全随机地移动,但它完全能够玩游戏.起草时不参考收集的数据.该程序收集的历史数据更多地影响了游戏的玩法,而不是它在"四连环"游戏中的总和和实质.(With the Connect Four article, I wrote a piece of software that played a game using random moves and its historical memory in order to play a game. It is true that there is code in the program that verifies the move but the moves are decided by either the memory or on a random basis, which means that to a large extent the moves are made not due to a logical process but by the program’s memory of how it has been played before. This program is an expansion on the ideas tried in the Connect Four code and represents a sort of half a step back, half a step forward approach in that although the code never makes a completely random move, it is perfectly capable of playing a game of draughts without referring to the data that it has collected. The historical data collected by the program serves as more of an influence on the way the game is played rather than being the sum and substance that it is in the Connect Four game.) 话虽如此,该程序的本质是它是一个草稿游戏,因此即使玩家不了解甚至不知道其玩法的来龙去脉,也应该提供合理的草稿游戏. .这不是在代码中通过制定一套游戏遵循的总体规则或策略来实现的,而应通过使每个动作尽可能独立于彼此的动作来实现(历史影响除外).下面概述了根据通常在草稿中移动的想法计算出的每个棋子的移动选项,例如"如果我去那里我会被抓住"或"如果我不移动我就会被抓住”.(That being said, the essential nature of the program is that it is a draughts game and as such should give a reasonable game of draughts even if the ins and outs of how it gets to play the game are not understood or even known to the player. This is to be achieved within the code not by having a set of overall rules or strategies that the game follows but by making each move as independent as possible from each other move with the exception of the historical influences. The options for the movement of each piece being calculated according to the normal idea of making a move in draughts such as ‘will I get taken if I go there’ or ‘will I be taken if I don’t move’ are outlined below.) 这带给我标题的"学习"和历史数据的使用,以及对于什么是真正的学习有许多定义的事实,我将陈述学习的概念是什么.程序.这并不是说这是学习存在的唯一想法,或者我相信这是唯一有效的学习定义.该项目的代码仅使用学习的思想.(Which brings me to the “learning” in the title and the use of the historical data and the fact that there are any number of definitions for what learning actually is, I’m going to state what the idea of learning is as used by the program. This is not to say that this is the only idea of learning that there is or that I believe it is the only definition of learning that is valid. It is simply the idea of learning that is used by the code for this project.) 因此,在这里,用于该项目的学习思想是该程序在其生命周期/体验中经历某些事件或移动.然后,这些事件将用于影响程序的未来行为,即程序对要进行的举动是否是好的举动的决定,既受程序对选秀游戏规则的理解,也受程序的影响.给定动作的历史.如果在程序赢得游戏的情况下使用了给定的举动,则比在失败的游戏中更频繁地使用给定的举动的可能性更大.(So, here goes, the idea of learning that is used for this project is that the program experiences certain events or moves within its lifetime/experience. These events are then used to influence the future behaviour of the program, i.e., the program’s decision about whether a move to be made is a good move or not is influenced by both the program’s understanding of the rules of the game of draughts and by the history of a given move. If a given move has been used in situations in which the program has won the game, then it is more likely to make the same move again than it would if the given move was used in a losing game more often than not.) 在项目开始之初,该程序的初衷是完全不玩完美的吃水游戏.该代码一次播放一次游戏,并根据其当前位置和过去的历史来确定其最佳操作.没有决策树计划x提前移动数.没有宏伟的计划可以说明,如果您遵循这些步骤,则计算机将获胜.没有评级系统可以说,如果您不擅长绘图,计算机将使您的工作更加轻松.这样做的原因是因为我想编写程序来以最基本的理解水平玩游戏,只需简单地考虑每个动作并给它一个等级即可.一旦开始添加一些内容,例如如果您想玩一个出色的草稿游戏,那么您就必须确保自己占优势或目标是双重尝试,就超出了我想要的代码的细节层次在工作.(At the outset of the project, there was the intention that the program would have no concept at all of how to play a perfect game of draughts. The code plays the game one move at a time and determines its best move based on its current position and its past history. There are no decision trees planning x number of moves in advance. There is no grand plan that says if you follow these moves, then the computer will win. There is no rating system that says that if you’re not very good at draughts, the computer will take it easier on you. The reason for this is because I wanted to write the program to play the game at its most basic level of understanding simply by considering each move in isolation and giving it a rating. As soon as you start adding things that say if you want to play a good game of draughts, then you have to make sure that you take the edges or you aim for double takes, you go beyond the level of detail that I wanted the code to work at.) 这种想法是,与其给程序一个静态的玩游戏游戏的思路,不如说它的理解更加流畅,因为代码在玩游戏时可能变好或变差.我并不期望程序的玩法改变不会超越其一般游戏的细微改进或弱化,但我的想法是反映一个真实的人在游戏中会变得更好或更糟的方式.随着时间的推移.但是,没有代码可以使游戏随着时间的流逝而遗忘,或者在游戏不够频繁时降低其获胜能力.(The idea being that rather than giving the program a static idea of how to play a game of draughts, its understanding is more fluid in that the code can get better or worse at playing the game. I don’t seriously expect that the changes in the program’s way of playing the game will go beyond being a subtle improvement or weakening of its general game but then the idea is to mirror the way a real person would get better or worse at the game over time. Although, there is no code to make it forget things over time or to diminish its ability to win if it doesn’t play often enough.)
训练(Training)
该程序的最初想法之一是一种训练模式,在这种模式下,计算机可以通过在指定时间内玩自己的游戏来达到一定水平的能力.这个想法被放弃是因为它根本没有任何好处.这背后的想法是学习应该是一个持续的过程,那么您如何限制学习?在我看来,您可以执行此操作的唯一方法是说,在一定程度上,该程序已学到了足够的知识.问题是,对于好或坏的学习已经有了一些设置规则,例如,如果程序得知某个举动会帮助自己赢得比赛,比如说在第9步移动A3,然后在每次移动A3时实际上进行练习9号输了比赛,您会说程序应该在哪一点停止调整其对9号行动所做的反应?此刻代码的工作方式是,它最终将开始认识到,在第9步移动A3是一个非常愚蠢的举动,并在第9步开始移动其他片段,而如果您在学习过程中胜出,如果将A3移到第9步,则无论结果如何,程序都将继续执行此操作.(One of the original ideas for the program was a training mode in which the computer would achieve a certain level of competence in the way the game is played by playing itself for a specified time. This idea was abandoned due to the reason that it simply wouldn’t be of any benefit. The thought behind this was that learning should be an on going process so how do you cap learning? It appears to me that the only way in which you could do this is to say that at a certain point, the program has learned enough. The problem is that there are already some setting rules for good or bad learning, for example if the program learns that a certain move will help it win the game, say moving A3 at move nine and then in practice every time it moves A3 at move nine it loses the game, at precisely which point will you say the program should stop adjusting its responses to the move it makes at move nine? The way the code works at the moment is that it will eventually begin to get the idea that moving A3 at move nine is a really dumb move and start moving other pieces at move nine, whereas if you capped the learning process when it was winning by moving A3 at move nine then the program would continue to do this regardless of the result.)
游戏规则(The Rules of the Game)
游戏规则是草稿或西洋棋游戏的标准规则,即每种颜色每次可以在对角线方向上一次旋转一个方块一个方块,除非它们能够在这一点上取走对手的方块他们将跳过一块,将其从板上移除.对游戏进行了编程,因此,如果玩家或计算机能够拿到一块,那么就必须拿下该块.这也适用于同一动作中可以拍的任何作品.电脑将自动移动所有可用的棋子,但玩家必须将接收到的棋子拖放到每张棋子上,直到棋子不能再取下为止.只要选中了使用高光的选项,程序将自动高亮显示任何给定动作中可取的片段.(The rules of the game are the standard rules for a draughts or checkers game, that is each colour can move one piece one square at a time per turn, in a diagonal direction unless they are in a position to take an opponent’s piece at which point they will jump over the piece to remove it from the board. The game is programmed so that if a player or the computer is able to take a piece then that piece must be taken. This also applies to any piece that can be taken in the same move. The computer will automatically take all the available pieces with a single move but the player must drag and drop the piece taken over each piece in such a way that they are taken until the piece cannot take any more pieces. The program will automatically highlight the pieces that are available to be taken in any given move as long as the option to use the highlights is checked.) 该游戏还具有一条内置规则,该规则规定,如果二十步之内不进行任何抽奖,则该游戏将被宣布为平局.这样做是为了防止游戏结束时无休止地来回移动.(The game additionally has an inbuilt rule that says if no pieces are taken for more than twenty moves, then the game is declared a draw. This is done to prevent endless moving backwards and forwards at the end of the game.)
用户界面(The User Interface)
程序的用户界面尽可能基本,而不会限制播放器可用的任何选项.当玩家使用拖放功能移动计算机时,计算机会自动移动.播放器可用的选项在四个选项卡控件上进行设置,其中第一个是(The user interface for the program is as basic as it can be without restricting any options available to the player. The computer moves automatically while the player uses drag and drop to move their pieces. The options available to the player are set up on four tab controls, the first of these being the)游戏设定(Game Setup)标签.(Tab.)
此选项卡包含将在其上玩游戏的颜色方块的选项,这些选项可以是浅色方块或深色方块.它允许您关闭突出显示选项,该选项在播放器通过拖放操作拾取片段时使用.高光选项向玩家显示当前选定作品的可用动作.此标签还包括(This tab contains the options for which colour squares the game will be played on, the choices being either the light or the dark squares. It allows you to turn off the highlights option which is used when the player picks up a piece using drag and drop. The highlights option shows the player the available moves for the current piece selected. This tab also includes the)开始(Start)按钮,指示程序根据选择的选项来绘制棋子以开始游戏.应该注意的是,第一个动作是由计算机随机决定的,因此没有选择指定谁先移动的选项.(button that instructs the program to draw the pieces to begin the game according to the options selected. It should be noted that the first move is randomly decided by the computer so there is no option to specify who moves first.)
的(The)播放器设定(Player Setup)标签仅包含玩家选择使用的棋子颜色的选项.应该注意的是,无论哪一侧移动哪种颜色,蓝色总是在面板上淡化,红色总是在面板上淡化.(tab simply contains the option for the colour of the pieces that the player chooses to use. It should be noted that the blues always play down the board and the reds always play up the board regardless of which side is moving which colour.)
的(The)板色(Board Colours)标签设置游戏板的颜色.从上面的图像中可以看到,这些是我在上面的板上使用的颜色,因此您可以轻松地查看其工作方式.(tab sets up the colours for the playing board. As you can see from the images above, these are the colours that I have used on the board above so that you can easily see how it works.)
的(The)可选颜色(Optional Colours)标签可设置播放器可选项目的颜色.在此程序中只有突出显示的部分是可选的,因此它是图纸上的唯一项目.(tab setups up the colours for the items that are optional for the player. There is only the highlights that are optional in this program so it is the only item on the sheet.)
代码(The Code)
自然地,试图在本文中描述项目中的所有代码会有点过分,因此我将在这里集中介绍游戏逻辑的简要概述.对于那些对其他部分的工作方式感兴趣的人,模糊逻辑库在我有关Code Project和(Naturally trying to describe all the code in the project in this article would be a bit too much so I’ll concentrate here on a brief outline of the logic for playing the game. For those who are interested in how the other parts work, the fuzzy logic library is fairly comprehensively covered in my articles on Code Project and the) BoardControl
DLL是一种简单易用的Windows GUI控件,对于人们自己来说应该不难.(DLL is a straightforward Windows GUI control which shouldn’t be too hard for people to work out for themselves.)
草稿委员会(Draughts Board)
的(The) DraughtsBoard
类继承自(class inherits from the) Board
包含在(class contained in the) BoardControl
DLL和控制开发板的主要设置,并保持程序平稳运行.玩家移动的所有处理都直接在(DLL and controls the main setup of the board and keeps the program running smoothly. All the processing for the player’s movement is done directly in the) DraughtsBoard
该类控制拖放控件,正方形的高亮显示以及拖放的图像显示.(class which controls the drag and drop controls and the highlighting for the squares as well as displaying of the images for the drag and drop.)
任何拖放操作的主要驱动功能是(The main driving function for any drag and drop operation is the) OnDragOver
该功能在这种情况下主要用于确定要移动哪个色块.然后该函数调用(function which in this case is used mainly to figure out which colour piece is being moved. The function then calls either the) PlayerLightMove
或者(or the) PlayerDarkMove
功能.这些实际上是为检查不同方向而编写的相同功能.在大多数情况下,这些函数将执行以下代码的版本:(functions. These are in effect the same functions that are just written to check different directions. In most circumstances, the functions will execute a version of the following code:)
if( bsStartSquare != null
&& GetSquareAboveLeft( bsStartSquare.Identifier ) == square
|| GetSquareAboveRight( bsStartSquare.Identifier ) == square)
{
if( bMustTake == false )
{
square.DragDropImage = bitLightDrop;
bAllowDrop = true;
}
else
{
square.DragDropImage = this.bitLightNoDrop;
bAllowDrop = false;
}
return;
}
此代码告诉程序在板上移动鼠标时要显示哪个图像.当代码首次调用鼠标指针时,突出显示供玩家移动的方块的代码是在拖放操作开始时触发的(This code tells the program which image is to displayed when the mouse is moved around the board. The code to highlight the squares available to the player to move is triggered at the start of the drag and drop operation when the code first calls the) OnDragOver
功能.高亮功能代码的标准部分是:(function. A standard piece of the highlight function code is:)
bool bMultiSquares = true;
/// check to see if it is more than a single jump
///
while( bMultiSquares == true )
{
bMultiSquares = false;
squareToMoveTo = squareTemp;
BasicSquare squareNext =
GetSquareAboveLeft( squareTemp.Identifier );
if( squareNext != null && squareNext.IsOccupied == true )
{
if( squareNext.OccupyingName == "COMPUTER" )
{
squareTemp = GetSquareAboveLeft( squareNext.Identifier );
if(squareTemp != null && squareTemp.IsOccupied == false)
{
squareTemp.DrawHighlight = true;
bMultiSquares = true;
}
}
}
squareNext = GetSquareAboveRight( squareToMoveTo.Identifier );
if( squareNext != null && squareNext.IsOccupied == true )
{
if( squareNext.OccupyingName == "COMPUTER" )
{
squareTemp = GetSquareAboveRight( squareNext.Identifier );
if(squareTemp != null && squareTemp.IsOccupied == false)
{
squareTemp.DrawHighlight = true;
bMultiSquares = true;
}
}
}
}
这段代码是整个程序中使用的典型技术,在这种情况下,您从一个起始正方形开始(This code is typical of the technique used throughout the program in that you begin from a starting square, in this case) squareTemp
然后在周围的正方形中搜索所需的信息.在上述情况下,代码正在搜索上方和左右方格(and then search the surrounding squares for the information you require. In the case above, the code is searching the squares above and to the left and right of) squareTemp
努力确定是否可以拍摄并突出显示需要绘画的作品.(in an effort to ascertain if there is a piece that can be taken and highlights the one that needs drawing.)
草稿游戏(Draughts Game)
的(The) DraughtsGame
阶级是游戏如何运作的原动力.这是计算机移动的关键所在.这是主要决策过程在(class is the driving force behind how the game works. This is where the nuts and bolts of the computer’s move take place. This is where the main decision process takes place in the) MovePiece
函数,但在代码到达该函数之前,它会建立一个所有可在其中移动的可用片段的列表.(function, but before the code gets to that, it builds a list of all the available pieces that can be moved in the) GetAvailablePieces
函数,其代码如下所示:(function, the code for which, looks like this:)
DraughtsSquare tempSquare = (DraughtsSquare)board.GetHashTable[
board.GetIdentifierBelowLeft(square.Identifier)];
if( tempSquare.IsOccupied == false )
{
DraughtsPiece piece = new DraughtsPiece( square.Identifier,
"COMPUTER", false, square.IsKing );
if( pattern.IsPieceInPattern( piece.SquareIdentifier,
nMoveNumber ) == false )
{
if( pattern.GamePieces.Count == 0 )
piece.IsStartForPattern = true;
piece.AddMove( tempSquare.Identifier );
pattern.AddGamePiece( piece );
}
else
{
pattern.AddMoveToPiece( piece, tempSquare.Identifier );
}
}
else
{
/// check if it's a possible take piece
///
if( tempSquare.IsOccupied == true
&& square.OccupyingName !=
tempSquare.OccupyingName )
{
DraughtsSquare checkSquare = (DraughtsSquare)board.GetHashTable[
board.GetIdentifierBelowLeft( tempSquare.Identifier )];
if( checkSquare != null && checkSquare.IsOccupied == false )
{
DraughtsPiece piece = new DraughtsPiece( square.Identifier,
"COMPUTER", false, square.IsKing );
if( pattern.IsPieceInPattern(
piece.SquareIdentifier, nMoveNumber ) == false )
{
if( pattern.GamePieces.Count == 0 )
piece.IsStartForPattern = true;
piece.AddMove( checkSquare.Identifier );
pattern.AddGamePiece( piece );
}
else
{
pattern.AddMoveToPiece( piece, tempSquare.Identifier );
}
}
}
}
代码从在板上找到一个正方形开始,然后检查它是否被占用.当我们输入上面的代码时,我们知道正方形包含的部分不是玩家的部分,并且玩家正在玩轻便的部分,这意味着玩家正在下棋盘,而计算机正在上棋.然后,上面的代码检查以查看我们正在检查的正方形下面和左边的正方形是否是(The code starts by finding a square on the board and then checking to see if it is occupied or not. By the time we enter the code above, we know that the square contains a piece that is not the player’s piece and that the player is playing with light pieces which means that the player is playing down the board and the computer is playing up. The code above then checks to see if the square below and to the left of the square that we are checking is) null
是否有效(从上面的代码中省略),如果该正方形有效,我们首先检查左下方的正方形是否包含另一块.如果不是,则认为这是有效的举动.的(or not, (omitted from the code above) if the square is valid, we proceed by checking if the square below left contains another piece. If it doesn’t, it is considered a valid move. The) else
的条款(clause of the) if
/(/) else
上面检查了阻止移动的棋子是否与我们要移动的正方形的占用者不同.在这种情况下,它只能是玩家的作品;如果不同,则意味着我们可以采取有效的行动.(above checks to see if the piece blocking a move is different from the occupier of the square that we are moving from. In this case, it can only be a player’s piece; if it is different, it means we could have a valid take move.)
验证移动之后,两种情况下的过程都是相同的,即创建了一个新的计算机并将其添加到该正方形的移动模式中.如果已经通过沿前一个方向的检查添加了棋子,请说"在右下方”,则将移动添加到该样式,如果没有,则将棋子添加到该样式.(Once a move has been validated, the process is the same in both cases in that a new computer piece is created and is added to the movement pattern for this square. If the piece has already been added by a check in a previous direction say Below Right then a move is added to that pattern, if not the piece is added to the pattern.)
一旦有了板上所有可用零件的可用图案,我们就可以开始考虑如何将它们移动到板上.(Once we have the available patterns for all the pieces available on the board, we can begin to consider how to move them in the) MovePiece
功能.主要决策过程(function. The main decision processes of the) MovePiece
功能如下图所示,过程的每个部分都通过以下变量声明了值:(function are pictured below with each part of the process being assigned a value by the following variables declared in the) DraughtsGame
类:(class:)
private const int nMustTake = 3;
/// values to set which decision set should be used
///
private const int nNormalMove = 1;
private const int nHistoricalMove = 1;
private const int nTakenMove = 2;
private const int nSacrificeMove = 1;
private const int nSupportMove = 1;
private const int nKingMove = 1;
private const int nLeavingOpenMove = 2;
private const int nOutOfWayMove = 1;
private const int nMustTakeTakenReduction = 1;
private const int nKingInfluenceMove = 1;
由于游戏中没有战术概念,因此通过玩游戏并查看游戏效果最佳可以得出其价值.最初的想法是让用户可以对过程的这一部分进行配置,但是由于它对所有人开放,因此,有人对其进行更改以使其完全是垃圾只是时间问题,因此这一想法被放弃了.在玩游戏时,然后开始抱怨它不起作用.(As there is no concept of tactics within the game, the values have been arrived at by playing the game and seeing which way it plays best. There was originally an idea to allow this part of the process to be user configurable but this was abandoned due to the fact that with it being open to all, it would only be a matter of time before someone changed it so that it was completely rubbish at playing and then started complaining that it didn’t work.) 下面的代码片段显示了如何在代码中使用这些值的简单示例,该代码片段用于检查法线(即单对角线移动):(A simple example of how these values are used within the code is shown in the following snippet from the code that checks normal, i.e., single diagonal moves:)
for( int i=0; i<collection.Count; i++ )
{
bDecisionIncremented = false;
bDecisionDecremented = false;
/// make sure that we are dealling with patterns for this move.
///
pattern = (DraughtsPattern)availablePatterns.GetPattern(i);
if( pattern.MoveNumber != nMoveNumber )
continue;
decisionSet = ( FuzzyDecisionSet )collection[ i ];
piece = ( DraughtsPiece )pattern.GetStartsWithPiece();
if( piece.LightPiece == true && piece.IsKing == false )
{
if( processMoves.IsAboveLeftClear(board,
piece.SquareIdentifier) == true)
{
decisionSet.AddByName( "MoveAboveLeft", nNormalMove );
bDecisionIncremented = true;
}
else
{
if( processMoves.IsEnemyAboveLeft( board,
piece.SquareIdentifier, piece.Player ) == true
&& processMoves.CanTakeAboveLeft( board,
piece.SquareIdentifier, piece.Player ) == false )
{
decisionSet.SetIsValidByName( "MoveAboveLeft", false );
}
}
}
if( processMoves.IsAboveRightClear( board,
piece.SquareIdentifier ) == true )
{
decisionSet.AddByName( "MoveAboveRight", nNormalMove );
bDecisionIncremented = true;
}
else
{
if( processMoves.IsEnemyAboveRight( board,
piece.SquareIdentifier, piece.Player ) == true
&& processMoves.CanTakeAboveRight( board,
piece.SquareIdentifier, piece.Player ) == false )
{
decisionSet.SetIsValidByName( "MoveAboveRight", false );
}
}
在决定每个动作需要采取什么动作之前,代码会循环遍历所有可用零件,并获取每个零件可用的动作模式.(The code cycles through the available pieces and gets the pattern of moves available for each piece, before deciding what action is required for each move.)
下图是用于决策过程的图表(Below is the diagram used for the decision process used in the) MovePiece
功能,每个运动选项都存储在(function, each movement option is stored in the) FuzzyDecisionSetCollection
包含一个数组的类(class that holds an array of) FuzzyDecisionSet
在函数中设置为的:(s which are set up in the function as:)
for( int i=0; i<availablePatterns.Count; i++ )
{
FuzzyDecisionSet fuzzyDecisionSet = new
FuzzyDecisionSet( availablePatterns.GetPattern( i ).GetStartsWith() );
fuzzyDecisionSet.Decision.IsValid = true;
fuzzyDecisionSet.Decision.IncrementDecision();
fuzzyDecisionSet.IsValid = true;
fuzzyDecisionSet.AddDecision( new FuzzyDecision( "MustTake", true ) );
fuzzyDecisionSet.AddDecision( new FuzzyDecision( "MoveAboveLeft", true ) );
fuzzyDecisionSet.IncrementByName( "MoveAboveLeft" );
fuzzyDecisionSet.AddDecision( new FuzzyDecision( "MoveAboveRight", true ) );
fuzzyDecisionSet.IncrementByName( "MoveAboveRight" );
fuzzyDecisionSet.AddDecision( new FuzzyDecision( "MoveBelowLeft", true ) );
fuzzyDecisionSet.IncrementByName( "MoveBelowLeft" );
fuzzyDecisionSet.AddDecision( new FuzzyDecision( "MoveBelowRight", true ) );
fuzzyDecisionSet.IncrementByName( "MoveBelowRight" );
collection.Insert( i, fuzzyDecisionSet );
}
然后,在整个过程中使用"(Any changes to the code values are then made throughout the process using the named tags of “) MoveAboveLeft
“,"(”, “) MoveBelowRight
“等(”, etc.)
草稿流程移动(Draughts Process Moves)
的(The) DraughtsProcessMoves
class是绑定播放器和计算机之间功能的粘合剂.概念上的类是一个简单的检查类,其中玩家和程序的计算机部分在确定各自动作的可用性时都使用该类,尽管对于玩家来说,此信息当然用于计算正在执行的动作可用于高光选项.(class is the glue that binds the functionality between the player and the computer. The class in concept is a simple checking class in that both the player and the computer parts of the program use it when they are deciding the availability of their respective moves, though of course for the player this information is used to calculate which moves are going to be available for the highlights option.)
数据(The Data)
下图显示了程序保存的XML数据的图片,以记录其历史进度.它显示在页面底部的Microsoft XML记事本链接中.(The image below shows a picture of the XML data that is saved by the program to record its historical progress. It is displayed in Microsoft’s XML Notepad links which can be found at the bottom of the page.)
上面显示的数据是正方形GC的第一步移动时存储的信息,计算机在播放蓝色棋子时,这意味着可以移动到的两个位置是正方形FD和HD.每个草稿移动的详细信息都存储在(The data shown above is the information stored for the square GC when it is the first move and the computer is playing with the blue pieces which means that the two places available to move to are the squares FD and HD. The details for each draughts move are stored in the) BasicMove
类(class that the) DraughtsMove
类继承,这些包含在(class inherits from and these are contained in the) DraughtsPiece
继承自(class that inherits from the) BasicGamePiece
类,尽管考虑了一下,但细节存储在(class, although thinking about it, the details stored in the) DraughtsPiece
该类可能会移至(class will probably be moved to the) BasicGamePiece
该系列中下一个程序的类.(class for the next program in the series.)
结论(Conclusion)
该项目的目的是开发一种程序,该程序比起草稿游戏应如何工作的标准思想更自然.这样做的目的更多是针对一种基于不基于控制板子上所有事物的全知全能的思想来计算移动量的系统,并且将固定响应或一系列响应预先编程到代码中,而将代码考虑彼此独立的每个动作,并根据给定情况下的最佳动作做出判断.这与具有其自身历史的程序的概念相结合,该程序能够影响但不一定支配关于每个动作做出的各个决定.从理论上讲,这至少意味着每个版本的代码在玩游戏时应显示出细微的差异,因为每个版本的游戏都有自己的历史记录,而该历史记录在很大程度上取决于游戏中每个玩家的动作.(The aim of this project was to develop a program that works in a more natural way than the standard idea of how a draughts game should work. This was done by aiming more for a system of calculating the moves on a basis that relied not on a total omniscient idea of controlling everything that occurs on the board and having a fixed response or series of responses preprogrammed into the code but for the code to consider each move in isolation from every other move and to make its judgments based on the best move in the given situation. This is coupled with the concept of a program having its own history which is able to influence but not necessarily dominate the individual decisions that are made about each move. This in theory at least will mean that each version of the code should display subtle differences when played as each version of the game will have its own history that is determined largely by the moves made by each individual player of the game.) 该方法的有效性和该程序编码中使用的技术的有效性留给读者.(The effectiveness of this method and the validity of the techniques used in the coding of this program is left to the reader.)
参考文献注释(A Note on the References)
下面列出的书是自我开始研究人工智能以来我所阅读的书.所有这些都或多或少地影响了我的思想,在我有意识地使用书中某些内容的地方,我会在文章中明确指出它是使用它的.文本中未提及一本书或多本书的事实并不意味着它没有影响力,因为它们都是核心研究的一部分.(The books listed below are the books that I have read since I started research on artificial intelligence. All of them have influenced my thinking to a greater or lesser degree, and where I knowingly use something from a book I will make it clear in the article that it uses it. The fact that a specific book or books are not mentioned in the text does not mean it has not had an influence as they are all part of the core research.)
参考文献(References)
- 汤姆`阿彻(Tom Archer)(2001)Inside C#,Microsoft Press(Tom Archer (2001) Inside C#, Microsoft Press)
- Jeffery Richter(2002)Applied Microsoft .NET Framework Programming,Microsoft Press(Jeffery Richter (2002) Applied Microsoft .NET Framework Programming, Microsoft Press)
- Charles Peltzold(2002)使用C#对Microsoft Windows进行编程,Microsoft Press(Charles Peltzold (2002) Programming Microsoft Windows With C#, Microsoft Press)
- Robinson et al(2001)Professional C#,Wrox(Robinson et al (2001) Professional C#, Wrox)
- William R. Staneck(1997)网络发布专业参考版,Sams.NET(William R. Staneck (1997) Web Publishing Unleashed Professional Reference Edition, Sams.NET)
- Robert Callan,(1999年),<神经网络的本质>,Prentice Hall.(Robert Callan, (1999) The Essence Of Neural Networks, Prentice Hall)
- Timothy Masters(1993)C ++中的实用神经网络食谱,Morgan Kaufmann(Academic Press)(Timothy Masters (1993) Practical Neural Network Recipes In C++, Morgan Kaufmann (Academic Press))
- Melanie Mitchell(1999)遗传算法导论,麻省理工学院出版社(Melanie Mitchell (1999) An Introduction To Genetic Algorithms, MIT Press)
- Joey Rogers(1997)C ++中的面向对象的神经网络,学术出版社(Joey Rogers (1997) Object-Orientated Neural Networks in C++, Academic Press)
- 西蒙`海金(Simon Haykin)(1999)神经网络综合基金会,Prentice Hall(Simon Haykin (1999) Neural Networks A Comprehensive Foundation, Prentice Hall)
- Bernd Oestereich(2002)在实践中使用UML进行面向对象分析和设计的软件开发Addison Wesley(Bernd Oestereich (2002) Developing Software With UML Object-Orientated Analysis And Design In Practice Addison Wesley)
- R Beale&T Jackson(1990)神经计算导论,物理研究所出版(R Beale & T Jackson (1990) Neural Computing An Introduction, Institute Of Physics Publishing)
- Bart Kosko(1994)模糊思维,火烈鸟(Bart Kosko (1994) Fuzzy Thinking, Flamingo)
- Buckley&Eslami(2002)对Physica-Verlag模糊逻辑和模糊集的介绍(Buckley & Eslami (2002) An Introduction To Fuzzy Logic And Fuzzy Sets, Physica-Verlag)
- 史蒂文`约翰逊(2001)出现,企鹅出版社(Steven Johnson (2001) Emergence, The Penguin Press)
- 约翰`霍兰德(1998):<从混沌到有序的出现>,牛津大学出版社(John H. Holland (1998) Emergence From Chaos To Order, Oxford University Press)
- 厄尔`考克斯(Earl Cox,1999年),<模糊系统手册>,AP专业人员(Earl Cox (1999) The Fuzzy Systems Handbook, AP Professional)
- 马克`沃德(1999),<虚拟生物>,潘(Mark Ward (1999) Virtual Organisms, Pan)
- Bonabeau,Dorigo,Theraulaz(1999)从自然系统到人工系统的群智能,牛津大学出版社(Bonabeau, Dorigo, Theraulaz (1999) Swarm Intelligence From Natural To Artificial Systems, Oxford University Press)
- Masao Mukaidono,初学者的模糊逻辑(2002)世界科学出版社(Masao Mukaidono, Fuzzy Logic For Beginners (2002) World Scientific Publishing)
- 黛博拉`高登(Deborah Gordon),<工作中的蚂蚁>(Ants at Work,1999年),诺顿W(Deborah Gordon, Ants At Work (1999), W W Norton)
- 吉格伦泽(Gigerenzer),托德(Todd)和美国广播公司(ABC)研究小组(1999)使我们变得聪明的简单启发式法,牛津大学出版社(Gigerenzer, Todd & ABC Research Group (1999) Simple Heuristics That Make Us Smart, Oxford University Press)
- Rodney A.Brooks(1999)寒武纪情报(Rodney A. Brooks (1999) Cambrian Intelligence)
有用的网址(Helpful Links)
- 我的CodeProject文章(My CodeProject articles)
- 来自SnapFiles.com的XMLNotepad(XMLNotepad from SnapFiles.com)
- 版本跟踪器的XML记事本(XML Notepad from Version Tracker)
执照(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++ C# VC7.0 WinXP Windows .NET .NET1.1 Visual-Studio VS.NET2003 Dev 新闻 翻译