Skip to content

Commit

Permalink
improve ux
Browse files Browse the repository at this point in the history
  • Loading branch information
mac authored and mac committed Oct 5, 2024
1 parent 83c0ee2 commit 24b4661
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 239 deletions.
4 changes: 4 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public/
third_party/
assets/
dist/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 iFwu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 象棋棋盘识别与分析系统

这是一个在线象棋棋盘识别与分析系统,可以从上传的图片中识别出象棋棋局,并提供最佳走法分析。

## 在线演示

您可以在这里体验本系统:[象棋棋盘识别与分析](https://ifwu.github.io/xiangqi-analysis/)

## 功能特点

- 棋盘识别:从上传的图片中自动识别象棋棋盘和棋子位置
- FEN 生成:根据识别结果生成 FEN(Forsyth–Edwards Notation)字符串
- 最佳走法分析:使用象棋引擎分析当前局面,给出最佳走法建议
- 走棋模拟:可以按照建议的最佳走法进行模拟,查看局面变化
- 中文走法表示:将走法转换为中文表示,方便理解
- 响应式设计:适配不同尺寸的设备屏幕

## 技术栈

- 前端框架:Preact
- 图像处理:OpenCV.js
- 象棋引擎:Pikafish(WebAssembly 版本)
- 构建工具:Vite
- 包管理器:pnpm
- 部署:GitHub Pages

## 本地开发

1. 克隆仓库:

```
git clone https://github.com/your-username/xiangqi-analysis.git
cd xiangqi-analysis
```

2. 安装依赖:

```
pnpm install
```

3. 启动开发服务器:

```
pnpm dev
```

4. 在浏览器中打开 `http://localhost:5173` 查看应用

## 构建和部署

1. 构建项目:

```
pnpm build
```

2. 部署到 GitHub Pages:

```
pnpm deploy
```

注意:本项目使用 GitHub Actions 进行自动部署。每次推送到主分支时,都会触发构建和部署流程。

## 项目结构

- `src/`: 源代码目录
- `components/`: React 组件
- `chessboard/`: 棋盘识别和分析相关的模块
- `public/`: 静态资源目录
- `vite.config.ts`: Vite 配置文件
- `.github/workflows/`: GitHub Actions 工作流配置

## 贡献

欢迎提交 Issues 和 Pull Requests 来改进这个项目!

## 许可证声明

本项目使用 MIT 许可证。

本项目使用了 [Pikafish](https://github.com/official-pikafish/Pikafish) 象棋引擎,该引擎采用 GNU General Public License v3.0 (GPL-3.0) 许可证。Pikafish 的版权归其原作者所有。

本项目仅调用 Pikafish 引擎,并未对其进行修改。使用本项目不要求您的应用程序遵守 GPL-3.0 许可证。但是,如果您计划重新分发包含 Pikafish 的完整应用程序,请确保遵守 GPL-3.0 许可证的相关规定,包括提供源代码访问和适当的许可声明。

完整的 GPL-3.0 许可证文本可在 [此处](https://www.gnu.org/licenses/gpl-3.0.en.html) 查看。

使用本项目时,请确保理解并遵守相关的许可条款。如有疑问,建议咨询法律专业人士。
15 changes: 11 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<!doctype html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="description" content="在线象棋棋盘识别与分析系统,提供棋局识别、FEN生成、最佳走法分析等功能。" />
<meta name="keywords" content="象棋,棋盘识别,象棋分析,FEN,最佳走法,中国象棋" />
<meta name="author" content="@iFwu" />
<meta name="theme-color" content="#4a4a4a" />
<meta property="og:title" content="象棋棋盘识别与分析系统" />
<meta property="og:description" content="在线象棋棋盘识别与分析系统,提供棋局识别、FEN生成、最佳走法分析等功能。" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://ifwu.github.io/xiangqi-analysis/" />
%VITE_UMAMI_SCRIPT%
<title>象棋分析</title>
<title>象棋棋盘识别与分析系统 | 在线象棋分析工具</title>
</head>
<body>
<div id="app"></div>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"vite": "^5.4.8"
},
"packageManager": "[email protected]",
"homepage": "https://ifwu.github.io/xiangqi-analysis/"
"homepage": "https://ifwu.github.io/xiangqi-analysis/",
"license": "MIT"
}
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function App() {
height: number;
}>();
// 从 localStorage 加载初始深度值
const initialDepth = Number(localStorage.getItem('depth')) || 15;
const initialDepth = Number(localStorage.getItem('depth')) || 14;
const [depth, setDepth] = useState(initialDepth);

// Initialize OpenCV and Chess Engine
Expand Down Expand Up @@ -295,7 +295,11 @@ export function App() {
</div>
</main>
<footer>
<p>© 2023 象棋棋盘识别与分析系统</p>
<p>
© 2024 象棋棋盘识别与分析系统 |
Powered by <a href="https://github.com/official-pikafish/Pikafish"> Pikafish</a>&nbsp;|&nbsp;
<a href="https://github.com/iFwu/xiangqi-analysis">GitHub 源码仓库</a>
</p>
</footer>
</>
);
Expand Down
Loading

0 comments on commit 24b4661

Please sign in to comment.