[Linked Image]

It is hidden within the War

Code
import matplotlib.pyplot as plt
import networkx as nx

# Create a directed graph
G = nx.DiGraph()

# Recursive function to generate the war recursion tree with unique labels
def add_war_nodes(graph, parent, depth, max_depth):
    if depth > max_depth:
        return

    # Generate unique battle names
    left_battle = f"Battle-{depth}L"
    right_battle = f"Battle-{depth}R"

    # Add edges to represent battles branching from strategic decisions
    graph.add_edge(parent, left_battle)
    graph.add_edge(parent, right_battle)

    # Recursively create deeper battle strategies
    add_war_nodes(graph, left_battle, depth + 1, max_depth)
    add_war_nodes(graph, right_battle, depth + 1, max_depth)

# Root node representing the beginning of war decisions
G.add_node("War Begins")

# Generate recursive war strategy tree
add_war_nodes(G, "War Begins", 1, 5)  # Depth of recursion is 5

# Set up figure size
plt.figure(figsize=(14, 10))

# Recalculate positions for better label visibility
pos = nx.spring_layout(G, seed=42)  

# Draw nodes and edges without labels to prevent overlap
nx.draw(G, pos, with_labels=False, node_color="black", edge_color="gray", node_size=200)

# Draw labels separately in red with a white background for clarity
for node, (x, y) in pos.items():
    plt.text(x, y + 0.03, node, fontsize=9, ha='center', color="red", 
             bbox=dict(facecolor="white", edgecolor="none", boxstyle="round,pad=0.2"))

# Set the title of the plot
plt.title("The War of Shifting Fronts - Hidden Recursion Tree with Clear Labels")

# Show the final visualization
plt.show()


It would surprise you but every game is the ending of conditions for a probable game that inspires the rules to fall apart.
This code can create a highly complex adaptive strategy.

Code
// Structure representing a war decision node
typedef struct {
    char name[50];  // Fixed-size character array for name
    int strength;   // Hidden game-theoretic influence
    int risk;       // Determines adaptability to opposition
} BattleNode;

// Global statistics variables
int battleCount = 0;
var totalStrength = 0;
var totalRisk = 0;
int maxStrength = 0;
int minRisk = 100;  // Start with a high value to track lowest risk

// Function to generate a pseudo-random number in a range (Zorro's method)
int randomInt(int min, int max) {
    return min + (int)((max - min) * random()); 
}

// Recursive function to simulate war strategies with game-theoretic decisions
void simulateBattle(BattleNode* battle, int depth, int maxDepth) {
    if (depth > maxDepth) return;  // Base case: stop recursion

    // Generate random strategy values using Zorro's `random()` function
    battle->strength = randomInt(1, 100);
    battle->risk = randomInt(1, 100); // Ensuring no negative values

    // Update statistics
    battleCount++;
    totalStrength += battle->strength;
    totalRisk += battle->risk;
    
    if (battle->strength > maxStrength) maxStrength = battle->strength;
    if (battle->risk < minRisk) minRisk = battle->risk;

    // Debugging: Print battle details to log
    printf("\n[Battle %d] %s | Strength: %d | Risk: %d", 
           battleCount, battle->name, battle->strength, battle->risk);

    // Hidden recursive expansion influenced by game theory
    if (battle->strength > battle->risk) {
        battle->strength += randomInt(1, 50);
        battle->risk -= randomInt(1, 20);
    } else {
        battle->strength -= randomInt(1, 30);
        battle->risk += randomInt(1, 10);
    }

    // Ensure risk does not go negative
    if (battle->risk < 0) battle->risk = 0;

    // Recursively simulate further battles
    if (depth + 1 <= maxDepth) {
        BattleNode nextBattle;
        sprintf(nextBattle.name, "%s-%d", battle->name, depth);
        simulateBattle(&nextBattle, depth + 1, maxDepth);
    }
}

// Function to display final statistics
void displayStatistics() {
    printf("\n--- War Simulation Statistics ---");
    printf("\nTotal Battles Simulated: %d", battleCount);

    if (battleCount > 0) {
        printf("\nAverage Strength: %.2f", totalStrength / (var)battleCount);
        printf("\nAverage Risk: %.2f", totalRisk / (var)battleCount);
    }
    printf("\nMax Strength Encountered: %d", maxStrength);
    printf("\nMin Risk Encountered: %d", minRisk);
    printf("\n--------------------------------\n");
}

// Main function to trigger the war simulation in Zorro
void run() {  
    if (is(INITRUN)) {  // Run only once at the start
        BattleNode root;
        strcpy(root.name, "War Begins");
        simulateBattle(&root, 1, 5);  // Start recursive war simulation
        
        // Display statistics at the end
        displayStatistics();
    }
}


Here are some statistics to test :

Code
[Battle 4] War Begins-1-2-3 | Strength: 82 | Risk: -13
[Battle 5] War Begins-1-2-3-4 | Strength: 77 | Risk: 17
--- War Simulation Statistics ---
Total Battles Simulated: 5
Average Strength: -2.00
Average Risk: -1.80
Max Strength Encountered: 82
Min Risk Encountered: -79
--------------------------------


Last edited by TipmyPip; 01/31/25 12:18.