Skip to content

Commit 4b65345

Browse files
committed
removed the tic tac toe
1 parent 1803365 commit 4b65345

File tree

6 files changed

+123
-43
lines changed

6 files changed

+123
-43
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
*.bin
99
*.elf
1010
*.s
11-
*.swp
11+
*.swp
12+
TIC_TAC_TOE/
13+
14+
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
2-
Please distribute this file with the SDL runtime environment:
3-
4-
The Simple DirectMedia Layer (SDL for short) is a cross-platform library
5-
designed to make it easy to write multi-media software, such as games
6-
and emulators.
7-
8-
The Simple DirectMedia Layer library source code is available from:
9-
https://www.libsdl.org/
10-
11-
This library is distributed under the terms of the zlib license:
12-
http://www.zlib.net/zlib_license.html
13-
1+
2+
Please distribute this file with the SDL runtime environment:
3+
4+
The Simple DirectMedia Layer (SDL for short) is a cross-platform library
5+
designed to make it easy to write multi-media software, such as games
6+
and emulators.
7+
8+
The Simple DirectMedia Layer library source code is available from:
9+
https://www.libsdl.org/
10+
11+
This library is distributed under the terms of the zlib license:
12+
http://www.zlib.net/zlib_license.html
13+

TIC_TAC_TOE/usr/share/doc/a/src/eg.c

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ SDL_Surface* surface=NULL;
1717

1818

1919
typedef struct {
20-
int board[3][3]; // 0 = empty, 1 = player1 (X), 2 = player2 (O)
21-
int currentPlayer;
20+
unsigned int board[3][3]; // 0 = empty, 1 = player1 (X), 2 = player2 (O)
21+
unsigned int currentPlayer;
2222
bool isRunning;
2323
} GameState;
2424

@@ -357,6 +357,79 @@ int main(int argc, char* args[]) {
357357
}
358358

359359

360+
void easyAi(GameState* GameState){
361+
int row,col;
362+
do{
363+
row=rand()%3;
364+
col=rand()%3;
365+
366+
}while(GameState->board[row][col]!=0);
367+
GameState->board[row][col]=GameState->currentPlayer;
368+
}
369+
370+
371+
void mediumAI(GameState* GameState) {
372+
int bestRow = -1, bestCol = -1;
373+
float bestScore = -1;
374+
375+
for (int i = 0; i < 3; i++) {
376+
for (int j = 0; j < 3; j++) {
377+
if (GameState->board[i][j] == 0) { // Empty cell
378+
float score = get_score(GameState, i, j);
379+
if (score > bestScore) { // Find the best score
380+
bestScore = score;
381+
bestRow = i;
382+
bestCol = j;
383+
}
384+
}
385+
}
386+
}
387+
388+
// Place AI move in the best position found
389+
if (bestRow != -1 && bestCol != -1) {
390+
GameState->board[bestRow][bestCol] = GameState->currentPlayer;
391+
}
392+
}
393+
394+
//get a min heap of the scores
395+
396+
float get_score(GameState* GameState, int row, int col) {
397+
float scr = 0;
398+
int player = GameState->currentPlayer;
399+
400+
// Check boundaries before accessing board elements
401+
if (row > 0 && GameState->board[row - 1][col] == player) scr++; // Top
402+
if (row < 2 && GameState->board[row + 1][col] == player) scr++; // Bottom
403+
if (col > 0 && GameState->board[row][col - 1] == player) scr++; // Left
404+
if (col < 2 && GameState->board[row][col + 1] == player) scr++; // Right
405+
406+
if (row > 0 && col > 0 && GameState->board[row - 1][col - 1] == player) scr++; // Top-left
407+
if (row > 0 && col < 2 && GameState->board[row - 1][col + 1] == player) scr++; // Top-right
408+
if (row < 2 && col > 0 && GameState->board[row + 1][col - 1] == player) scr++; // Bottom-left
409+
if (row < 2 && col < 2 && GameState->board[row + 1][col + 1] == player) scr++; // Bottom-right
410+
411+
return pow(scr, 0.5); // Square root of score
412+
}
413+
414+
415+
int aiChose(char choice[10]){
416+
if("easy"== tolower(choice)){
417+
return 1;
418+
}
419+
else if("hard "==tolower(choice))
420+
{
421+
return 2;
422+
423+
}
424+
else if("medium"==tolower(choice)){
425+
return 3;
426+
}
427+
else{
428+
printf("enter a valid choice");
429+
return 0;
430+
}
431+
}
432+
360433

361434
#ifdef _WIN32
362435
#include <windows.h>

TIC_TAC_TOE/usr/share/doc/src/button.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ int main() {
7575
return 0;
7676
}
7777

78+
79+
80+
81+
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
[Setup]
2-
AppName=My Tic-Tac-Toe Game
3-
AppVerName=My Tic-Tac-Toe Game Version 1.0 by AATHI S
4-
AppVersion=1.0
5-
DefaultDirName={pf}\MyTicTacToeGame
6-
DefaultGroupName=Tic-Tac-Toe Game
7-
OutputDir=userdocs:Inno Setup Output
8-
OutputBaseFilename=TicTacToeInstaller
9-
10-
[Files]
11-
[Files]
12-
; Only copy the file a.exe, don't recreate the full path structure
13-
Source: "a.exe*"; DestDir: "{app}"; Flags: ignoreversion
14-
Source: "SDL2.dll*"; DestDir: "{app}"; Flags: ignoreversion
15-
16-
; Copy all files from assets directory to resources subfolder inside the installation folder
17-
Source: "Z:/home/darkemperor/aathi/my-learnig-path-/TIC_TAC_TOE/usr/share/doc/assets\*"; DestDir: "{app}\resources"; Flags: ignoreversion recursesubdirs
18-
19-
; Copy the icon file, no extra folder structure
20-
Source: "app.ico"; DestDir: "{app}"; Flags: ignoreversion
21-
22-
[Icons]
23-
Name: "{group}\Tic-Tac-Toe Game"; Filename: "{app}\a.exe"; IconFilename: "{app}\app.ico"
24-
25-
[Run]
26-
Filename: "{app}\a.exe"; Description: "Launch Tic-Tac-Toe Game"; Flags: nowait postinstall skipifsilent
27-
1+
[Setup]
2+
AppName=My Tic-Tac-Toe Game
3+
AppVerName=My Tic-Tac-Toe Game Version 1.0 by AATHI S
4+
AppVersion=1.0
5+
DefaultDirName={pf}\MyTicTacToeGame
6+
DefaultGroupName=Tic-Tac-Toe Game
7+
OutputDir=userdocs:Inno Setup Output
8+
OutputBaseFilename=TicTacToeInstaller
9+
10+
[Files]
11+
[Files]
12+
; Only copy the file a.exe, don't recreate the full path structure
13+
Source: "a.exe*"; DestDir: "{app}"; Flags: ignoreversion
14+
Source: "SDL2.dll*"; DestDir: "{app}"; Flags: ignoreversion
15+
16+
; Copy all files from assets directory to resources subfolder inside the installation folder
17+
Source: "Z:/home/darkemperor/aathi/my-learnig-path-/TIC_TAC_TOE/usr/share/doc/assets\*"; DestDir: "{app}\resources"; Flags: ignoreversion recursesubdirs
18+
19+
; Copy the icon file, no extra folder structure
20+
Source: "app.ico"; DestDir: "{app}"; Flags: ignoreversion
21+
22+
[Icons]
23+
Name: "{group}\Tic-Tac-Toe Game"; Filename: "{app}\a.exe"; IconFilename: "{app}\app.ico"
24+
25+
[Run]
26+
Filename: "{app}\a.exe"; Description: "Launch Tic-Tac-Toe Game"; Flags: nowait postinstall skipifsilent
27+

build/.cmake/api/v1/reply/index-2025-02-24T14-54-10-0963.json renamed to build/.cmake/api/v1/reply/index-2025-03-05T16-31-47-0786.json

File renamed without changes.

0 commit comments

Comments
 (0)