Exp No 1: Implementation of Toy Problems (Tic Tac Toe) : 8-Puzzle)
Exp No 1: Implementation of Toy Problems (Tic Tac Toe) : 8-Puzzle)
AIM:
To implement the two player Tic-Tac-Toe game in python
ALGORITHM:
1. We will make the board using dictionary in which keys will be the
location (i.e: top-left, mid-right, etc.) and initially it's values will be
empty space and then after every move we will change the value
according to player's choice of move.
2. We will have to print the updated board after every move in the game
and thus we will make a function in which we'll define the printBoard
function so that we can easily print the board every time by calling
this function.
3. Now we'll write the main function which has all the gameplay
functionality.
4. Now we will check if player X or O has won, for every move after 5
moves.
5. If neither X nor O wins and the board is full, we'll declare the result as
'tie'.
6. Now we have to change the player after every move.
7. Now we will ask if player wants to restart the game or not.
# plotting
fig, ax = plt.subplots(1,1,figsize=(10,5))
ax.scatter(x_train, y_train, s=10, label='train data')
ax.plot(x_test, x_test, ls='--', label='test data', color='green')
ax.plot(x_test, y_pred_without_dropout, label='predicted ANN - R2
{:.2f}'.format(r2_score(x_test, y_pred_without_dropout)), color='red')
ax.plot(x_test, y_pred_with_dropout, label='predicted ANN Dropout - R2
{:.2f}'.format(r2_score(x_test, y_pred_with_dropout)), color='black')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.legend()
ax.set_title('test data');
Stemming or Lemmatization:
a. Reduce each word to its root or base form to reduce the number of
unique words in the text.
b. Use a stemmer or lemmatizer to perform this task.
c. Stemming is a more aggressive method that can produce non-words,
while lemmatization preserves the meaning of the words.
Part-of-speech tagging:
a. Identify the part of speech (noun, verb, adjective, etc.) of each word in
the text.
b. Use a part-of-speech tagger to perform this task.
Parsing:
a. Analyze the grammatical structure of the text to understand the
relationship between words.
b. Use a parser to perform this task.
Feature extraction:
a. Identify relevant features in the text, such as keywords or phrases, that
can be used for further analysis.
b. Use techniques such as term frequency-inverse document frequency (TF-
IDF) or bag-of-words to extract these features.