Skip to content

This web application is Implementation of React tutorial (Tic-tac-toe), using React Hooks and TypeScript.

Notifications You must be signed in to change notification settings

y-bash/React-TicTacToe

Repository files navigation

Tic-tac-toe (React Hooks and TypeScript)

Implementation of React tutorial (Tic-tac-toe), using React Hooks and TypeScript. This application was bootstrapped with Create React App. The source code comments written in Japanese Language.

このアプリケーションは TypeScript と React Hooks による React チュートリアル (三目並べ) の実装です。 ツールチェーンとして Create React App が使われています。 ソースコードのコメントは日本語で記載されています。

Installation

In the project directory, you can install:

$ npm install

Usage

In the project directory, you can run:

$ npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

$ npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

Improvements

3 by 3 Grid

src/rules/Rules.ts

export type Piece = "O" | "X"
const PLAYERS: Piece[]  = ["O", "X"]
const COLS   : string[] = ["a", "b", "c"]
const ROWS   : string[] = ["1", "2", "3"]
const BINGO_LINES: number[][] = [
  [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6],
  [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6],
]

4 by 4 Grid

src/rules/Rules.ts

export type Piece = "O" | "X" | "H"
const PLAYERS: Piece[]  = ["O", "X", "H"]
const COLS   : string[] = ["a", "b", "c", "d"]
const ROWS   : string[] = ["1", "2", "3", "4"]
const BINGO_LINES: number[][] = [
  [ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9,10,11],
  [12,13,14,15], [ 0, 4, 8,12], [ 1, 5, 9,13],
  [ 2, 6,10,14], [ 3, 7,11,15], [ 0, 5,10,15],
  [ 3, 6, 9,12]
]

License

MIT

Author

y-bash

About

This web application is Implementation of React tutorial (Tic-tac-toe), using React Hooks and TypeScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published