Пример #1
0
		public override void Load(XmlReader xmlReader)
		{
			bool bBreak = false;
			for( ;; )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
				switch( xmlReader.NodeType )
				{
					case XmlNodeType.Element:
					{
						switch( xmlReader.Name )
						{
							case "DraughtsPattern":
							{
								DraughtsPattern temp = new DraughtsPattern();
/*
								while( xmlReader.Name != "MoveNumber" )
								{
									xmlReader.Read();
								}

								xmlReader.Read();

								temp.MoveNumber = Int32.Parse( xmlReader.Value );
*/
								temp.Load( xmlReader );
								Patterns.Add( temp );
								break;
							}
						}
					} break;
					case XmlNodeType.EndElement:
					{
						switch( xmlReader.Name )
						{
							case "BasicGamePatternCollection": bBreak = true; break;
						}
					} break;
				}

				if( bBreak == true )
					break;
			}
		}
Пример #2
0
		public void UpdatePattern( DraughtsPattern pattern )
		{
			string strTemp = pattern.GetStartsWith();

			for( int i=0; i<Patterns.Count; i++ )
			{
				if( ( ( DraughtsPattern )Patterns[ i ] ).StartsWith( strTemp ) == true )
				{
					for( int n=0; n<pattern.GamePieces.Count; n++ )
					{
						DraughtsPiece piece = ( DraughtsPiece )pattern.GamePieces[ n ];

						if( ( ( DraughtsPattern )Patterns[ i ] ).IsPieceInPattern( piece ) == true )
						{
							DraughtsPiece collectionPiece = pattern.GetPiece( piece.SquareIdentifier ); 

							if( collectionPiece != null )
							{
								for( int j=0; j<piece.Moves.Count; j++ )
								{
									/// draughts move will add or update as appropriate
									/// 
									collectionPiece.AddMove( ( ( DraughtsMove )piece.Moves[ j ] ).Identifier );
								}
							}
						}
						else
							( ( DraughtsPattern )Patterns[ i ] ).AddGamePiece( piece );
					}
				}
			}
		}
Пример #3
0
		public bool IsIn( DraughtsPattern pattern )
		{
			for( int i=0; i<Patterns.Count; i++ )
			{
				if( ( ( DraughtsPattern )Patterns[ i ] ) == pattern )
					return true;
			}

			return false;
		}
Пример #4
0
		public void AddPattern( DraughtsPattern pattern )
		{
			Patterns.Add( new DraughtsPattern( pattern ) );
		}
Пример #5
0
		/// <summary>
		/// do not call base copy constructor from here as it will cast the
		/// internal game pieces to basic game pieces and c**k everything up.
		/// </summary>
		/// <param name="patternSet"></param>
		public DraughtsPattern( DraughtsPattern pattern ) : base()
		{
			NumberOfTimesSeen = pattern.NumberOfTimesSeen;
			NumberOfTimesSeenInWinningGame = pattern.NumberOfTimesSeenInWinningGame;
			NumberOfTimesSeenInLosingGame = pattern.NumberOfTimesSeenInLosingGame;
			IsWinningPattern = pattern.IsWinningPattern;
			IsLosingPattern = pattern.IsLosingPattern;
			Weighting = pattern.Weighting;
			Response = pattern.Response;
			PatternID = pattern.PatternID;
			IsEndingPattern = pattern.IsEndingPattern;
			MoveNumber = pattern.MoveNumber;

			for( int i=0; i<pattern.GamePieces.Count; i++ )
			{
				GamePieces.Add( ( DraughtsPiece )pattern.GamePieces[ i ] );
			}
		}
Пример #6
0
		/// <summary>
		/// Get the currently available moves.
		/// </summary>
		/// <param name="board"></param>
		/// <param name="light"></param>
		public void GetAvailablePieces( bool light )
		{
			if( availablePatterns == null )
				throw new Exception( "Everything's screwed" );

			availablePatterns.Clear();
			nMoveNumber++;

			/// get all moveable pieces 
			/// 

			foreach( DictionaryEntry dicEnt in board.GetHashTable )
			{
				DraughtsSquare square = ( DraughtsSquare )dicEnt.Value;

				if( square.IsOccupied == true )
				{
					DraughtsPattern pattern = new DraughtsPattern();

					pattern.MoveNumber = nMoveNumber;

					/// is it a computer piece
					/// 
					if( square.PlayerIsOnSquare == false )
					{
						/// work out which direction we are going in
						/// 

						/// Player is playing up the board
						/// computer is playing down
						/// 
						if( board.PlayerIsLight == true )
						{
							DraughtsSquare tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowLeft( square.Identifier ) ];

							if( tempSquare != null )
							{
								/// valid square
								/// 
								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 );
											}
										}
									}
								}
							}

							tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( square.Identifier ) ];

							if( tempSquare != null )
							{
								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
								{
									if( tempSquare.IsOccupied == true 
										&& square.OccupyingName != tempSquare.OccupyingName )
									{
										DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( 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, checkSquare.Identifier );
											}
										}
									}
								}
							}

							if( square.IsKing == true )
							{
								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( square.Identifier ) ];

								if( tempSquare != null )
								{
									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
									{
										if( tempSquare.IsOccupied == true 
											&& square.OccupyingName != tempSquare.OccupyingName )
										{
											DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( 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, checkSquare.Identifier );
												}
											}
										}
									}
								}

								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( square.Identifier ) ];

								if( tempSquare != null )
								{
									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
									{
										if( tempSquare.IsOccupied == true 
											&& square.OccupyingName != tempSquare.OccupyingName )
										{
											DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( 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, checkSquare.Identifier );
												}
											}
										}
									}
								}
							}
						}
						else
						{
							/// player is playing down the board computer is playing up
							/// 

							DraughtsSquare tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( square.Identifier ) ];

							if( tempSquare != null )
							{
								if( tempSquare.IsOccupied == false )
								{
									DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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
								{
									if( tempSquare.IsOccupied == true 
										&& square.OccupyingName != tempSquare.OccupyingName )
									{
										DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( tempSquare.Identifier ) ];

										if( checkSquare != null && checkSquare.IsOccupied == false )
										{
											DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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, checkSquare.Identifier );
											}
										}
									}
								}
							}

							tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( square.Identifier ) ];

							if( tempSquare != null )
							{
								if( tempSquare.IsOccupied == false )
								{
									DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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
								{
									if( tempSquare.IsOccupied == true 
										&& square.OccupyingName != tempSquare.OccupyingName )
									{
										DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( tempSquare.Identifier ) ];

										if( checkSquare != null && checkSquare.IsOccupied == false )
										{
											DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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, checkSquare.Identifier );
											}
										}
									}
								}
							}

							if( square.IsKing == true )
							{
								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowLeft( square.Identifier ) ];

								if( tempSquare != null )
								{
									if( tempSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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
									{
										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", true, 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 );
												}
											}
										}
									}
								}

								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( square.Identifier ) ];

								if( tempSquare != null )
								{
									if( tempSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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
									{
										if( tempSquare.IsOccupied == true 
											&& square.OccupyingName != tempSquare.OccupyingName )
										{
											DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( tempSquare.Identifier ) ];

											if( checkSquare != null && checkSquare.IsOccupied == false )
											{
												DraughtsPiece piece = new DraughtsPiece( square.Identifier, "COMPUTER", true, 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, checkSquare.Identifier );
												}
											}
										}
									}
								}
							}
						}

						if( pattern.Count > 0 )
						{
							availablePatterns.AddPattern( pattern );
						}
					}
					else /// this is a player piece ( Player is on square == true )
					{
						/// player is playing up the board
						/// computer is playing down
						/// 
						if( board.PlayerIsLight == true )
						{
							DraughtsSquare tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( square.Identifier ) ];

							if( tempSquare != null )
							{
								/// valid square
								/// 
								if( tempSquare.IsOccupied == false )
								{
									DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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.GetIdentifierAboveLeft( tempSquare.Identifier ) ];

										if( checkSquare != null && checkSquare.IsOccupied == false )
										{
											DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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, checkSquare.Identifier );
											}
										}
									}
								}
							}

							tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( square.Identifier ) ];

							if( tempSquare != null )
							{
								if( tempSquare.IsOccupied == false )
								{
									DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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
								{
									if( tempSquare.IsOccupied == true 
										&& square.OccupyingName != tempSquare.OccupyingName )
									{
										DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( tempSquare.Identifier ) ];

										if( checkSquare != null && checkSquare.IsOccupied == false )
										{
											DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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, checkSquare.Identifier );
											}
										}
									}
								}
							}

							if( square.IsKing == true )
							{
								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowLeft( square.Identifier ) ];

								if( tempSquare != null )
								{
									if( tempSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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
									{
										if( 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, "PLAYER", true, 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, checkSquare.Identifier );
												}
											}
										}
									}
								}

								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( square.Identifier ) ];

								if( tempSquare != null )
								{
									if( tempSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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
									{
										if( square.OccupyingName != tempSquare.OccupyingName )
										{
											DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( tempSquare.Identifier ) ];

											if( checkSquare != null && checkSquare.IsOccupied == false )
											{
												DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", true, 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, checkSquare.Identifier );
												}
											}
										}
									}
								}	
							}			
						}
						else
						{
							/// player is playing down the board
							/// 

							DraughtsSquare tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowLeft( square.Identifier ) ];

							if( tempSquare != null )
							{
								if( tempSquare.IsOccupied == false )
								{
									DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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
								{
									DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowLeft( tempSquare.Identifier ) ];

									if( checkSquare != null && checkSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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, checkSquare.Identifier );
										}
									}
								}
							}

							tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( square.Identifier ) ];

							if( tempSquare != null )
							{
								if( tempSquare.IsOccupied == false )
								{
									DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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
								{
									DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierBelowRight( tempSquare.Identifier ) ];

									if( checkSquare != null && checkSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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, checkSquare.Identifier );
										}
									}
								}
							}

							if( square.IsKing == true )
							{
								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( square.Identifier ) ];

								if( tempSquare != null )
								{
									if( tempSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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
									{
										DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveLeft( tempSquare.Identifier ) ];

										if( checkSquare != null && checkSquare.IsOccupied == false )
										{
											DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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, checkSquare.Identifier );
											}
										}
									}
								}

								tempSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( square.Identifier ) ];

								if( tempSquare != null )
								{
									if( tempSquare.IsOccupied == false )
									{
										DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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
									{
										DraughtsSquare checkSquare = ( DraughtsSquare )board.GetHashTable[ board.GetIdentifierAboveRight( tempSquare.Identifier ) ];

										if( checkSquare != null && checkSquare.IsOccupied == false )
										{
											DraughtsPiece piece = new DraughtsPiece( square.Identifier, "PLAYER", 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, checkSquare.Identifier );
											}
										}
									}
								}
							}
						}

						if( pattern.Count > 0 )
						{
							availablePatterns.AddPattern( pattern );
						}
					}
				}
			}
		}