From 8cf2e4b32cd6e5ad04d28232a77de2cd3671ce5b Mon Sep 17 00:00:00 2001 From: ariqbasyar <ariqbasyar2@gmail.com> Date: Sun, 3 Jan 2021 18:13:55 +0700 Subject: [PATCH] improved README --- README.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9377ed6..15bd7e6 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,91 @@ # Tic Tac Toe -Nama: Muhammad Ariq Basyar +> This game can be played from this +[group's Front-end](https://gitlab.cs.ui.ac.id/pemfung-fun/frontend) or access +https://pemfung-fun.netlify.app/ + +Name: Muhammad Ariq Basyar NPM: 1806205110 -Serverless service untuk game Tic Tac Toe. +Serverless service for Tic Tac Toe board game. + +A regular game [Tic Tac Toe](https://en.wikipedia.org/wiki/Tic-tac-toe) with +board's size 3x3. This game is using +[minimax algorithm](https://en.wikipedia.org/wiki/Minimax) + +## How to play? + +1. You can choose either be the first move or second move(so the bot is the +first move). + +2. You can choose your weapon (either X or O) depends or your preference. + +3. Because of the best move for the first move is to choose any corner, this +bot's algorithm immediately choose the right bottom corner (value 256 in +binary) to reduce useless computation. + +4. Same as a regular tic tac toe game, your goal is to make best decision on +every move to get strike XXX or OOO (match with your weapon). + +5. Have fun and good luck! + +> Note: because i do not give any chance for opponent to win in the minimax +algorithm, by theory, every match is either draw or the bot is the winner. + +## How to run locally? + +> NOTE: i assumed [python](https://www.python.org/) and +[docker](https://www.docker.com/) is already installed on your machine. + +1. Of course, clone this project + + ```shell + git clone https://gitlab.cs.ui.ac.id/pemfung-fun/tic-tac-toe.git + ``` + +2. Install [aws-sam-cli](https://pypi.org/project/aws-sam-cli/) + + ```shell + pip install aws-sam-cli + ``` + +3. Build the project + + ```shell + make + ``` + +4. Unzip `build/function.zip` and move to project's root folder + + ```shell + unzip build/function.zip + ``` + +5. Run this [FaaS](https://en.wikipedia.org/wiki/Function_as_a_service) locally + + ```shell + sam local start-api --host 127.0.0.1 --port 3000 + ``` + + > see [the docs](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-start-api.html) + for more options. + +6. Now you can try to POST something like this + + ```shell + curl -v\ + -X POST 'http://127.0.0.1:3000'\ + -H 'Content-Type: application/json'\ + -d '{"next": "X", "board":[[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]]}' + ``` + +## Development Environment + +You can change the default value of `Access-Control-Allow-Origin` header on +[src/Lib.hs](src/Lib.hs) to whatever you want depends on your front-end's origin +[learn more about CORS](https://www.w3.org/wiki/CORS_Enabled). Example: -Sebuah game [Tic Tac Toe](https://en.wikipedia.org/wiki/Tic-tac-toe) dengan -besar board 3x3, didalamnya terdapat bot yang akan mengalahkan player dengan -algoritma [Minimax](https://en.wikipedia.org/wiki/Minimax) +```haskell +header = object ["Access-Control-Allow-Origin" .= ("*" :: String)] +``` -- GitLab