Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsantelicesl committed Apr 5, 2024
2 parents 4e1304b + 484cf51 commit 5470df8
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions ai.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#include "game.cpp"
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

class Node
{
public:
int value;
vector<Node*> children;
vector<Node *> children;
int board[9];

Node(int *arr)
{
for (int i = 0; i < 9; i++)
{
this->board[i] = *(arr+i);
this->board[i] = *(arr + i);
}
}
void addChild(Node *child)
Expand All @@ -24,17 +26,43 @@ class Node
}
};

// A function that looks for every possible actions.
// Push back the possible actions as indexes into a vector
// Returns the vector.
vector<int> actions(int board[]){
vector<int> possible_actions;
for (int i = 0; i <= 8; i++){
if (board[i] == 0){
possible_actions.push_back(i);
}
}
return possible_actions;
}

// Returns the result of the board after the given action
//
//
int* result(int board[], vector<int> actions){
}

// Calculate the utility value of the current board state.
// Implement and return the utility value of the current board state.
// Returns 1 if 'X' wins, -1 if 'O' wins, and 0 for a draw or ongoing game.
int utility(char board){
int utility(int board[]){
char win = winner(board);
if (win == 'X')
return 1;
else if (win == 'O')
return -1;
else if (winner(board))
return 0;

}

// Perform the Minimax algorithm to determine the best move for the current player.
// Implement and return the optimal utility value for the current player.
// Takes the current board state as input.
float minimax(char board){
float minimax(int board[]){

}

Expand Down

0 comments on commit 5470df8

Please sign in to comment.