Ai test

AI Tesrter

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/536280/1605576/Ai%20test.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

Tabs.AI = {
    tabOrder: 910,
    tabLabel: 'AI Assistant',
    tabDisabled: false,
    myDiv: null,
    inputDiv: null,
    outputDiv: null,

    init: function (div) {
        var t = Tabs.AI;
        t.myDiv = div;
        t.createMainDiv();
    },

    createMainDiv: function () {
        var t = Tabs.AI;
        var m = '<DIV class=divHeader align=center>AI Assistant</div>';

        m += '<div style="padding:10px;">';
        m += '<input type="text" id="aiInput" style="width:100%;" placeholder="Ask me a question...">';
        m += '<button id="aiButton" style="width:100%; margin-top:5px;">Get Answer</button>';
        m += '<div id="aiOutput" style="margin-top:10px; border:1px solid #888; padding:10px; min-height:100px;"></div>';
        m += '</div>';

        t.myDiv.innerHTML = m;
        t.inputDiv = ById('aiInput');
        t.outputDiv = ById('aiOutput');

        ById('aiButton').addEventListener('click', function () {
            t.getAnswer();
        });

        t.inputDiv.addEventListener('keypress', function (e) {
            if (e.key === 'Enter') {
                t.getAnswer();
            }
        });
    },

    getAnswer: function () {
        var t = Tabs.AI;
        var question = t.inputDiv.value.trim();

        if (question !== '') {
            // Basic question answering logic (replace with your AI)
            var answer = t.processQuestion(question);
            t.outputDiv.innerHTML = answer;
        }
    },

    processQuestion: function (question) {
        // This is a placeholder for your AI logic.
        // For now, it just returns canned responses.
        question = question.toLowerCase();

        if (question.includes('resources')) {
            return "Make sure to build farms and mines to get more resources.";
        } else if (question.includes('attack')) {
            return "Train more troops and upgrade your castle before attacking.";
        } else {
            return "I'm still learning. Please ask another question.";
        }
    }
};