Skip to content

Commit

Permalink
[Auto-format code on push]
Browse files Browse the repository at this point in the history
  • Loading branch information
format.yml committed Jul 2, 2023
1 parent d03428e commit ce4f406
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
## [1.0.1](https://github.com/mrdcvlsc/minimax-tic-tac-toe/compare/v1.0.0...v1.0.1) (2023-07-01)


### Bug Fixes

* fixed depth input possibly going undefined in the web app ([95f6103](https://github.com/mrdcvlsc/minimax-tic-tac-toe/commit/95f61036d881bf09b94a99fa9e7922356ca1275b))
- fixed depth input possibly going undefined in the web app ([95f6103](https://github.com/mrdcvlsc/minimax-tic-tac-toe/commit/95f61036d881bf09b94a99fa9e7922356ca1275b))

# 1.0.0 (2023-07-01)

Expand Down
24 changes: 11 additions & 13 deletions public/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// =================== html initialization ===================

const PIECE = [' ', '✕', '◯'];
const INVALID = 0, DRAW = 0, COMPUTERS = '0';
const INVALID = 0,
DRAW = 0,
COMPUTERS = '0';

const BOARD = document.querySelector('.board');
const SELECT_GRID = document.querySelector('.grid-size');
Expand Down Expand Up @@ -31,13 +33,11 @@ SELECT_PLAYER.addEventListener('change', () => {
if (selectedPlayer === 1) {
setNewGame('New game, both computer playing');
} else if (selectedPlayer === 2) {
setNewGame('New game, you\'re playing as X');
setNewGame("New game, you're playing as X");
} else {
setNewGame('New game, you\'re playing as O');
setNewGame("New game, you're playing as O");

const moves = Game.computerAutoPlay(
(INPUT_DEPTH.value) ? Number(INPUT_DEPTH.value) : 0
);
const moves = Game.computerAutoPlay(INPUT_DEPTH.value ? Number(INPUT_DEPTH.value) : 0);

for (let move of moves) {
// works but instantanously, not as intended,
Expand Down Expand Up @@ -77,9 +77,9 @@ SELECT_GRID.addEventListener('change', () => {

setNewGame(
'The depth has been optimized in relation to the grid value to ' +
'improve calculation speed. You can easily adjust the depth setting, ' +
'but keep in mind that higher values for "depth and grid" will ' +
'increase the move time of the computer and will use more resources.'
'improve calculation speed. You can easily adjust the depth setting, ' +
'but keep in mind that higher values for "depth and grid" will ' +
'increase the move time of the computer and will use more resources.'
);
});

Expand All @@ -103,9 +103,7 @@ function setNewGame(msg = '') {
DISPLAY_MSG.style.color = 'white';

if (SELECT_PLAYER.value === COMPUTERS) {
const computerMoves = Game.computerAutoPlay(
(INPUT_DEPTH.value) ? Number(INPUT_DEPTH.value) : 0
);
const computerMoves = Game.computerAutoPlay(INPUT_DEPTH.value ? Number(INPUT_DEPTH.value) : 0);

for (let move of computerMoves) {
// works but instantanously, not as intended,
Expand All @@ -127,7 +125,7 @@ function generateCells() {
for (let j = 0; j < Game.grid; ++j) {
const square = document.createElement('span');
square.className = 'cell';
square.style.animationDelay = `${(i * 0.125) + (j * 0.125) + 0.125}s`;
square.style.animationDelay = `${i * 0.125 + j * 0.125 + 0.125}s`;

square.addEventListener('click', () => makeMove(i, j));

Expand Down
14 changes: 9 additions & 5 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
}

@keyframes animate-fade {
0% { opacity: 0; }
100% { opacity: 1; }
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

.header {
Expand Down Expand Up @@ -48,7 +52,8 @@ body {
animation-fill-mode: backwards;
}

.new-game, .message {
.new-game,
.message {
animation-duration: 2s;
animation-delay: 2s;
animation-name: animate-fade;
Expand Down Expand Up @@ -192,7 +197,6 @@ a {
}
}


select {
font-size: 1em;
}
}

0 comments on commit ce4f406

Please sign in to comment.