phsl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
phsl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.4
2
+ Name: phsl
3
+ Version: 0.1.0
4
+ Summary: PHSL (Python Historical Strategy Lab) - 璇玑定量化战略审计终端与多智能体沙盘
5
+ Author-email: Peng Hao <research@pystrategylab.com>
6
+ Project-URL: Homepage, https://github.com/pystrategylab/phsl
7
+ Project-URL: Bug Tracker, https://github.com/pystrategylab/phsl/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: google-genai
17
+ Requires-Dist: numpy
18
+ Requires-Dist: pandas
19
+ Requires-Dist: matplotlib
20
+ Requires-Dist: streamlit
21
+ Requires-Dist: fpdf2
22
+ Requires-Dist: pydantic>=2.0.0
23
+
24
+ # Xuanji General Strategic Prototype
25
+
26
+ **Author:** Peng Hao
27
+ **Affiliation:** Python Historical Strategy Lab
28
+ **License:** MIT
29
+
30
+ PHSL: Xuanji Strategic Audit Terminal 🛡️
31
+
32
+ Python Historical Strategy Lab (PHSL) presents the Xuanji Strategic Audit Terminal, an advanced, AI-driven wargaming and strategic simulation system.
33
+
34
+ Xuanji acts as a **digital wind tunnel** for strategy, performing rigorous "Red Team" audits on strategic visions by mapping them to historical prototypes and stress-testing them in simulated environments. By integrating systems thinking,the system quantifies the physical viability of a strategy against real-world environmental noise, friction, and resistance.
35
+
36
+ 📐 The Core Strategic Axiom
37
+
38
+ At the heart of the Xuanji engine is the structural conservation of historical and realistic isomorphism. Strategic effectiveness is calculated using the following core formula:
39
+
40
+ $$E = \frac{P \cdot (ssc\_d \cdot L)}{(I \cdot (1 + vol)) + P}$$
41
+
42
+ Dimensional Variables:
43
+
44
+ $E$ (Strategic Effectiveness): The actualized impact of the strategy.
45
+ $P$ (Resource Pressure): The resources and effort applied.
46
+ $ssc\_d$ (SSC Density / Logical Density): The binding strength between the strategic vision and physical assets, which is mathematically equivalent to the likelihood P(E|H) in Bayes' theorem.
47
+ $L$ (Leverage): The strategic multiplier (e.g., technological generation gaps).
48
+ $I$ (Inertia): The inherent resistance or friction of the target environment.
49
+ $vol$ (Volatility): Geopolitical or market fluctuations.
50
+
51
+ ✨ Key Features
52
+
53
+ Strategic Oracle (AI Intelligence): Powered by Google's Gemini 2.5 Pro model, the Oracle module dynamically searches for historical prototypes, estimates Bayesian parameters, and outputs comprehensive JSON-formatted intelligence reports.
54
+
55
+ Bayesian Cognitive Engine: Refines the probability of success using Bayesian noise filtration (FRE Validation) and Monte Carlo simulations to find the "Truth Distribution."
56
+
57
+ Physics-Based Stress Testing:
58
+ * ERT (Environmental Resilience Test): Calculates system stability and identifies the critical Collapse Line (Break Point / BP).
59
+ * SIP (Strategic Ignition Point): Models efficiency against environmental resistance to find the exact Activation Pressure (AP) needed for a strategy to take effect across different leverage tiers (L1-L3 vs. L-0 Baseline).
60
+
61
+ Interactive UI & Visualizations: A sleek Streamlit dashboard (app.py) combined with matplotlib logic (visualizer.py) to render structural resilience audits and truth curves.
62
+
63
+ 📂 Project StructurePlaintextphsl/
64
+
65
+ ├── app.py # Main Streamlit web application and UI layout
66
+
67
+ ├── controller.py # Central nervous system orchestrating Oracle and Engine
68
+
69
+ ├── engine.py # Core mathematical and Bayesian calculation engine
70
+
71
+ ├── arena.py # Acts as the Dynamic Digital Wind Tunnel for strategy testing.
72
+
73
+ ├── oracle.py # Gemini API integration for historical & intelligence mapping
74
+
75
+ ├── protocol.py # Isomorphism protocol for contextual switching
76
+
77
+ ├── report_generator.py # CLI-based comprehensive strategy report generation
78
+
79
+ ├── visualizer.py # Custom Matplotlib plotting library (Truth curves, SIP, ERT)
80
+
81
+ └── __init__.py # Package initialization
82
+
83
+ 🚀 Installation & Setup
84
+ 1. Clone the repository and navigate to the project directory:(Ensure you have Python 3.8+ installed)
85
+ 2. Install required dependencies:Bashpip install streamlit google-genai matplotlib pandas numpy
86
+ 3. Configure Network/Proxy (If applicable):By default, oracle.py is configured with local proxies. If you are running this in an environment without proxy requirements, you may need to comment out lines 10-11 in oracle.py.
87
+ 4. 💻 Usage Run the Streamlit application from your terminal:Bash streamlit run app.py
88
+
89
+ Operating the Terminal:
90
+
91
+ Open the local web address provided by Streamlit.In the sidebar console, enter your Google Gemini API Key.Input your Strategic Vision Description (e.g., "The impact of the Belt and Road Initiative on restructuring global supply chains...").Click "⚡ 启动全领域审计" (Initiate All-Domain Audit).
92
+
93
+ Review the generated intelligence reports, historical isomorphism mappings, and physics-based stress test charts.
94
+
95
+ 🛠️ System Components Breakdown
96
+
97
+ * **The Oracle (oracle.py):** Acts as the Chief Auditing Officer. It enforces logical dimensionality reduction, applies real-time intelligence gathering, and matches inputs with evolutionary or military history.
98
+
99
+ * **The Engine (engine.py):** Executes the mathematical heavy lifting. It applies noise filters to leverage factors, ensuring that technological or structural advantages decay appropriately in high-noise environments.
100
+
101
+ * **The Visualizer (visualizer.py):** Generates high-fidelity, cyberpunk-styled (dark theme) charts to visualize the Monte Carlo truth curves and strategic hedge auditing.
102
+
103
+ * **The Arena (arena.py):** Acts as the Dynamic Digital Wind Tunnel. It orchestrates multi-agent, double-blind red/blue adversarial simulations across multiple parallel universes. By pit-testing the red team's strategy against dynamic environmental blowbacks round-by-round, it tracks physical attrition, applies life/death isolation statistics, and calculates the true Emergent Break Point and absolute survival rates under extreme resistance.
phsl-0.1.0/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # Xuanji General Strategic Prototype
2
+
3
+ **Author:** Peng Hao
4
+ **Affiliation:** Python Historical Strategy Lab
5
+ **License:** MIT
6
+
7
+ PHSL: Xuanji Strategic Audit Terminal 🛡️
8
+
9
+ Python Historical Strategy Lab (PHSL) presents the Xuanji Strategic Audit Terminal, an advanced, AI-driven wargaming and strategic simulation system.
10
+
11
+ Xuanji acts as a **digital wind tunnel** for strategy, performing rigorous "Red Team" audits on strategic visions by mapping them to historical prototypes and stress-testing them in simulated environments. By integrating systems thinking,the system quantifies the physical viability of a strategy against real-world environmental noise, friction, and resistance.
12
+
13
+ 📐 The Core Strategic Axiom
14
+
15
+ At the heart of the Xuanji engine is the structural conservation of historical and realistic isomorphism. Strategic effectiveness is calculated using the following core formula:
16
+
17
+ $$E = \frac{P \cdot (ssc\_d \cdot L)}{(I \cdot (1 + vol)) + P}$$
18
+
19
+ Dimensional Variables:
20
+
21
+ $E$ (Strategic Effectiveness): The actualized impact of the strategy.
22
+ $P$ (Resource Pressure): The resources and effort applied.
23
+ $ssc\_d$ (SSC Density / Logical Density): The binding strength between the strategic vision and physical assets, which is mathematically equivalent to the likelihood P(E|H) in Bayes' theorem.
24
+ $L$ (Leverage): The strategic multiplier (e.g., technological generation gaps).
25
+ $I$ (Inertia): The inherent resistance or friction of the target environment.
26
+ $vol$ (Volatility): Geopolitical or market fluctuations.
27
+
28
+ ✨ Key Features
29
+
30
+ Strategic Oracle (AI Intelligence): Powered by Google's Gemini 2.5 Pro model, the Oracle module dynamically searches for historical prototypes, estimates Bayesian parameters, and outputs comprehensive JSON-formatted intelligence reports.
31
+
32
+ Bayesian Cognitive Engine: Refines the probability of success using Bayesian noise filtration (FRE Validation) and Monte Carlo simulations to find the "Truth Distribution."
33
+
34
+ Physics-Based Stress Testing:
35
+ * ERT (Environmental Resilience Test): Calculates system stability and identifies the critical Collapse Line (Break Point / BP).
36
+ * SIP (Strategic Ignition Point): Models efficiency against environmental resistance to find the exact Activation Pressure (AP) needed for a strategy to take effect across different leverage tiers (L1-L3 vs. L-0 Baseline).
37
+
38
+ Interactive UI & Visualizations: A sleek Streamlit dashboard (app.py) combined with matplotlib logic (visualizer.py) to render structural resilience audits and truth curves.
39
+
40
+ 📂 Project StructurePlaintextphsl/
41
+
42
+ ├── app.py # Main Streamlit web application and UI layout
43
+
44
+ ├── controller.py # Central nervous system orchestrating Oracle and Engine
45
+
46
+ ├── engine.py # Core mathematical and Bayesian calculation engine
47
+
48
+ ├── arena.py # Acts as the Dynamic Digital Wind Tunnel for strategy testing.
49
+
50
+ ├── oracle.py # Gemini API integration for historical & intelligence mapping
51
+
52
+ ├── protocol.py # Isomorphism protocol for contextual switching
53
+
54
+ ├── report_generator.py # CLI-based comprehensive strategy report generation
55
+
56
+ ├── visualizer.py # Custom Matplotlib plotting library (Truth curves, SIP, ERT)
57
+
58
+ └── __init__.py # Package initialization
59
+
60
+ 🚀 Installation & Setup
61
+ 1. Clone the repository and navigate to the project directory:(Ensure you have Python 3.8+ installed)
62
+ 2. Install required dependencies:Bashpip install streamlit google-genai matplotlib pandas numpy
63
+ 3. Configure Network/Proxy (If applicable):By default, oracle.py is configured with local proxies. If you are running this in an environment without proxy requirements, you may need to comment out lines 10-11 in oracle.py.
64
+ 4. 💻 Usage Run the Streamlit application from your terminal:Bash streamlit run app.py
65
+
66
+ Operating the Terminal:
67
+
68
+ Open the local web address provided by Streamlit.In the sidebar console, enter your Google Gemini API Key.Input your Strategic Vision Description (e.g., "The impact of the Belt and Road Initiative on restructuring global supply chains...").Click "⚡ 启动全领域审计" (Initiate All-Domain Audit).
69
+
70
+ Review the generated intelligence reports, historical isomorphism mappings, and physics-based stress test charts.
71
+
72
+ 🛠️ System Components Breakdown
73
+
74
+ * **The Oracle (oracle.py):** Acts as the Chief Auditing Officer. It enforces logical dimensionality reduction, applies real-time intelligence gathering, and matches inputs with evolutionary or military history.
75
+
76
+ * **The Engine (engine.py):** Executes the mathematical heavy lifting. It applies noise filters to leverage factors, ensuring that technological or structural advantages decay appropriately in high-noise environments.
77
+
78
+ * **The Visualizer (visualizer.py):** Generates high-fidelity, cyberpunk-styled (dark theme) charts to visualize the Monte Carlo truth curves and strategic hedge auditing.
79
+
80
+ * **The Arena (arena.py):** Acts as the Dynamic Digital Wind Tunnel. It orchestrates multi-agent, double-blind red/blue adversarial simulations across multiple parallel universes. By pit-testing the red team's strategy against dynamic environmental blowbacks round-by-round, it tracks physical attrition, applies life/death isolation statistics, and calculates the true Emergent Break Point and absolute survival rates under extreme resistance.
@@ -0,0 +1,8 @@
1
+ # phsl/__init__.py
2
+ from .engine import XuanjiEngine
3
+ from .controller import XuanjiController
4
+ from .oracle import StrategicOracle
5
+ from .visualizer import PHSLVisualizer
6
+ from .report_generator import StrategicReportGenerator
7
+ from .pdf_exporter import XuanjiPDFReport
8
+ from .arena import XuanjiValidator