File size: 11,410 Bytes
24b4bc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# Brain Game 🧠

import streamlit as st
import zlib
import base64
import random
import pandas as pd
import plotly.express as px
from streamlit_ace import st_ace
import streamlit.components.v1 as components
import json

# Utility functions (compress_text and decompress_text) remain the same

# Main Streamlit App
def main():
    st.set_page_config(layout="wide", page_title="Nietzsche's Philosophical Playground")
    st.title("🧠🎮 Nietzsche's Philosophical Playground: Where Ideas Come to Dance")
    
    # Initialize session state for game dynamics
    if 'philosophical_points' not in st.session_state:
        st.session_state.philosophical_points = 0
    if 'unlocked_chapters' not in st.session_state:
        st.session_state.unlocked_chapters = ['nietzsche_influence']

    # Sidebar for navigation and game stats
    st.sidebar.title("🗺️ Philosophical Journey Map")
    st.sidebar.write(f"💡 Philosophical Points: {st.session_state.philosophical_points}")
    
    chapters = {
        "📖 Nietzsche's Influence: Beyond Good and Evil": "nietzsche_influence",
        "✍️ The Art of Aphorism: Nietzsche's Literary Genius": "aphoristic_style",
        "🧩 Deconstructing 'Beyond Good and Evil'": "deconstruct_beyond_good_and_evil",
        "📚 Romantic and Literary Influences on Nietzsche": "romantic_influences",
        "🔎 Right Wing Pathology: A Philosophical Analysis": "right_wing_pathology",
        "🦸 The Hero's Journey: From Myth to Modern Psychology": "hero_myth",
        "🙏 The Death of God and the Call to Adventure": "belief_in_god",
        "📈 Übermensch and Incremental Improvement": "incremental_improvement",
        "❤️ Amor Fati: Love, Acceptance, and Challenge": "love_acceptance_challenge",
        "🔍 Epistemology: Sorting Truth from Manipulation": "sorting_truth_manipulation",
        "🗺️ Nietzschean Concept Network": "topic_model_visualization"
    }

    for chapter, func_name in chapters.items():
        if func_name in st.session_state.unlocked_chapters:
            st.sidebar.markdown(f"[{chapter}](#{func_name})")
        else:
            st.sidebar.markdown(f"🔒 {chapter}")

    app_mode = st.sidebar.selectbox("🚀 Choose Your Philosophical Quest", 
                                    [chapter for chapter, func_name in chapters.items() 
                                     if func_name in st.session_state.unlocked_chapters])

    # Call the corresponding function based on user selection
    globals()[chapters[app_mode]]()

    # Add the Mermaid topic model visualization
    st.header("🗺️ Nietzschean Concept Network")
    render_mermaid_diagram()

def render_mermaid_diagram():
    mermaid_code = """
    graph TD
        A[Nietzsche's Philosophy] --> B[Übermensch]
        A --> C[Eternal Recurrence]
        A --> D[Will to Power]
        B --> E[Self-Overcoming]
        C --> F[Amor Fati]
        D --> G[Master Morality]
        D --> H[Slave Morality]
        A --> I[Death of God]
        I --> J[Revaluation of Values]
        B --> K[Creation of Values]
        F --> L[Embracing Life]
        G --> M[Nobility]
        H --> N[Ressentiment]
    """

    # Custom CSS to make the diagram interactive
    custom_css = """
    <style>
        .mermaid svg { cursor: pointer; }
        .mermaid .node rect { fill: #f4f4f4; stroke: #999; stroke-width: 1px; }
        .mermaid .node text { fill: #333; }
        .mermaid .edgePath path { stroke: #999; stroke-width: 1px; }
        .mermaid .node:hover rect { fill: #e1e1e1; }
    </style>
    """

    # JavaScript to add interactivity
    custom_js = """
    <script>
    const svg = document.querySelector(".mermaid svg");
    if (svg) {
        const nodes = svg.querySelectorAll(".node");
        nodes.forEach(node => {
            node.addEventListener("click", function() {
                const rect = this.querySelector("rect");
                const text = this.querySelector("text");
                rect.style.fill = getRandomColor();
                text.style.fontWeight = "bold";
                wiggleNode(this);
            });
        });
    }

    function getRandomColor() {
        return "#" + Math.floor(Math.random()*16777215).toString(16);
    }

    function wiggleNode(node) {
        let angle = 0;
        const interval = setInterval(() => {
            angle += 5;
            node.style.transform = `rotate(${Math.sin(angle * Math.PI / 180) * 5}deg)`;
            if (angle >= 360) clearInterval(interval);
        }, 16);
    }
    </script>
    """

    # Combine Mermaid diagram with custom CSS and JavaScript
    mermaid_html = f"""
    {custom_css}
    <div class="mermaid">
    {mermaid_code}
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.13.3/mermaid.min.js"></script>
    <script>mermaid.initialize({{startOnLoad:true}});</script>
    {custom_js}
    """

    components.html(mermaid_html, height=600)

def nietzsche_influence():
    st.header("📖 Nietzsche's Influence: Beyond Good and Evil")
    
    st.write("""
    Welcome, brave soul, to the whirlwind world of Friedrich Nietzsche! 
    Prepare to have your mind twisted, turned, and occasionally tickled 
    as we explore the influence of philosophy's most notorious mustache owner. 🎭
    """)

    # Interactive Nietzsche Quote Generator
    st.subheader("🎲 Roll the Dice of Wisdom")
    if st.button("Generate Nietzschean Insight"):
        quotes = [
            "God is dead! God remains dead! And we have killed him.",
            "He who has a why to live can bear almost any how.",
            "There are no facts, only interpretations.",
            "In heaven, all the interesting people are missing.",
            "What does not kill me makes me stronger.",
        ]
        quote = random.choice(quotes)
        st.info(f"🧠 {quote}")
        st.session_state.philosophical_points += 5
        st.success(f"You gained 5 philosophical points! Total: {st.session_state.philosophical_points}")

    # Nietzsche's Concept Strength Meter
    st.subheader("💪 Concept Strength Meter")
    concept = st.selectbox("Choose a Nietzschean concept:", 
                           ["Übermensch", "Eternal Recurrence", "Will to Power", "Master-Slave Morality"])
    strength = random.randint(1, 100)
    st.progress(strength / 100)
    st.write(f"The strength of '{concept}' in today's philosophy: {strength}%")

    # Philosophical Dilemma Game
    st.subheader("🤔 Philosophical Dilemma Solver")
    dilemma = st.text_input("Present a moral dilemma:")
    if st.button("What Would Nietzsche Do?"):
        responses = [
            "Embrace the chaos and dance!",
            "Create your own values and live by them fiercely.",
            "Consider the perspective of the Übermensch.",
            "Ask yourself: Would you will this to recur eternally?",
            "Reject conventional morality and forge your own path.",
        ]
        nietzsche_response = random.choice(responses)
        st.write(f"Nietzsche might say: {nietzsche_response}")
        st.session_state.philosophical_points += 10
        st.success(f"You gained 10 philosophical points for wrestling with morality! Total: {st.session_state.philosophical_points}")

    # Unlock new chapter if enough points
    if st.session_state.philosophical_points >= 50 and 'aphoristic_style' not in st.session_state.unlocked_chapters:
        st.session_state.unlocked_chapters.append('aphoristic_style')
        st.balloons()
        st.success("Congratulations! You've unlocked 'The Art of Aphorism' chapter!")

def aphoristic_style():
    st.header("✍️ The Art of Aphorism: Nietzsche's Literary Genius")
    
    st.write("""
    Welcome to the dojo of philosophical one-liners! Here, we'll master the art of 
    saying profound things in tweet-sized chunks. Nietzsche was the OG of philosophical 
    mic drops, so let's channel our inner mustachioed madman! 🥋📜
    """)

    # Aphorism Generator 2.0
    st.subheader("🎭 The Aphorism Forge")
    subjects = ["The wise", "Fools", "Heroes", "Cowards", "Artists", "Scientists"]
    verbs = ["seek", "fear", "embrace", "reject", "transcend", "dance with"]
    objects = ["truth", "power", "love", "death", "life", "eternity"]
    twists = ["but find only mirrors", "yet discover their shadow", "and become what they behold", "only to lose themselves", "and laugh at the absurdity"]

    if st.button("Forge an Aphorism"):
        aphorism = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)}, {random.choice(twists)}."
        st.success(f"🧠✍️ {aphorism}")
        st.session_state.philosophical_points += 7
        st.info(f"You gained 7 philosophical points for your aphoristic wisdom! Total: {st.session_state.philosophical_points}")

    # Aphorism Workshop with Streamlit Ace Editor
    st.subheader("🖋️ Craft Your Magnum Opus")
    st.write("Channel your inner Nietzsche and craft an aphorism that will echo through the ages!")
    
    user_aphorism = st_ace(
        placeholder="Type your aphorism here...",
        language="plain_text",
        theme="monokai",
        keybinding="vscode",
        font_size=14,
        min_lines=5,
        key="aphorism_editor"
    )

    if user_aphorism:
        st.write("Your Aphoristic Gem:")
        st.info(user_aphorism)
        quality_score = random.randint(1, 100)
        st.write(f"Nietzsche's Ghost rates your aphorism: {quality_score}/100")
        if quality_score > 80:
            st.success("Bravo! Nietzsche would be proud (and slightly jealous).")
            st.session_state.philosophical_points += 20
            st.success(f"You gained 20 philosophical points for your brilliant aphorism! Total: {st.session_state.philosophical_points}")
        elif quality_score > 50:
            st.warning("Not bad! Keep refining your philosophical wit.")
            st.session_state.philosophical_points += 10
            st.info(f"You gained 10 philosophical points for your decent attempt! Total: {st.session_state.philosophical_points}")
        else:
            st.error("Nietzsche suggests more contemplation... perhaps on a mountain top?")
            st.session_state.philosophical_points += 5
            st.info(f"You gained 5 philosophical points for effort! Total: {st.session_state.philosophical_points}")

    # Unlock new chapter if enough points
    if st.session_state.philosophical_points >= 100 and 'deconstruct_beyond_good_and_evil' not in st.session_state.unlocked_chapters:
        st.session_state.unlocked_chapters.append('deconstruct_beyond_good_and_evil')
        st.balloons()
        st.success("Congratulations! You've unlocked the 'Deconstructing Beyond Good and Evil' chapter!")

# Additional chapter functions would be defined here...

def topic_model_visualization():
    st.header("🗺️ Nietzschean Concept Network")
    render_mermaid_diagram()

# File handling functions
def save_file(content, filename):
    st.download_button(
        label="Download File",
        data=content,
        file_name=filename,
        mime="text/plain"
    )

def load_file():
    uploaded_file = st.file_uploader("Choose a file")
    if uploaded_file is not None:
        content = uploaded_file.getvalue().decode("utf-8")
        return content
    return None

# Main function to run the Streamlit app
if __name__ == "__main__":
    main()