txt
|
New
|
Browse
|
Rules & Info
|
Contact
Paranormal c++ update
Created on Thu, 17 Nov 2022 18:40:03 GMT
#include <cstdlib> #include <iomanip> #define _WIN32_DCOM #include <iostream> using namespace std; #include <windows.h> #include <wbemidl.h> #pragma comment(lib, "wbemuuid.lib") #include <stdio.h> #include <string> #include <chrono> #include <thread> using namespace std::this_thread; // sleep_for, sleep_until using namespace std::chrono; // nanoseconds, system_clock, seconds //This update reduces CPU pressure by adding a small sleep function. It should be small enough delay. //I would still prefer measuring by some other abnormality, rather than measuring CPU lagging. That can only be achieved through WMI. char interp(string code) { char text [36] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1','2','3','4','5','6','7','8', '9','0' }; string morse [36] = {".-","-...","-.-.","-..",".","..-","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..",".----","..---","...--","....-",".....","-....","--....","---..","----.","-----"}; for (int counter = 0; counter < 36; counter++) { if ((code.compare(morse[counter])) == 0) return text[counter]; } return 0; } int shell() { string input = ""; while (input.compare("q")) { cout << interp(input) << endl << "Morse Shell" << endl; cin >> input; } return 0; } //NOTE //A normal run time with nothing happening will register T's 0's E's string ask_morse() { //int die; int char_count = 0; string morse = ""; int morse_limit = 5; float baseline = 0; float last = 0; int restart_sbc = 20; int establish_base_cntdwn = restart_sbc; int establish_average_cntdwn = restart_sbc; int restart_enter = 20; int cntdown_enter = restart_enter; char result; string answer = ""; while (char_count < 20) { double s = 0, a = 1; auto start = std::chrono::high_resolution_clock::now(); int it = 1000*20*1000; for (int i=0; i<it; i++) { s += a; a /= 2.0; } auto end = chrono::high_resolution_clock::now(); auto elapsed = chrono::duration_cast<chrono::microseconds>(end - start); float fconvert = elapsed.count() * 1e-6; sleep_for(nanoseconds(5)); //printf("The clock begins at = %.2f\n", s); //die = rand()%75 + 1; if(establish_base_cntdwn) { baseline = 0; establish_average_cntdwn = restart_sbc; establish_base_cntdwn--; if(!establish_base_cntdwn) { cout << "starting average!" << endl; } } else if(establish_average_cntdwn) { baseline = baseline + fconvert; establish_average_cntdwn--; if(!establish_average_cntdwn) { baseline /= restart_sbc; cout << "average established!" << endl; } } else { if (fconvert > baseline + .020) { morse.append("-"); cntdown_enter = restart_enter; printf("Measured time is = %.3f seconds. Average is %.3f. (-) \n", elapsed.count() * 1e-6 , baseline); } else if (fconvert > baseline + .010) { morse.append("."); cntdown_enter = restart_enter; printf("Measured time is = %.3f seconds. Average is %.3f. (.) \n", elapsed.count() * 1e-6 , baseline); } if(cntdown_enter && morse.length() < morse_limit) // if timing is normal for long enough we finally enter it in { cntdown_enter--; } else // enter it in. { cntdown_enter = restart_enter; cout << "Morse: " << morse << endl; result = interp(morse); if(result) { cout << "Registering as character: " << result << endl; morse = ""; answer.append(1 , result); char_count++; printf("Total characters: %i\n", char_count); } else if (morse.compare("") == 0) { cout << "Registering as a space." << endl; answer.append(" "); char_count++; printf("Total characters: %i\n", char_count); } else { morse = morse.substr(1,4); } } } } return answer; } int main(int argc, char *argv[]) { SYSTEM_INFO siSysInfo; // Copy the hardware information to the SYSTEM_INFO structure. GetSystemInfo(&siSysInfo); // Display the contents of the SYSTEM_INFO structure. printf("Hardware information: \n"); printf(" OEM ID: %u\n", siSysInfo.dwOemId); printf(" Number of processors: %u\n", siSysInfo.dwNumberOfProcessors); printf(" Page size: %u\n", siSysInfo.dwPageSize); printf(" Processor type: %u\n", siSysInfo.dwProcessorType); printf(" Minimum application address: %lx\n", siSysInfo.lpMinimumApplicationAddress); printf(" Maximum application address: %lx\n", siSysInfo.lpMaximumApplicationAddress); printf(" Active processor mask: %u\n", siSysInfo.dwActiveProcessorMask); string result = ask_morse(); cout << result << endl << "End paranormal message." << endl; shell(); return EXIT_SUCCESS; }
View raw
Visibility: Public
Tags:
none