分享和讨论Javascript相关的话题
回复
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

當點擊tool-edit處於編輯狀態時,兵卒的擺放需要加上限定,y軸不能低於卒林線,當處於y軸卒林線或往前一步時,只能處於x軸為0、2、4、6、8的線上。同時,當編輯完成時,行動方不能立即吃到對方的將或帥。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

一種新的數據格式:

分支:@…&…&…$

省略最後的$

開局可以是i或…/…/…/…&-&-0&1
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

改進:
當點擊tool-edit處於編輯狀態時:

一,為edit-comment-item和ejceespbmini-container的父元素添加className,把它們的style寫到css中。調整手機端的css,使這四個元素一直完整居中顯示。當手機端屏寬大到使.ejceescomment的長寬比小於0.5時,應使這四個元素横向並排顯示。ejceesrecord內的十二個棋子也應一直都能完整顯示。

二,在點擊edit-palette-item時,之前是改border,現在把border去掉,改為「stroke: white; stroke-width: 2」。在生成時,把裡面的use中的stroke屬性去掉。

三,在生成.ejceespbmini時,如果rotate的值改變,則它內部的棋子位置也將改變。在點擊tool-rotate時,也會影響到它。

四,兵卒的擺放增加限制。紅兵不能擺到y軸大於6的地方,如果擺到y軸為6和7時,x軸只能在0、2、4、6、8上。黑卒不能擺到y軸小於3的地方,如果擺到y軸為3和4時,x軸只能在0、2、4、6、8上。

五,將帥的擺放增加限制。當擺放完成點擊confirm時,要檢查行動方下一步是否可以直接吃到將,或者行動方下一步棋是否被困斃,以及將帥是否照面。如有,則alert提示不可完成。

六,ejceesoutput的文字提示。當進入編輯狀態時,當選取到棋子時,都應有長留提示。當放上棋子時,當點擊右方選項時,當confirm檢查不通過時,都要有短時提示。

七,進入編輯狀態時,隱藏.ejceesstep,當退出編輯狀態時才顯示。

只需給出所要修改的地方,所有的代碼和注釋都要使用英文。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

geminiEditMode.7z
(70.69 KiB) 已下载 101 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

代码: 全选

**「Game Start」比較好,而且明顯更自然、更常用。**

### 為什麼不是「Game Begin」?
- **「Game Begin」聽起來不自然**:英文母語者很少(幾乎從來不)這樣說或寫在遊戲介面裡。它聽起來像非母語者的直譯,語法上雖然沒錯,但不夠口語化或遊戲風格。常見的類似表達是「Let the game begin!」(這是成語,用在比賽或表演開始時),而不是單純當作標題或按鈕。
- **「Game Start」是遊戲業界標準**:尤其在街機、復古遊戲、日式遊戲(很多日本遊戲直譯成英文時就是這樣)、Steam、itch.io 等平台上,到處都是「Game Start Screen」「Game Start Button」「Press to Game Start」。設計師、開發者、UI 素材庫(Pinterest、Shutterstock、Dribbble)幾乎都用這個詞。

### 實際遊戲例子(常見用法)
- 老街機或格鬥遊戲:**GAME START**(例如《Street Fighter》系列常見)
- 現代遊戲主選單:**Start Game** 或 **Game Start**
- 按鈕常見寫法:**Start** / **New Game** / **Game Start**

如果你要做遊戲 UI 或翻譯:
- **最推薦**:**Game Start**(直接、簡潔、玩家一看就懂)
- **更自然按鈕版**:**Start Game**(英文母語遊戲最常用)
- **敘述版**:**The game begins now** 或 **Let the games begin!**(比較有戲劇性)

總結:**選「Game Start」準沒錯**,它就是遊戲圈的慣用語,「Game Begin」會讓人覺得有點怪怪的。如果你是在做特定遊戲類型(例如日式 RPG 或手機遊戲),我可以再幫你看更多範例!
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

改進:
一,在編輯狀態中,左邊的十二個棋子的父元素,即edit-pallete-grid,要垂直居中。右邊的edit-comment-grid內的四個元素,要始終是上面兩個下面兩個。

二,當處於編輯狀態時,應長時間顯示編輯模式的文字提示。如果isTile0Selected===true,則提示文字應長時間為:「Edit Mode: Select a piece to place or move.」,如果isTile0Selected===true,則提示文字應長時間為:「Edit Mode: Select a piece to replace or delete.」。

三,當處於編輯評論狀態時,應長時間顯示「Edit comment.」。「選擇範圍狀態」也要長時間顯示「Select range of the steps.」以及自動播放時也要長時間顯示提示文字直到播放停止。其它功能在點擊後,短暫顯示提示文字後回到當前狀態所要顯示的提示文字。(把英文潤色下使之更符合一般的英文表達。

只需給出所要修改的地方,所有的代碼和注釋都應使用英文。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

geminiPrompt.7z
(100.86 KiB) 已下载 92 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

代码: 全选

.edit-comment-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-content: center;
  align-items: center;
  align-content: center;
  width: 100%;
  height: 100%;
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
}

.edit-comment-item, .ejceespbmini-container {
  width: 100%;
  aspect-ratio: 1;
  cursor: pointer;
  box-sizing: border-box;
}


<div class="edit-comment-grid">
	<svg class="edit-comment-item"></svg>
	<div class="ejceespbmini-container">
		<svg></svg>
	</div>
	<svg class="edit-comment-item"></svg>
	<svg class="edit-comment-item"></svg>
</div>

當寬度夠寬時,它們能撐開寬度,但高度不夠時,為何做不到子元素高度隨父素的高度變化並盡量撐開高度?

https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

終於攻克難題了,把四個按鈕保持1:1比例,再按父元素高寬中最小的鋪滿:

https://ejsoon.vip/wp-content/uploads/2 ... 99961.html
附件
ejcees20260324edit99961.7z
(38.22 KiB) 已下载 52 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

改進:
當進入編輯狀態時,在x軸為0、2、4、6、8上,不能有兩個兵同時擺到x軸相同、y軸為6和7的坐標上,也不能有兩個卒同時擺到x軸相同, y軸為3和4的坐標上。

例如有一個紅兵處於「2,6」的位置,則「2,7」不能再放置另一個紅兵。

只需給出要修改的地方,所有的代碼和注釋都要使用英文。


grok

代码: 全选

```html
<!-- Modification 1: Add the following new helper function -->
<!-- Insert this function immediately after the existing "getLogicalCoords" function (search for: function getLogicalCoords(visX, visY) { ... }) -->

/**
 * Validates special pawn placement rules for edit mode only.
 * On files x = 0,2,4,6,8:
 *   - Red pawn 'P' cannot occupy both y=6 and y=7 on the same file.
 *   - Black pawn 'p' cannot occupy both y=3 and y=4 on the same file.
 * This prevents two pawns of the same color from being placed simultaneously
 * on the forbidden pair of rows for that file.
 * @param {string} pieceChar - The piece character ('P' or 'p')
 * @param {number} logX - Logical x coordinate (0-8)
 * @param {number} logY - Logical y coordinate (0-9)
 * @returns {boolean} true if the placement is allowed
 */
function isValidPawnPlacement(pieceChar, logX, logY) {
    if (!isEditMode) {
        return true;
    }
    // Only special files (initial pawn files)
    const specialFiles = [0, 2, 4, 6, 8];
    if (!specialFiles.includes(logX)) {
        return true;
    }

    if (pieceChar === 'P') { // Red pawn
        if (logY === 6 || logY === 7) {
            const otherY = (logY === 6) ? 7 : 6;
            const existingId = tileMap.get(`${logX},${otherY}`);
            if (existingId && existingId.startsWith('P')) {
                return false;
            }
        }
    } else if (pieceChar === 'p') { // Black pawn
        if (logY === 3 || logY === 4) {
            const otherY = (logY === 3) ? 4 : 3;
            const existingId = tileMap.get(`${logX},${otherY}`);
            if (existingId && existingId.startsWith('p')) {
                return false;
            }
        }
    }
    return true;
}
```

```html
<!-- Modification 2: Insert the validation check in the edit-mode board click handler -->
<!-- Locate the SVG click handler (search for code that handles board clicks when isEditMode === true, -->
<!-- typically inside the DOMContentLoaded block where svgElement.addEventListener('click', ...) is defined, -->
<!-- or in the placePiece / palette placement logic). -->
<!-- Add the block below RIGHT BEFORE the actual placement or move logic executes. -->

// === INSERT THIS VALIDATION BLOCK HERE (edit-mode placement / move) ===
const targetPieceChar = selectedPalettePiece || (editPickedPieceId ? editPickedPieceId[0] : null);
if (targetPieceChar && (targetPieceChar === 'P' || targetPieceChar === 'p')) {
    if (!isValidPawnPlacement(targetPieceChar, logicalX, logicalY)) {
        setOutputText("Invalid pawn placement: cannot place two pawns of the same color on the same file at these rows.", true);
        return; // Block the placement/move
    }
}
// === END OF INSERTED BLOCK ===
```

**Summary of changes (all other code remains untouched):**
- Only the two sections above need to be added/modified.
- All comments and variable names are in English as required.
- The rule is enforced exclusively in edit mode and only for the specified pawn types and coordinates.
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

代码: 全选

改進:
一,增加一種數據格式「地址傳參」:

host#fen;comment+a0b0;comment+c1b2;comment@d3e6&f4g8$

host是當前網址。

#是錨點。

fen是開局信息,如「3aka3/9/9/4p1N2/4p1N2/3nR4/3r1c1R1/4Bp3/1n2K4/c1B6,b,-,-,0,1」,它後方的空格替換成了逗號,共有五個逗號。如果是INITIAL_FEN,則只用「i」來取代。

;comment是當前局面的評論,以;開頭,comment的內容用encodeURIComponent()編碼。

+是接下來的走法。

a0b0是引擎走法描述。

@…&…&…$是當存在分支時接下來的幾種走法,@為分支開始,$為分支結束,&為分支間隔。

例如「c1b2;comment@d3e6&f4g8$」指c1b2接下來有d3e6和f4g8兩種走法。

分支可以多層嵌套,比如c1b2;comment@d3e6+e3e4+d1i1@d3e6&f4g8$&f4g8$

最末尾的$將被省略,則在數量上@比$多1個。

二,當點擊tool-exp-txt時:

左方textarea的文字將被選中。

右方改為四個切換按鈕:中文棋譜,英文棋譜,引擎棋譜,地址傳參。

開始時是「中文棋譜」高亮。點擊其中一個就會高亮,並把左方textarea的內容替換為按鈕指示的內容,然後選中這些內容。

四個按鈕在垂直方向上平均分配間隔,水平居中。

只需給出要修改的地方,所有的代碼和注釋都要使用英文。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

這回gemini fast也想來跟pro一決雌雄。
附件
geminiproExportURL.7z
(69.89 KiB) 已下载 46 次
geminifast棋譜匯出.7z
(68.45 KiB) 已下载 45 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

grok不算太好用,但是也能用:
ejcees20260325editp99962.7z
(38.45 KiB) 已下载 68 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

之前匹配局面信息的正規表示式為:

代码: 全选

(/(?:position fen )?([a-zA-Z0-9/]+ [wb])/)
現在在局面信息可能包含「 1 - 0 1」,也可能不包含。例如:

代码: 全选

position fen rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w 1 - 0 1 moves h2e2 h9g7 h0g2 i9h9 i0h0 g6g5
改進這段代碼。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5786
注册时间: 2022年 11月 18日 17:36
联系:

Re: 將製作ejcees(中國象棋打譜程式)

帖子 ejsoon »

ejcees20260325uri9997

【重要更新】增加url傳參功能。

很可能這個就做完了。

https://ejsoon.vip/wp-content/uploads/2 ... i9997.html
附件
ejcees20260325uri9997.7z
(39.83 KiB) 已下载 47 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
回复
  • 相似主题
    回复总数
    阅读次数
    最新帖子

在线用户

正浏览此版面之用户: Bing [Bot] 和 4 访客