# AI-homework **Repository Path**: WS3269864565/Gomoku ## Basic Information - **Project Name**: AI-homework - **Description**: 一个贝壳的AI-homeword,设计了一个五子棋的UI小程序,第一次尝试 - **Primary Language**: JavaScript - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-03-31 - **Last Updated**: 2026-04-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Gomoku (Five-in-a-Row Mini Program) A Five-in-a-Row game application based on WeChat Mini Program, featuring both human-vs-AI and online multiplayer modes. ## Project Introduction This is a learning-oriented Five-in-a-Row Mini Program designed primarily for learning and practicing WeChat Mini Program development technologies. The game includes the following core features: - **Human vs AI**: Play against the AI opponent - **Online Multiplayer**: Match with other players online - **Hint Function**: AI suggests the optimal move position ## Technology Stack - **Frontend**: WeChat Mini Program (WXML, WXSS, JavaScript) - **Backend**: WeChat Cloud Development (CloudBase) - Cloud Functions: Login, Matchmaking, Phone Number Retrieval - Cloud Database: User information, Room management ## Project Structure ``` gomoku-miniprogram/ ├── cloudfunctions/ # Cloud Functions │ ├── getPhoneNumber/ # Retrieve phone number │ ├── login/ # Login function │ └── match/ # Matchmaking logic ├── pages/ │ ├── home/ # Home page │ ├── index/ # Game main page (Human vs AI) │ └── online/ # Online multiplayer ├── utils/ │ ├── ai.js # AI core algorithm │ ├── board.js # Board utility functions │ ├── db.js # Database operations │ └── gameUI.js # Game UI rendering ├── app.js # Mini Program entry point ├── app.json # Mini Program configuration └── app.wxss # Global styles ``` ## Core Algorithms ### Board Validation - `isInside(row, col)` - Check if coordinates are within the board boundaries - `countDirection(row, col, dRow, dCol)` - Count consecutive pieces in a specified direction - `checkWin(row, col, player)` - Check if a player has won - `isBoardFull()` - Check if the board is completely filled ### AI Algorithm - `evaluatePoint(row, col)` - Evaluate the score of a potential move - `findBestMove()` - Find the optimal move position - `findHintMove()` - Find a hint move position Evaluation factors: - Number of connected pieces - Active three, active four, running four - Blocking opponent's active three or active four ## Usage Instructions 1. Import the project into WeChat Developer Tool 2. Configure the Cloud Development environment 3. Deploy the cloud functions 4. Compile and run ## Game Rules - 15×15 standard board - Black pieces move first - First player to form a line of five consecutive pieces wins ## Dependency Configuration Refer to the `package.json` files in each cloud function directory to install dependencies. ## License For learning purposes only.