Overpowered

by gapty

First published

After repeated incidents of "overpowering", Twilight Sparkle writes a program to find the cause of the recuring problem.

After repeated incidents of "overpowering", Twilight Sparkle writes a program to find the cause of the recuring problem.


Written for the Science Fiction Contest II. Check out the other entries here.

Huge thanks to The Sleepless Beholder for prereading and PseudoBob Delightus for proofreading it!

Please be aware that the chapters with codes may have weird formatting on mobile view.

Act 1: about.txt

View Online

Since the acquisition of the geodes that channel Equestrian magic, fluctuating power levels have been observed, wherein each superpower activates unintentionally (colloquially called “being overpowered”). The previous theory of "overpowering through usage" has been refuted, as even without utilizing the geodes, the superpowers have been activated unintentionally.

This program has been developed to analyze the power levels of the geodes and identify the cause of the uncontrollability.

GeodeScanner.py

View Online

from Sensors import sensors
from Messenger import send_notification

class GeodeScanner:

"""
    A class for scanning and measuring the power levels of the different elements and their respective geodes.

    Attributes:
    - ELEMENTS: A list of the different elements to be scanned.
    - sensors: A dictionary containing lists of sensors for each element.
    - current_element: A string representing the currently scanned element.
    - current_value: A list representing each of the current sensor values.
    - geode_power: An integer representing the power level of the geode.
"""
    
    ELEMENTS = ['Honesty', 'Kindness', 'Laughter', 'Generosity', 'Loyalty', 'Empathy', 'Magic']

    def __init__(self):
        self.sensors = {}
        self.current_element = ""
        self.current_value = {element: 0 for element in self.ELEMENTS}
        self.geode_power = 0
        self.start_scan = False
        
        # Initialize sensors for each element
        for element in self.ELEMENTS:
            self.sensors[element] = Sensors(element)

    def stop_scanning(self):
        # Stops start_scanning
        self.start_scan = False

    def start_scanning(self):
        # Continuously scans geode elements for changes in power levels until stopped
        self.start_scan = True
        while self.start_scan:
            for element in self.ELEMENTS:
                value = self.sensors[element].get_value()
                if value != self.current_value[element]:
                    self.current_value[element] = value
                    self.current_element = element
                    self.measure_power()

    def measure_power(self):
        # Measures geode power level and calls function log_data()
        self.geode_power = self.sensors[self.current_element].get_value()
        self.log_data()

    def log_data(self):
        # Logs timestamp and geode’s power level to file. Sends notification to Element bearer
        log_file = open("Element_logs/" + self.current_element + ".txt", "a")
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
        log_file.write(timestamp + " Power: " + str(self.geode_power) + "\n")
        log_file.close()
        send_notification(self.current_element, "Your geode’s power level is now " + str(self.geode_power))
        send_notification(self.current_element, "Please log your current action for analysis")

analysis_report.docx

View Online

After conducting a two-week analysis of the collected data, the following conclusions regarding the geode's power levels were discovered:

More data and experiments are required to explain some aspects of the geode's power level, especially the interconnection between the geodes.

To keep “overpowering” in control, following actions are recommended:

The program has also been modified to issue a notification to the wearer when the measured value exceeds 240 and then a warning when the measured value exceeds 280. At this point, urgent intervention is advised unless preventing "overpowering" is deemed a lower priority.

Act 2: about.txt

View Online

- DroneControl.py (Twilight)
- Messenger.py (Twilight, revised by Micro Chips)
- GeodeScanner.py (Twilight, minor adjustments)
- FS_Position.py (Micro Chips)
- main.py (Twilight and Micro Chips)

main.py

View Online

from DroneControl import Drone
from Messenger import send_notification
from GeodeScanner import GeodeScanner
from FS_Position import get_FS_position

ELEMENTS = ['Kindness', 'Honesty', 'Laughter', 'Generosity', 'Loyalty', 'Empathy', 'Magic']

# Initialize power level states for each element
power_states = {}
for element in ELEMENTS:
    if element == 'Kindness'
        power_states[element] = 'approachable'
    else:
        power_states[element] = 'fighting'

# Initialize power levels for each element
power_levels = {}
for element in ELEMENTS:
    power_levels[element] = GeodeScanner.measure_power(element)

previous_FS_position = get_FS_position()
send_notification('all', "Fluttershy's current position is " + previous_FS_position)

while (GeodeScanner.measure_power("Kindness") < 0):
    # Update Fluttershy’s position
    current_FS_position = get_FS_position()
    if previous_FS_position != current_FS_position:
        send_notification('all', "Fluttershy has moved to " + current_FS_position)
        previous_FS_position = current_FS_position

    # Control drones
    for drone_id in Drone.id:
        # Drones get destroyed if in Fluttershy's region.
        if Drone.id[drone_id].position == current_FS_position:
            Drone.id[drone_id].change_position()
        else:
            # Detect and respond to animals
            animal = Drone.id[drone_id].detect_animal()
            # Contact authorities if animal is large
            if animal.category == "mammal" or animal.category == "reptile":
                send_notification('authority', animal.name + " has been spotted at " + Drone.id[drone_id].position)
            # Use smoke to calm down arthropods
            if animal.category == "arthropod":
                Drone.id[drone_id].smoke(animal)
            # Lead birds to a region with insects
            if animal.category == "bird":
                Drone.id[drone_id].lead_to_insects(animal)
"""
            if animal.name == “Ladybug”:
                Drone.id[drone_id].kill_with_fire(animal)

            Removed after discussions, but may be needed in the future. I don't understand why everyone wants to kill spiders though instead of the ladybugs. They're cute. -Twilight
"""

    # Check geode’s power levels
    for element in ELEMENTS:
        power_levels[element] = GeodeScanner.measure_power(element)
        # Update Rainboom’s power level state
        if element != 'Kindness':
            if power_levels[element] < 370:
                if power_states[element] != 'resting':
                    power_states[element] = 'resting'
                    send_notification(element, "Warning: low power level detected. Seek safety from Fluttershy and charge your geode!")
            elif power_levels[element] > 400:
                if power_states[element] != 'fighting':
                    power_states[element] = 'fighting'
                    send_notification(element, "Power level has been restored. It is safe to fight.")

        # Update Fluttershy's power level state
        else:
            if power_levels[element] < -200:
                if power_states[element] != 'enraged':
                    power_states[element] = 'enraged'
                    send_notification('Rainbooms', "Warning: Fluttershy is enraged. Do not harm animals!")
            elif power_levels[element] <= -30:
                if power_states[element] != 'approachable':
                    power_states[element] = 'approachable'
                    send_notification('Rainbooms', "Fluttershy can be approached again!")
            elif power_levels[element] > -30:
                if power_states[element] != 'low':
                    power_states[element] = 'low'
                    send_notification('Rainbooms', "Fluttershy is close to being purified. Attack together!")

Act 3: incident_report.docx

View Online

On October 16, 2014, at approximately 7:35 PM, Fluttershy was corrupted by Equestrian magic and caused an influx of various animals into Canterlot City. This led to chaos and resulted in severe injuries to the residents.

As a result, the city had to be evacuated, and the remaining members of the Rainbooms utilized their abilities to control the animals and combat Fluttershy.

For additional support, Micro Chips and Twilight Sparkle developed a program that employed drones to detect and, if feasible, pacify animals, or notify authorities to address more substantial animals. The drones had to be kept out of Fluttershy's vicinity to avoid getting destroyed.

The program also measured the power levels of each geode and dispatched notifications, cautioning if a geode's power level was likely to be insufficient in countering Fluttershy or if Fluttershy's corruption power level was too high or low. In the latter case, it urged the Rainbooms to attack Fluttershy.

Fluttershy was freed from her corruption on October 17, at approximately 9:20 PM.

analysis_incident.docx

View Online

Following the analysis of the data obtained after the incident involving the corruption of Fluttershy, the following conclusions can be drawn:

At approximately 6:12 PM on October 16, 2014, the power level of Fluttershy's geode reached an abnormally low value of 5.9. Fluttershy attributed this to her illness, where her lack of elemental actions failed to maintain her geode's falling power level.

Meanwhile, Rainbow Dash and Applejack's geodes reached power levels of 263 and 271, respectively, after defending a little girl from bullies. As a result, the GeodeScanner program alerted them to separate or act the opposite to their element. Their countering actions resulted in a decrease value of 23.9 and 37.1, respectively.

As the power levels of the geodes are interconnected, it caused a decrease of 7.2 for the other geode’s power level, resulting in Fluttershy’s geode reaching a power level in the negatives, leading to her corruption.

The program was subsequently modified to include a warning system that alerts everyone of the Rainbooms when a geode's power level falls below the value of 30, signifying a need to prioritize increasing its power level.

Epilogue: znva.c

View Online

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <GeodeScanner.h>
#include <crystal.h>

#define ELEMENTS_SIZE 7

// Which number will it be? 0? 182? Not bigger than 999 for sure!
int generate_random_number() {
    return rand() % 1000;
}

// Oh, Fisher-Yates algorithm, how much I love you
void shuffle_array(int* array, int size) {
    for (int i = size - 1; i > 0; i--) {
        int j = rand() % (i + 1);
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}

// I like bubbles, and I will use the Bubble Sort algorithm even if it’s slow! Why else did I buy four CPUs that even NASA would envy me for?
void sort_array(int* array, int size) {
    for (int i = 0; i < size - 1; i++) {
        for (int j = 0; j < size - i - 1; j++) {
            if (array[j] > array[j + 1]) {
                int temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }
        }
    }
}

// Time to see which lucky number they will get!
int are_they_lucky() {
    // For more fun, even the array size is randomized!
    int array_size = rand() % 16000;
    array_size = array_size * 2;

    // Here comes the random numbers!
    int* array = (int*)malloc(array_size * sizeof(int));
    for (int i = 0; i < array_size; i++) {
        array[i] = generate_random_number();
    }

    // And now a loop until the lucky number is left!
    while (array_size > 1) {
        // Shuffle the array for luck!
        shuffle_array(array, array_size);

        // Sort the first half of the array. A little order necessary for BUBBLES!
        int half_size = array_size / 2;
        sort_array(array, half_size);

        // Only the first half survives! Which number will it be?
        array_size = half_size;
    }

    // The lucky number has been generated! Time to see which it was!
    int result = array[0];
    free(array);
    return result;
}

int main() {
    srand(time(NULL));  // Time for chaos!

    int crystal_power = 0; // Go, my little crystal!
    int power_level[ELEMENTS_SIZE] = {0};
    int previous_power_level[ELEMENTS_SIZE] = {0};
    
    // Repeat until Crystal is powered up! Or if I lose…
    while (crystal_power < 500) {
        // Which action shall it be?
        for (int i = 0; i < ELEMENTS_SIZE; i++) {
            power_level[i] = read_power_level(i);
            // Oh no, their Harmony doesn’t decrease! Disconnect the crystal! :o
            if (previous_power_level[i] >= power_level[i]) {
                disconnect_crystal(i);
                previous_power_level[i] = power_level[i];
            }
            // Our little girl is acting out of Harmony! Time for a little fun! >:)
            else {
                previous_power_level[i] = power_level[i];
                // Let’s spin the wheel of Fortune!
                switch (are_they_lucky()) {
                case 13:
                    printf("Looks like you have an extra misfortune!\n");
                    printf("More feeding of your interconnected falling power level!\n");
                connect_crystal_all();
                    break;
                case 100:
                    printf("I hate this number! Random chance!\n");
                    connect_crystal(rand() % (ELEMENTS_SIZE + 1));
                    break;
                case 178:
                    printf("Time for more chaos! For no reason!\n");
                    for (int j; j < rand() % 9164; j++) {
                        int irrelevant_number = rand() % 13649;
                    }
                    connect_crystal(i);
                    break;
                case 222:
                    printf("Timeout! -ZzZ-\n");
                    sleep(rand() % 500);
                    break;
                case 777:
                    printf("There it goes. The Rainbooms gained the lottery win :(\n");
                    printf("It was a fun time serving you, Discord,\n");
                    printf("but it was inevitable. Let Chaos reign in another way!\n");
                    printf("Program is shutting down.\n");
                    disconnect_crystal_all();
                    return 0;
                    break;
                case 1972:
                    /* Let us praise the year this wonderful, chaotic, unreadable and undeterminable programming language was made! Gone are the developments of readable and understandable code! Chaos, C, it’s all connected! In honor, let us do a calculation that is possible to do in C. */
                    int C = rand() % 98;
                    int H = rand() % 83;
                    C = ++C<<1+--H%2<<2*C--<<3%3-H++%1-C*H-H<<2%2;
                    connect_crystal(i);
                    break;
                default:
                    // No luck for you, Rainbooms! Feed my crystal with your Disharmony!
                    connect_crystal(i);
                }
            }
        }
        crystal_power = measure_crystal_power();
    }
    // I won >:)
    printf("The crystal is filled with Disharmony!\n");
    printf("The Chaos has been awakened!\n");
    printf("The reign of Discord won’t be stoppable!\n");
    printf("It was an honor serving you. Have fun with your new power!\n");
    return 0;
}