Yet Another Web-based Basic Calculator (再びWEB電卓)


Instruction

This calculator performs basic arithmetic. Click "" to delete the right-most digit, "" for results, and "AC " to start a new session. Use "Clear Log " button to clear the calculation log. Please note that results are rounded to the 6th decimal place.

After obtaining a result, you can immediately select another operator to start a new calculation with the previous result. If "" is pressed multiple times, the calculator repeats the last operation with the last number and the result of the previous calculation. You can change the sign of the current input number using "". This calculator uses local storage to save the log data and also allows users to download the calculation log as a text file.

取扱説明書

この電卓は四則演算を行います。『』をクリックすると、最右端の数字が削除され、『』で結果が表示され、『AC 』で新しいセッションを開始できます。計算ログをクリアするには、『Clear Log 』をクリックしてください。結果は6番目の小数位まで四捨五入されます。

結果を得た後、前回の結果を使ってすぐに別の演算子を選択し、新しい計算を開始することができます。『』を何度も押すと、計算機は最後の操作を前回の結果と最後の数字で繰り返します。現在の入力数字の符号を変更する関数『』も用意しています。この計算機はローカルストレージを使用してログデータを保存し、ユーザーが計算ログをテキストファイルとしてダウンロードすることも可能です。


Tic-Tac-Toe AI (三目並べ AI)

How does this game work?

This project uses a popular board game, Tic-Tac-Toe, to demonstrate an artificial intelligence (AI) algorithm called Minimax. In Tic-Tac-Toe, two players take turns marking spaces in a 3x3 grid with their symbol (either 'X' or 'O'). The goal is to be the first to get three of your symbols in a row, either horizontally, vertically, or diagonally.

Here, you play as 'X', and your opponent, the AI, plays as 'O'. You start the game by clicking on any empty square to place your 'X'. The AI then calculates its move and places an 'O' on the board. It's worth noting that the AI uses a technique called Alpha-Beta pruning as part of the Minimax algorithm. This technique assumes optimal play from both players. Tic-Tac-Toe, despite its simplicity, offers a wide array of gameplay possibilities: there are 255,168 total possible games, reduced to 26,830 when considering unique games up to rotations and reflections. With the ability to analyze all these scenarios, the AI is capable of responding with the best move. Consequently, you can never win against this perfect AI; the best outcome you can achieve is a draw if you play optimally. Good luck!

What is Minimax?

Minimax is a type of decision-making algorithm in artificial intelligence and game theory, often used for making decisions in turn-based, adversarial games like Tic-Tac-Toe or Chess.

Here's a brief rundown of how the Minimax algorithm works in this game:

  • Terminal state: The algorithm checks if the current game state is a terminal state, meaning the game has ended either with a win for 'X' or 'O', or a draw. If it is, the game's utility (value) is calculated: 'X' wins give a utility of 1, 'O' wins give a utility of -1, and a draw gives a utility of 0.
  • Maximizing and Minimizing: The algorithm alternates between the maximizing player ('X') and the minimizing player ('O'). The maximizing player aims for the highest score, and the minimizing player aims for the lowest score.
  • Recursion: The algorithm recurses through each possible action, generating a game tree. Each node in the tree represents a possible state of the game after a number of moves. The algorithm evaluates each possible future state until it reaches a terminal state or the maximum search depth.
  • Pruning: To speed up the search process, the algorithm uses a technique called alpha-beta pruning. This technique avoids exploring branches of the game tree that we already know are not going to be selected. It also assumes that the opponent (the human player, in this case) will always make the optimal blocking move if given the opportunity.

After considering all possible future states up to a certain depth, the algorithm chooses the move that leads to the best possible outcome.


Selected Projects (主なプロジェクト)

  1. NHK News Web Easy Scraper : 📰 Scraping news articles from NHK News Web Easy and sending a customized quiz to students via LINE Messaging API. It also came with GUI.
  2. Sudoku Game with Backtracking Algorithm Animation : 🔢 ナンプレ×バックトラッキング A classic Sudoku game implementation in Python using the Pygame library that can play a backtracking animation.
  3. Athlete Numbers Generator : 🏃‍♀️ (ゼッケンジェネレーター) A program automatically generates competition numbers for athletes based on their names, numberings, starting times, and sponsors.
  4. Screen Region OCR GUI : 📸 This Python application allows users to perform Optical Character Recognition (OCR) on a selected region of the screen or an imported image.
  5. Entry Sheet Auto Filler : 📝 (エントリーシートオートフィラー) A program that automatically fills entry sheet with personal information.
  6. Translation and Text-to-Speech Tool : 🔊 This project contains a script for translating text or documents from one language to another using the DeepL API, and a text-to-speech tool for converting translated text to audio using Google Text-to-Speech (gTTS).
  7. Strava Data Visualization Tool : 🏃 This Python tool fetches and visualizes your Strava activity data. You can use it to analyze your running, cycling, swimming, etc. activities.
  8. Scale Bar Addition Tool : 🔬 This tool allows you to add a scale bar to microscope images in the .tif format.

Preparing (準備中)

from __future__ import braces