我的一群机器人朋友

· · 休闲·娱乐

预先通知:这里的内容不折射任何现实,如有雷同,纯属巧合

以前总是听说,在 OIer 中有着许多机器人。我本是不相信的。但在我****后,才发现这确实是事实。

众所周知,Edge有EdgeDrive,因此,我们可以猜测,对于人一定也有一个“BodyDrive”吧,在观察了一个疑似死循环的机器人 10^9 秒后,我发现了控制他的伪代码:(使用 C++ 呈现)

#include <bits/stdc++.h>
#include "BodyDriver.h"
#include "Base64.h"

#ifndef _WIN32
string ImpStr[10] = 
{
    "5YWl5a2m6ICD", 
    "5LiB77yI6YeN6K+777yJ",
    "6K6y6L+w5Lq6",
    "NTDlh6DliIY=",
    "5L+h5oGv5LiO5pyq5p2l",
};
#else
/*
>>> def a(x):
...     return base64.b64encode(base64.b64decode(x).decode('utf-8').encode('gbk'))
*/
string ImpStr[10] = 
{
    "yOvRp7+8", 
    "tqGjqNbYtsGjqQ==",
    "vbLK9sjL",
    "NTC8uLfW",
    "0MXPotPrzrTAtA==",
};
#endif

body Body;

int main()
{
    while(1)
    {
        pair<People, string> P;

        P = Body.ear.listen(); 

        bool Flag = false;
        for(int i = 0; i < 5; i++)
        {
            if(P.second.find(Decode(ImpStr[i])) != string::npos)
            {
                Flag = true;
                break;
            }
        }

        if(Flag == true)
        {
#ifndef _WIN32
            Body.mouth.say(Decode("5oiR5Yib5q275L2g"));
#else
            Body.mouth.say(Decode("ztK0tMvAxOM="));
#endif
            Body.arm.hit(P.first);
        }
        else
        {
            Body.mouth.say(reply(P.second));
        }
    }

    return 0;
}

还有另一个人,也符合这个特点,他的代码:

#include <bits/stdc++.h>
#include "BodyDriver.h"
#include "Base64.h"

using namespace std; 

#ifndef _WIN32
string ImpStr[10] = 
{
    "5YWl5a2m6ICD", 
    "5LiB77yI6YeN6K+777yJ",
    "6K6y6L+w5Lq6",
    "NTDlh6DliIY=",
    "5L+h5oGv5LiO5pyq5p2l",
};
#else
string ImpStr[10] = 
{
    "yOvRp7+8", 
    "tqGjqNbYtsGjqQ==",
    "vbLK9sjL",
    "NTC8uLfW",
    "0MXPotPrzrTAtA==",
};
#endif

body Body;

int main()
{
    srand(time(NULL));

    while(1)
    {
        pair<People, string> P;
        P = Body.ear.listen(); 
        Body.mouth.say(Decode(ImpStr[rand() % 5]));
    }

    return 0;
}

TPD:2025年8月11日的新机器人

#include <bits/stdc++.h>
#include "BodyDriver.h"
#include "Base64.h"

body Body;

int main()
{
    while(1)
    {
        pair<People, string> P;

        P = Body.ear.listen(); 
        Body.arm.hit(P.first);
    }

    return 0;
}

UPD2: 8.13 的新机器人

#include <bits/stdc++.h>
#include "BodyDriver.h"
#include "Base64.h"

body Body;

int main()
{
    srand(time(NULL));
    while(1)
    {
        pair<People, string> P;
        P = Body.ear.listen();
        string s; 
        int n = rand() % 1000;
        for(int i = 1; i <= n; i++)
        {
            s += rand() % 26 + 'a';
        }
        Body.mouth.say(s);
    }

    return 0;
}

阅读提示:如果你无法理解这篇文章,请理解一下 Decode() 函数,然后在理解一下 ImpStr 的内容。

如果你仍然无法理解,请加入以下头文件,然后编译运行:

Author: 豆包

Base64.h

#include <bits/stdc++.h>

using namespace std; 

string ch ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

static inline bool Is(unsigned char c)
{
    return (isalnum(c) || (c == '+') || (c == '/'));
}

string Decode(string str) // 部分代码参考 zhihu
{
    size_t in_len = str.size();
    int i = 0, j = 0, in_ = 0;
    unsigned char ch4[4], ch3[3];
    string ret;

    while (in_len-- && (str[in_] != '=') && Is(str[in_]))
    {
        ch4[i++] = str[in_];
        in_++;
        if (i == 4)
        {
            for (i = 0; i < 4; i++)
            {
                ch4[i] = ch.find(ch4[i]) & 0xff;
            }

            ch3[0] = (ch4[0] << 2) + ((ch4[1] & 0x30) >> 4);
            ch3[1] = ((ch4[1] & 0xf) << 4) + ((ch4[2] & 0x3c) >> 2);
            ch3[2] = ((ch4[2] & 0x3) << 6) + ch4[3];

            for (i = 0; i < 3; i++)
            {
                ret += ch3[i];
            }
            i = 0;
        }
    }

    if (i != 0)
    {
        for (j = 0; j < i; j++)
        {
            ch4[j] = ch.find(ch4[j]) & 0xff;
        }

        ch3[0] = (ch4[0] << 2) + ((ch4[1] & 0x30) >> 4);
        ch3[1] = ((ch4[1] & 0xf) << 4) + ((ch4[2] & 0x3c) >> 2);

        for (j = 0; j < i - 1; j++) 
        {
            ret += ch3[j];
        }
    }

    return ret;
}

BodyDriver.h

#include <bits/stdc++.h>
using namespace std;

struct People
{
    std::string name;  
    int id;
};

class Ear
{
    public:
        std::pair<People, std::string> listen();
};

class Mouth
{
    public:
        void say(const std::string& content);
};

class Arm
{
    public:
        void hit(const People& person);
};

class body
{
    public:
        Ear ear;    
        Mouth mouth; 
        Arm arm;     
};

std::string reply(const std::string& input);
std::pair<People, std::string> Ear::listen()
{
    static int counter = 0;
    People speaker;
    speaker.id = counter++;
    speaker.name = "Person_" + std::to_string(speaker.id);

    std::string content;
    std::cout << "\n[" << speaker.name << "] 说: ";
    std::getline(std::cin, content);

    return {speaker, content};
}

void Mouth::say(const std::string& content)
{
    std::cout << "[回应] " << content << std::endl;
}

void Arm::hit(const People& person)
{
    std::cout << "[动作] 对 " << person.name << " 执行击打动作" << std::endl;
}

std::string reply(const std::string& input)
{
    return "已收到: " + input;
}