Пример #1
0
		public DraughtsPiece( DraughtsPiece piece ) : base( piece )
		{
			LightPiece = piece.LightPiece;
			IsKing = piece.IsKing;
			arrayMoves = new ArrayList();
			Player = piece.Player;
		}
Пример #2
0
		public override void Load(XmlReader xmlReader)
		{
			while( xmlReader.Name != "MoveNumber" )
			{
				xmlReader.Read();
			}

			xmlReader.Read();

			nMoveNumber = Int32.Parse( xmlReader.Value );

			while( xmlReader.Name != "PatternID" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			xmlReader.Read();
			nPatternID = int.Parse( xmlReader.Value );

			bool bBreak = false;
			for( ;; )
			{
				xmlReader.Read();
				switch( xmlReader.NodeType )
				{
					case XmlNodeType.Element:
					{
						switch( xmlReader.Name )
						{
							case "DraughtsPiece":
							{
								DraughtsPiece temp = new DraughtsPiece();
								temp.Load( xmlReader );
								arrayGamePieces.Add( temp );
								break;
							}
							case "NumberOfTimesSeen": bBreak = true; break;
						}
					} break;
				}

				if( bBreak == true )
					break;
			}

			/// should be on Number of times seen but doesn't hurt to check
			if( xmlReader.Name != "NumberOfTimesSeen" )
				return;

			xmlReader.Read();
			nNumberOfTimesSeen = int.Parse( xmlReader.Value );

			while( xmlReader.Name != "NumberOfTimesSeenInWinningGame" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			xmlReader.Read();
			nNumberOfTimesSeenInWinningGame = int.Parse( xmlReader.Value );

			while( xmlReader.Name != "NumberOfTimesSeenInLosingGame" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			xmlReader.Read();
			nNumberOfTimesSeenInLosingGame = int.Parse( xmlReader.Value );

			while( xmlReader.Name != "EndingPattern" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			xmlReader.Read();
			if( xmlReader.Value == "True" )
				bIsEndingPattern = true;
			else
				bIsEndingPattern = false;

			while( xmlReader.Name != "Weighting" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			xmlReader.Read();
			nWeighting = int.Parse( xmlReader.Value );

			while( xmlReader.Name != "Response" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			while( xmlReader.Name != "ResponsePresent" )
			{
				xmlReader.Read();
				if( xmlReader.EOF == true )
					return;
			}

			xmlReader.Read();
			int nResponse = int.Parse( xmlReader.Value );

			if( nResponse != 0 )
			{
				bResponsePresent = true;
				bgpResponse = new BasicGamePiece();
				bgpResponse.Load( xmlReader );
			}

		}
Пример #3
0
		public bool AddMoveToPiece( DraughtsPiece piece, string move )
		{
			for( int i=0; i<GamePieces.Count; i++ )
			{
				if( piece.SquareIdentifier == ( ( DraughtsPiece )GamePieces[ i ] ).SquareIdentifier )
				{
					( ( DraughtsPiece )GamePieces[ i ] ).AddMove( move );
					return true;
				}
			}

			return false;
		}
Пример #4
0
		public bool IsPieceInPattern( DraughtsPiece piece )
		{
			for( int i=0; i<GamePieces.Count; i++ )
			{
				if( piece == ( DraughtsPiece )GamePieces[ i ] )
					return true;
			}

			return false;
		}
Пример #5
0
		public void AddGamePiece( DraughtsPiece piece )
		{
			GamePieces.Add( piece );
		}
Пример #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 );
						}
					}
				}
			}
		}