胜战计(处于优势时使用的策略)
瞒天过海
备周则意怠,常见则不疑。阴在阳之内,不在阳之对。太阳,太阴。
通过伪装隐藏真实意图,在对方松懈时行动。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Polygon, Circle
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 8), facecolor='#0a0a2a')
ax.set_xlim(0, 14)
ax.set_ylim(0, 8)
ax.axis('off')
plt.title('瞒天过海策略示意图', fontsize=18, color='white', pad=20)
# 绘制天空和海洋
sky = Rectangle((0, 4), 14, 4, facecolor='#0a0a2a', edgecolor='none')
sea = Rectangle((0, 0), 14, 4, facecolor='#1a1a5a', edgecolor='none')
ax.add_patch(sky)
ax.add_patch(sea)
# 添加星光
stars_x = np.random.uniform(0, 14, 50)
stars_y = np.random.uniform(4.5, 7.5, 50)
ax.scatter(stars_x, stars_y, s=np.random.uniform(0.5, 3, 50),
color='white', alpha=0.7)
# 绘制月亮
moon = Circle((2, 6.5), 0.8, color='#f0f0c0', alpha=0.9)
ax.add_patch(moon)
# 绘制真实舰队(隐蔽航行)
real_ships = []
for i in range(5):
x = 1 + i * 0.8
y = 1.5 + np.random.uniform(-0.1, 0.1)
# 船体
hull = Polygon(np.array([ # 添加np.array转换
[x, y],
[x + 0.6, y],
[x + 0.5, y + 0.3],
[x + 0.1, y + 0.3]
]), closed=True, color='#303030')
# 船帆
sail = Polygon(np.array([ # 添加np.array转换
[x + 0.3, y + 0.3],
[x + 0.3, y + 0.9],
[x + 0.4, y + 0.9]
]), closed=True, color='#202020')
ax.add_patch(hull)
ax.add_patch(sail)
real_ships.extend([hull, sail])
# 绘制假目标(诱敌)
decoy_ships = []
for i in range(3):
x = 10 + i * 1.5
y = 2.5
# 船体(更大更显眼)
sail = Polygon(np.array([[x + 0.6, y + 0.6], [x + 0.6, y + 1.8], [x + 0.8, y + 1.8]]),
closed=True, color='#aaaaaa', alpha=0.7)
# 船帆(亮色吸引注意)
hull = Polygon(np.array([[x, y], [x + 1.2, y], [x + 1.0, y + 0.6], [x + 0.2, y + 0.6]]),
closed=True, color='#555555', alpha=0.7)
# 灯光(模拟活动)
light = Circle((x + 0.7, y + 0.3), 0.15, color='yellow', alpha=0.6)
ax.add_patch(hull)
ax.add_patch(sail)
ax.add_patch(light)
decoy_ships.extend([hull, sail, light])
# 添加策略说明
texts = [
("真实行动", (1, 0.8), '#a0d0ff'),
("伪装隐蔽", (1, 0.5), '#a0d0ff'),
("夜间潜行", (1, 0.2), '#a0d0ff'),
("虚假目标", (9.7, 3.5), '#ffa0a0'),
("吸引注意", (9.7, 3.2), '#ffa0a0'),
("声东击西", (9.7, 2.9), '#ffa0a0'),
("瞒天过海:通过伪装隐藏真实意图,制造假象迷惑敌人", (7, 7.5), 'white')
]
for text, pos, color in texts:
ax.text(pos[0], pos[1], text, color=color, fontsize=10,
ha='center', va='center', alpha=0.9)
# 添加海峡两岸
left_coast = Polygon(np.array([[0, 4], [0, 8], [3, 4]]), closed=True, color='#1a5a1a')
right_coast = Polygon(np.array([[14, 4], [14, 8], [11, 4]]), closed=True, color='#1a5a1a')
ax.add_patch(left_coast)
ax.add_patch(right_coast)
# 添加箭头表示行动方向
ax.arrow(3.5, 1.8, 5.0, 0, head_width=0.2, head_length=0.3,
fc='#70c0ff', ec='none', alpha=0.7)
# 添加波浪效果
wave_x = np.linspace(0, 14, 100)
wave_y = 4 + 0.1 * np.sin(10 * wave_x) + 0.05 * np.cos(15 * wave_x)
ax.plot(wave_x, wave_y, color='#40a0ff', alpha=0.3, linewidth=1.5)
# 添加图例
legend_elements = [
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#303030', markersize=10, label='真实舰队'),
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#aaaaaa', markersize=10, label='诱敌目标'),
plt.Line2D([0], [0], marker='>', color='#70c0ff', markersize=10, label='行动方向', linestyle='None')
]
ax.legend(handles=legend_elements, loc='upper center',
bbox_to_anchor=(0.5, -0.05), ncol=3,
facecolor='#000020', edgecolor='none',
labelcolor='white', fontsize=10)
plt.tight_layout()
plt.savefig('瞒天过海.png', dpi=300, bbox_inches='tight', facecolor='#0a0a2a')
plt.show()
围魏救赵
共敌不如分敌,敌阳不如敌阴。
攻击敌人薄弱处,迫使主力回援,以解己方之围。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, Rectangle
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 8))
ax.set_xlim(0, 14)
ax.set_ylim(0, 8)
ax.axis('off')
plt.title('围魏救赵策略示意图', fontsize=18, pad=20)
# 绘制地形背景
terrain = Rectangle((0, 0), 14, 8, facecolor='#e0e0c0', edgecolor='none')
ax.add_patch(terrain)
# 绘制河流
river_x = np.linspace(2, 12, 100)
river_y = 4 + 0.3 * np.sin(0.8 * river_x)
ax.plot(river_x, river_y, color='#40a0ff', linewidth=4, alpha=0.7)
ax.fill_between(river_x, river_y, 8, color='#a0d0ff', alpha=0.3)
# 绘制三个关键位置
def draw_city(x, y, name, color, size=0.8):
city = Circle((x, y), size, color=color, alpha=0.9)
ax.add_patch(city)
ax.text(x, y, name, ha='center', va='center', color='white',
fontsize=12, weight='bold')
return city
# 三个关键城市
zhao = draw_city(3, 6, '赵', '#3030a0') # 赵国 (蓝色)
wei = draw_city(11, 5.4, '魏', '#a03030') # 魏国 (红色)
qi = draw_city(7, 2.2, '齐', '#30a030') # 齐国 (绿色)
# 绘制魏国主力围攻赵国
def draw_army(x, y, color, size=20, direction=None):
ax.scatter([x], [y], s=size, color=color, alpha=0.8)
if direction:
dx, dy = direction
ax.arrow(x, y, dx*0.5, dy*0.5, head_width=0.2, head_length=0.3,
fc=color, ec=color, alpha=0.7)
# 魏国主力围攻赵国 (红色)
for i in range(12):
angle = i * 2 * np.pi / 12
radius = 1.5 + np.random.uniform(0, 0.2)
x = 3 + radius * np.cos(angle)
y = 6 + radius * np.sin(angle)
draw_army(x, y, '#d05050', 80, (-np.cos(angle)*0.5, -np.sin(angle)*0.5))
# 赵国守军 (蓝色)
for i in range(5):
angle = i * 2 * np.pi / 5
radius = 0.8 + np.random.uniform(0, 0.1)
x = 3 + radius * np.cos(angle)
y = 6 + radius * np.sin(angle)
draw_army(x, y, '#3060d0', 60)
# 齐国军队行动路线 (绿色)
# 1. 齐国主力佯攻赵国方向
ax.plot([7, 5.5], [2, 3.5], 'g--', alpha=0.5)
draw_army(5.5, 3.5, '#30d030', 70, (0.5, 0.5))
# 2. 实际分兵奔袭魏国
ax.plot([5.5, 11], [3.5, 5], 'g-', linewidth=2, alpha=0.8)
draw_army(8.5, 4.5, '#30d030', 100, (0.7, 0.3))
# 3. 齐国军队抵达魏国都城
draw_army(10.5, 5.5, '#30d030', 120)
ax.plot([10.5, 11], [5.5, 5.8], 'g-', linewidth=2)
ax.plot([10.5, 10.8], [5.5, 5.2], 'g-', linewidth=2)
# 魏国守军 (少量)
for i in range(4):
angle = i * 2 * np.pi / 4
radius = 0.6 + np.random.uniform(0, 0.1)
x = 11 + radius * np.cos(angle)
y = 6 + radius * np.sin(angle)
draw_army(x, y, '#d05050', 50)
# 魏国主力回援路线 (红色)
ax.plot([3, 11], [6, 5.5], 'r-', linewidth=2, alpha=0.6)
draw_army(7, 5.8, '#d05050', 90, (1.0, -0.1))
# 添加策略说明
texts = [
("1. 魏国主力围攻赵国", (3, 7.2), '#a03030'),
("2. 齐国佯装救援赵国", (5, 3.0), '#30a030'),
("3. 实际分兵奔袭魏国都城", (8.5, 4.0), '#30a030'),
("4. 魏国主力被迫回援", (7, 6.2), '#a03030'),
("5. 赵国危机解除", (3, 4.8), '#3030a0'),
("围魏救赵:攻击敌人要害,迫使敌方主力回援", (7, 1), 'black'),
("魏国", (11, 7.0), '#a03030'),
("赵国", (3, 7.8), '#3030a0'),
("齐国", (7, 1.2), '#30a030')
]
for text, pos, color in texts:
ax.text(pos[0], pos[1], text, color=color, fontsize=10,
ha='center', va='center', weight='bold')
# 添加图例
legend_elements = [
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#d05050', markersize=10, label='魏国军队'),
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#3060d0', markersize=10, label='赵国军队'),
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#30d030', markersize=10, label='齐国军队'),
plt.Line2D([0], [0], marker='>', color='#30a030', markersize=10, label='齐国行动', linestyle='None'),
plt.Line2D([0], [0], marker='>', color='#a03030', markersize=10, label='魏国行动', linestyle='None')
]
ax.legend(handles=legend_elements, loc='lower center',
bbox_to_anchor=(0.5, -0.05), ncol=3,
facecolor='#f0f0f0', edgecolor='gray',
fontsize=10)
# 添加策略原理图
ax.text(1, 1.5, "策略原理:", fontsize=11, weight='bold')
ax.text(1, 1.0, "1. 避实击虚:攻击敌人薄弱环节", fontsize=10)
ax.text(1, 0.6, "2. 攻其必救:威胁敌人要害", fontsize=10)
ax.text(1, 0.2, "3. 以逸待劳:在敌回援途中设伏", fontsize=10)
# 绘制时间线
timeline_x = [3, 5, 8, 11]
timeline_y = [0.4, 0.4, 0.4, 0.4]
ax.plot(timeline_x, timeline_y, 'k-', linewidth=1)
for i, label in enumerate(["初始", "佯攻", "奔袭", "回援"]):
ax.plot([timeline_x[i], timeline_x[i]], [0.3, 0.5], 'k-', linewidth=1)
ax.text(timeline_x[i], 0.6, f"阶段 {i+1}\n{label}", ha='center', fontsize=9)
plt.tight_layout()
plt.savefig('围魏救赵.png', dpi=300, bbox_inches='tight')
plt.show()
借刀杀人
敌已明,友未定,引友杀敌,不自出力。
利用第三方力量打击对手,避免直接消耗。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.axis('off')
plt.title('借刀杀人策略示意图', fontsize=20, pad=20, weight='bold')
# 设置背景为古代地图样式
map_bg = Rectangle((0, 0), 14, 10, facecolor='#f0e6d2', edgecolor='#8b7d6b', linewidth=2)
ax.add_patch(map_bg)
# 绘制三个势力区域
def draw_kingdom(x, y, width, height, color, name):
# 绘制领地
territory = Rectangle((x, y), width, height,
facecolor=color, alpha=0.2,
edgecolor=color, linewidth=2)
ax.add_patch(territory)
# 绘制王座
throne = Rectangle((x + width / 2 - 0.5, y + height - 1.5), 1, 1.5,
facecolor='#d4af37', edgecolor='#8b7500', linewidth=1.5)
ax.add_patch(throne)
# 添加势力名称
ax.text(x + width / 2, y + height - 0.7, name,
fontsize=14, ha='center', va='center',
weight='bold', color=color)
# 返回领地中心坐标
return x + width / 2, y + height / 2
# 绘制三个势力
my_center = draw_kingdom(1, 1, 4, 4, '#3060a0', '我方势力') # 蓝色
enemy_center = draw_kingdom(9, 1, 4, 4, '#a03030', '敌方势力') # 红色
third_center = draw_kingdom(4, 6, 6, 3, '#30a030', '第三方势力') # 绿色
# 绘制势力代表
def draw_leader(x, y, color, size=0.5):
leader = Circle((x, y), size, facecolor=color, edgecolor='black')
ax.add_patch(leader)
return leader
# 添加领导者
me = draw_leader(my_center[0], my_center[1] - 1, '#3060a0')
enemy = draw_leader(enemy_center[0], enemy_center[1] - 1, '#a03030')
third_party = draw_leader(third_center[0], third_center[1] - 0.5, '#30a030')
# 绘制策略步骤
step_texts = [
("1. 制造矛盾", (third_center[0], enemy_center[1] + 1.5), '#a03030'),
("散布谣言:敌方计划入侵第三方", (third_center[0], enemy_center[1] + 1.0), 'black'),
("伪造证据:敌方与第三方敌人结盟", (third_center[0], enemy_center[1] + 0.5), 'black'),
("2. 提供诱因", (third_center[0], third_center[1] - 1.5), '#30a030'),
("承诺支援:提供情报和物资", (third_center[0], third_center[1] - 2.0), 'black'),
("夸大利益:战胜后的领土分配", (third_center[0], third_center[1] - 2.5), 'black'),
("3. 第三方行动", (enemy_center[0], enemy_center[1] + 2.8), '#30a030'),
("第三方出兵攻击敌人", (enemy_center[0], enemy_center[1] + 2.5), 'black'),
("双方消耗实力", (enemy_center[0], enemy_center[1] + 2.2), 'black'),
("4. 坐收渔利", (my_center[0], my_center[1] + 2.8), '#3060a0'),
("保存自身实力", (my_center[0], my_center[1] + 2.5), 'black'),
("待两败俱伤后出击", (my_center[0], my_center[1] + 2.2), 'black'),
("借刀杀人:借助第三方力量打击敌人,避免直接消耗", (7, 9.5), '#000000')
]
for text, pos, color in step_texts:
ax.text(pos[0], pos[1], text, ha='center', va='center',
color=color, fontsize=10 if 'black' in color else 12)
# 绘制信息流(谣言和诱因)
ax.annotate('', xy=(my_center[0] + 1, my_center[1] + 1.8),
xytext=(third_center[0] - 1, third_center[1] - 0.5),
arrowprops=dict(arrowstyle='->', color='#3060a0',
linestyle='dashed', alpha=0.7),
annotation_clip=False)
ax.annotate('', xy=(my_center[0] + 1, my_center[1] + 1.5),
xytext=(third_center[0] - 0.5, third_center[1] - 1.0),
arrowprops=dict(arrowstyle='->', color='#3060a0',
linestyle='dashed', alpha=0.7),
annotation_clip=False)
# 绘制第三方攻击敌人的行动
ax.annotate('', xy=(third_center[0] - 1, third_center[1] - 1.5),
xytext=(enemy_center[0] + 0.5, enemy_center[1] + 1.0),
arrowprops=dict(arrowstyle='->', color='#30a030',
linewidth=2, alpha=0.8),
annotation_clip=False)
# 绘制战斗场景
def draw_battle(x, y):
# 绘制冲突符号
conflict = plt.text(x, y, '⚔', fontsize=24,
ha='center', va='center', alpha=0.7)
# 绘制爆炸效果
for i in range(8):
angle = i * np.pi / 4
length = 0.5 + np.random.random() * 0.3
dx = length * np.cos(angle)
dy = length * np.sin(angle)
ax.plot([x, x + dx], [y, y + dy], color='#ff3030', alpha=0.6)
draw_battle(enemy_center[0], enemy_center[1] + 1.5)
# 绘制资源流动
def draw_resource_flow(start, end, color, label):
ax.annotate('', xy=end, xytext=start,
arrowprops=dict(arrowstyle='fancy',
color=color,
connectionstyle="arc3,rad=-0.3",
alpha=0.7))
mid_x = (start[0] + end[0]) / 2
mid_y = (start[1] + end[1]) / 2 + 0.5
ax.text(mid_x, mid_y, label, color=color,
ha='center', fontsize=9, style='italic')
# 我方提供给第三方的资源
draw_resource_flow((my_center[0] + 1, my_center[1] + 0.5),
(third_center[0] - 1, third_center[1] - 0.5),
'#3060a0', '情报/物资')
# 第三方损失的资源
draw_resource_flow((third_center[0] - 1, third_center[1] - 1),
(enemy_center[0] + 1, enemy_center[1] + 1.5),
'#30a030', '兵力消耗')
# 敌方损失的资源
draw_resource_flow((enemy_center[0] - 1, enemy_center[1] + 1),
(third_center[0] + 1, third_center[1] - 1.5),
'#a03030', '领土损失')
# 绘制策略原理图
principles = [
"核心原理: 避免直接冲突",
"关键要素:",
"1. 寻找有利的'刀'(第三方力量)",
"2. 制造合理的'借口'(矛盾或利益)",
"3. 隐藏自身真实意图",
"4. 控制资源投入程度",
"5. 把握介入时机"
]
for i, text in enumerate(principles):
ax.text(11, 9.9 - i * 0.6, text, ha='left', va='top',
fontsize=10 if i > 1 else (11 if i == 1 else 12),
bbox=dict(facecolor='#f9f9e0', alpha=0.7, edgecolor='#d0d0a0') if i > 0 else None)
# 绘制时间线
ax.plot([2, 12], [0.5, 0.5], 'k-', linewidth=1)
timeline_points = [3, 5, 8, 10]
timeline_labels = ["制造矛盾", "提供诱因", "第三方行动", "坐收渔利"]
for i, (x, label) in enumerate(zip(timeline_points, timeline_labels)):
ax.plot([x, x], [0.4, 0.6], 'k-', linewidth=1)
ax.text(x, 0.7, f"阶段 {i + 1}\n{label}", ha='center', fontsize=9)
ax.text(x, 0.3, f"时间 +{i}", ha='center', fontsize=8, style='italic')
# 添加图例
legend_elements = [
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#3060a0', markersize=10, label='我方势力'),
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#a03030', markersize=10, label='敌方势力'),
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#30a030', markersize=10, label='第三方势力'),
plt.Line2D([0], [0], color='#3060a0', linestyle='dashed', label='信息操控'),
plt.Line2D([0], [0], color='#30a030', label='攻击行动'),
plt.Line2D([0], [0], color='#30a030', linestyle='-', label='资源流动')
]
ax.legend(handles=legend_elements, loc='lower center',
bbox_to_anchor=(0.5, -0.05), ncol=3,
facecolor='#f0f0d0', edgecolor='#c0c0a0',
fontsize=10)
plt.tight_layout()
plt.savefig('借刀杀人.png', dpi=300, bbox_inches='tight', facecolor='#f0e6d2')
plt.show()
以逸待劳
困敌之势,不以战;损刚益柔。
养精蓄锐,待敌疲惫时出击。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Polygon, Circle, Ellipse, Arrow
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.axis('off')
plt.title('以逸待劳策略示意图', fontsize=20, pad=20, weight='bold', color='#2c3e50')
# 设置背景为战场地形
# 高地 - 我方阵地
hill = Polygon(np.array([(0, 0), (0, 6), (3, 7), (6, 8), (9, 7), (12, 6), (14, 5), (14, 0)]),
closed=True, facecolor='#8e9e7e', edgecolor='#5a6b4c', alpha=0.9)
ax.add_patch(hill)
# 平原 - 敌军行进区域
plain = Rectangle((0, 0), 14, 5, facecolor='#b8a07c', alpha=0.7, edgecolor='none')
ax.add_patch(plain)
# 河流
river_x = np.linspace(1, 13, 100)
river_y = 1.5 + 0.3 * np.sin(0.7 * river_x)
ax.plot(river_x, river_y, color='#3498db', linewidth=3, alpha=0.8)
ax.fill_between(river_x, river_y, 0, color='#2980b9', alpha=0.3)
# 添加树木
def draw_tree(x, y, size=1.0):
trunk = Rectangle((x - 0.1 * size, y), 0.2 * size, 0.8 * size, facecolor='#8b4513')
leaves = Ellipse((x, y + 1.2 * size), 1.2 * size, 1.5 * size, facecolor='#27ae60')
ax.add_patch(trunk)
ax.add_patch(leaves)
for i in range(15):
x = np.random.uniform(1, 13)
y = np.random.uniform(0.5, 4.5)
if 5 < x < 9: # 避免在关键区域添加树木
continue
draw_tree(x, y, size=np.random.uniform(0.7, 1.2))
# 绘制我方军队 - 在高地上休整
def draw_soldier(x, y, color, resting=False, size=1.0):
# 身体
body = Ellipse((x, y), 0.5 * size, 0.8 * size, facecolor=color)
# 头部
head = Circle((x, y + 0.5 * size), 0.2 * size, facecolor='#f1c27d')
if resting:
# 休息姿势
arm1 = Rectangle((x - 0.3 * size, y - 0.2 * size), 0.3 * size, 0.1 * size,
facecolor=color, angle=30)
arm2 = Rectangle((x + 0.1 * size, y - 0.1 * size), 0.3 * size, 0.1 * size,
facecolor=color, angle=-20)
# 闭眼
eye = Polygon(np.array([[x - 0.1 * size, y + 0.55 * size],
[x + 0.1 * size, y + 0.55 * size],
[x + 0.05 * size, y + 0.52 * size]]),
closed=True, facecolor='black')
ax.add_patch(eye)
else:
# 站立姿势
arm1 = Rectangle((x - 0.3 * size, y), 0.3 * size, 0.1 * size, facecolor=color, angle=45)
arm2 = Rectangle((x + 0.1 * size, y), 0.3 * size, 0.1 * size, facecolor=color, angle=-45)
# 眼睛
eye1 = Circle((x - 0.08 * size, y + 0.55 * size), 0.03 * size, facecolor='black')
eye2 = Circle((x + 0.08 * size, y + 0.55 * size), 0.03 * size, facecolor='black')
ax.add_patch(eye1)
ax.add_patch(eye2)
# 腿
leg1 = Rectangle((x - 0.15 * size, y - 0.5 * size), 0.15 * size, 0.6 * size, facecolor=color)
leg2 = Rectangle((x, y - 0.5 * size), 0.15 * size, 0.6 * size, facecolor=color)
ax.add_patch(body)
ax.add_patch(head)
ax.add_patch(arm1)
ax.add_patch(arm2)
ax.add_patch(leg1)
ax.add_patch(leg2)
return [body, head, arm1, arm2, leg1, leg2]
# 我方军队在高地上休整(蓝色)
my_soldiers = []
for i in range(20):
x = np.random.uniform(2, 12)
y = np.random.uniform(6, 7.5)
soldier = draw_soldier(x, y, '#3498db', resting=True, size=0.8)
my_soldiers.extend(soldier)
# 绘制帐篷
def draw_tent(x, y, size=1.0):
# 帐篷主体
tent = Polygon(np.array([[x, y + size],
[x - 0.8 * size, y],
[x + 0.8 * size, y]]),
closed=True, facecolor='#e74c3c', edgecolor='#c0392b')
# 门
door = Rectangle((x - 0.2 * size, y), 0.4 * size, 0.3 * size, facecolor='#f39c12')
ax.add_patch(tent)
ax.add_patch(door)
# 营地设施
draw_tent(4, 6.5, size=1.5)
draw_tent(8, 6.8, size=1.2)
draw_tent(10, 6.3, size=1.3)
# 篝火
fire = plt.Circle((6, 6.5), 0.4, color='#e67e22', alpha=0.7)
ax.add_patch(fire)
for i in range(8):
angle = np.random.uniform(0, 2 * np.pi)
length = np.random.uniform(0.2, 0.6)
dx = length * np.cos(angle)
dy = length * np.sin(angle)
ax.plot([6, 6 + dx], [6.5, 6.5 + dy], color='#f1c40f', linewidth=2, alpha=0.7)
# 绘制敌军 - 在平原上行军疲惫
def draw_tired_soldier(x, y, color, size=1.0):
# 身体(弯腰)
body = Ellipse((x, y - 0.1 * size), 0.5 * size, 0.7 * size, facecolor=color)
# 头部
head = Circle((x, y + 0.2 * size), 0.2 * size, facecolor='#f1c27d')
# 手臂(下垂)
arm1 = Rectangle((x - 0.3 * size, y - 0.3 * size), 0.3 * size, 0.1 * size, facecolor=color, angle=-30)
arm2 = Rectangle((x + 0.1 * size, y - 0.4 * size), 0.3 * size, 0.1 * size, facecolor=color, angle=20)
# 腿(沉重)
leg1 = Rectangle((x - 0.15 * size, y - 0.7 * size), 0.15 * size, 0.6 * size, facecolor=color, angle=10)
leg2 = Rectangle((x, y - 0.8 * size), 0.15 * size, 0.6 * size, facecolor=color, angle=-5)
# 汗水
for i in range(3):
sweat = plt.Circle((x - 0.1 + i * 0.1, y + 0.3 * size), 0.03, color='#3498db', alpha=0.7)
ax.add_patch(sweat)
ax.add_patch(body)
ax.add_patch(head)
ax.add_patch(arm1)
ax.add_patch(arm2)
ax.add_patch(leg1)
ax.add_patch(leg2)
return [body, head, arm1, arm2, leg1, leg1]
# 敌军在平原上行军(红色)
enemy_soldiers = []
for i in range(15):
x = 1 + i * 0.8
y = 3.0 + np.random.uniform(-0.1, 0.1)
soldier = draw_tired_soldier(x, y, '#e74c3c', size=0.9)
enemy_soldiers.extend(soldier)
# 绘制行军路线
ax.plot([0.5, 13.5], [3.0, 3.0], 'r--', linewidth=1, alpha=0.7)
# 添加策略说明
texts = [
("我军阵地(高地)", (7, 8.0), '#2c3e50'),
("养精蓄锐", (7, 7.7), '#3498db'),
("构筑工事", (4, 6.0), '#3498db'),
("充分补给", (8, 6.0), '#3498db'),
("观察敌情", (10, 6.0), '#3498db'),
("敌军行军(平原)", (7, 4.5), '#2c3e50'),
("长途跋涉", (7, 4.2), '#e74c3c'),
("补给困难", (7, 3.9), '#e74c3c'),
("士气低落", (7, 3.6), '#e74c3c'),
("以逸待劳:养精蓄锐,待敌疲惫时出击", (7, 9.5), '#2c3e50'),
("时机成熟!", (12, 7.0), '#f39c12', 14)
]
for text in texts:
if len(text) == 3:
text, pos, color = text
size = 11
else:
text, pos, color, size = text
ax.text(pos[0], pos[1], text, ha='center', va='center',
color=color, fontsize=size, weight='bold')
# 绘制策略阶段
phases = [
("1. 占据有利地形", (2, 2.5), '#3498db'),
("2. 休整准备", (2, 2.0), '#3498db'),
("3. 观察敌军动向", (2, 1.5), '#3498db'),
("4. 敌军疲惫到达", (12, 2.5), '#e74c3c'),
("5. 发起攻击", (12, 2.0), '#f39c12'),
("6. 取得胜利", (12, 1.5), '#27ae60')
]
for text, pos, color in phases:
ax.text(pos[0], pos[1], text, ha='center', va='center',
color=color, fontsize=10, weight='bold',
bbox=dict(facecolor='#ecf0f1', alpha=0.8, edgecolor=color))
# 绘制时间线
ax.plot([3, 11], [1.0, 1.0], 'k-', linewidth=1.5)
time_points = [4, 6, 8, 10]
time_labels = ["敌军出发", "行军途中", "到达战场", "我军出击"]
for i, (x, label) in enumerate(zip(time_points, time_labels)):
ax.plot([x, x], [0.9, 1.1], 'k-', linewidth=1.5)
ax.text(x, 1.2, f"阶段 {i + 1}\n{label}", ha='center', fontsize=9, weight='bold')
# 添加时间标签
ax.text(x, 0.7, f"时间: {i * 4}小时", ha='center', fontsize=8, style='italic')
# 绘制攻击箭头
attack_arrow = Arrow(8, 7.0, 4.0, -3.0, width=0.8, color='#f39c12', alpha=0.9)
ax.add_patch(attack_arrow)
# 添加能量对比图
ax.text(1, 9.0, "军队状态对比", fontsize=12, weight='bold', color='#2c3e50')
# 我军能量
ax.plot([2, 2], [8.5, 9.5], 'b-', linewidth=8, solid_capstyle='round')
ax.text(2, 9.7, "我军", ha='center', fontsize=10, color='#3498db')
ax.text(2, 8.3, "高", ha='center', fontsize=9, color='#3498db')
# 敌军能量
ax.plot([3.5, 3.5], [8.5, 7.0], 'r-', linewidth=8, solid_capstyle='round')
ax.text(3.5, 9.7, "敌军", ha='center', fontsize=10, color='#e74c3c')
ax.text(3.5, 6.8, "低", ha='center', fontsize=9, color='#e74c3c')
# 能量变化箭头
ax.annotate('', xy=(2.2, 8.5), xytext=(2.2, 9.5),
arrowprops=dict(arrowstyle='->', color='#3498db', linewidth=2))
ax.text(2.4, 9.0, "保持充沛", rotation=90, ha='left', va='center',
color='#3498db', fontsize=9)
ax.annotate('', xy=(3.3, 8.5), xytext=(3.3, 7.0),
arrowprops=dict(arrowstyle='->', color='#e74c3c', linewidth=2))
ax.text(3.1, 7.8, "逐渐消耗", rotation=90, ha='right', va='center',
color='#e74c3c', fontsize=9)
# 添加策略原理
principles = [
"策略原理:",
"1. 选择有利地形 - 高地提供防御优势",
"2. 充分休息补给 - 保持最佳状态",
"3. 迫使敌人移动 - 消耗敌军体力",
"4. 耐心等待时机 - 待敌疲惫不堪",
"5. 集中力量出击 - 一举击溃敌军"
]
for i, text in enumerate(principles):
ax.text(12.5, 9.0 - i * 0.5, text, ha='left', va='top',
fontsize=10 if i > 0 else 11,
color='#2c3e50',
bbox=dict(facecolor='#ecf0f1', alpha=0.7, edgecolor='#bdc3c7') if i > 0 else None)
# 添加图例
legend_elements = [
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#3498db', markersize=10, label='我军士兵'),
plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='#e74c3c', markersize=10, label='敌军士兵'),
plt.Line2D([0], [0], color='#3498db', linewidth=3, label='我军阵地'),
plt.Line2D([0], [0], color='#b8a07c', linewidth=3, label='平原地形'),
plt.Line2D([0], [0], color='#f39c12', linewidth=3, label='出击时机')
]
ax.legend(handles=legend_elements, loc='lower center',
bbox_to_anchor=(0.5, -0.05), ncol=3,
facecolor='#ecf0f1', edgecolor='#bdc3c7',
fontsize=10)
plt.tight_layout()
plt.savefig('以逸待劳.png', dpi=300, bbox_inches='tight', facecolor='#ecf0f1')
plt.show()
趁火打劫
敌之害大,就势取利,刚决柔也。
趁敌方陷入危机时发动攻击。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon, Arrow
import matplotlib.patheffects as path_effects
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 8))
ax.set_xlim(0, 10)
ax.set_ylim(0, 6)
ax.set_aspect('equal')
ax.axis('off')
# 设置背景颜色
fig.patch.set_facecolor('#f0f8ff')
ax.set_facecolor('#f0f8ff')
# 绘制标题
title = ax.text(5, 5.5, '趁火打劫策略示意图',
fontsize=24, ha='center', va='center', fontweight='bold',
color='#8B0000')
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='gold')])
# 添加副标题
subtitle = ax.text(5, 5.1, '敌之害大,就势取利,刚决柔也',
fontsize=16, ha='center', va='center',
fontstyle='italic', color='#333333')
# 绘制城堡(敌人基地)
castle = Rectangle((1, 1), 2, 2, color='#8B4513', alpha=0.8)
castle_roof = Polygon(np.array([[0.8, 3.0], [1.5, 3.8], [2.5, 3.8], [3.2, 3.0]], dtype=np.float64),
color='#A52A2A')
castle_window = Rectangle((1.4, 1.8), 0.4, 0.4, color='yellow')
castle_door = Rectangle((1.8, 1), 0.4, 0.6, color='#654321')
ax.add_patch(castle)
ax.add_patch(castle_roof)
ax.add_patch(castle_window)
ax.add_patch(castle_door)
# 添加城堡标签
ax.text(2, 0.8, '敌人基地', fontsize=12, ha='center', color='#8B4513')
# 绘制火焰(表示敌人危机)
flames = []
for i in range(5):
x = np.random.uniform(1.2, 2.8)
y = np.random.uniform(3.1, 3.8)
size = np.random.uniform(0.3, 0.6)
flame = Polygon([
[float(x), float(y)], # 显式转换坐标值为float
[float(x - size/2), float(y - size)],
[float(x), float(y - size/3)],
[float(x + size/2), float(y - size)]
], color='#FF4500')
flames.append(flame)
ax.add_patch(flame)
# 添加烟雾
for i in range(8):
x = np.random.uniform(0.5, 3.5)
y = np.random.uniform(3.5, 4.5)
size = np.random.uniform(0.2, 0.5)
smoke = Circle((x, y), size, color='#A9A9A9', alpha=0.4)
ax.add_patch(smoke)
# 绘制我方部队
for i in range(3):
x = 4.5 + i * 1.5
y = 1.5
soldier = Circle((x, y), 0.3, color='#006400')
ax.add_patch(soldier)
ax.plot([x, x], [y - 0.3, y - 0.8], color='#006400', linewidth=2)
ax.plot([x - 0.2, x + 0.2], [y - 0.5, y - 0.5], color='#006400', linewidth=2)
ax.plot([x, x - 0.3], [y - 0.8, y - 1.2], color='#006400', linewidth=2)
ax.plot([x, x + 0.3], [y - 0.8, y - 1.2], color='#006400', linewidth=2)
# 绘制武器
ax.plot([x - 0.3, x + 0.3], [y + 0.15, y + 0.15], color='#2F4F4F', linewidth=3)
# 添加我方部队标签
ax.text(6, 1.9, '我方部队', fontsize=12, ha='center', color='#006400')
# 绘制箭头表示进攻方向
arrow = Arrow(4.5, 1.5, -1.8, 0, width=0.3, color='#8B0000', alpha=0.8)
ax.add_patch(arrow)
# 绘制策略说明框
strategy_box = Rectangle((5.5, 2.3), 4, 2.5, color='#FFFACD', alpha=0.9, ec='#DAA520', lw=2)
ax.add_patch(strategy_box)
# 添加策略说明文本
strategy_text = [
'趁火打劫策略解析:',
'',
'• 核心思想: 当敌人遭遇危机(如内乱、灾害、外敌)时',
'• 行动原则: 抓住时机,果断出击,获取最大利益',
'• 实施要点:',
' 1. 密切关注敌方动态,及时发现"火情"',
' 2. 快速评估形势,制定攻击方案',
' 3. 迅速行动,不给敌人喘息机会',
' 4. 夺取关键资源,扩大战果',
'',
'《三十六计》:"敌之害大,就势取利,刚决柔也"'
]
for i, text in enumerate(strategy_text):
y_pos = 4.7 - i * 0.22
ax.text(5.7, y_pos, text, fontsize=10, ha='left', va='top', color='#333333')
# 绘制装饰性边框
border = Rectangle((0.1, 0.1), 9.8, 5.8, fill=None, ec='#DAA520', lw=3, linestyle='--', alpha=0.7)
ax.add_patch(border)
# 添加火焰图标装饰
for i in range(10):
x = np.random.uniform(0.5, 9.5)
y = np.random.uniform(0.5, 5.5)
size = np.random.uniform(0.05, 0.15)
flame_icon = Polygon([
[x, y + size],
[x - size / 2, y],
[x, y + size / 3],
[x + size / 2, y]
], color='#FF4500', alpha=0.3)
ax.add_patch(flame_icon)
plt.savefig('趁火打劫.png', dpi=300, bbox_inches='tight', facecolor='#ecf0f1')
plt.tight_layout()
plt.show()
声东击西
敌志乱萃,不虞,坤下兑上之象。利其不自主而取之。
佯攻一处,实则突袭另一目标。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off')
ax.set_title('声东击西策略示意图', fontsize=18, pad=20)
# 绘制地形元素
river = Polygon([[1.0, 1.0], [3.0, 3.0], [5.0, 2.5], [7.0, 4.0], [9.0, 1.0]], closed=False,
fill=False, color='blue', lw=2, alpha=0.7)
mountain = Polygon([[2.0, 5.0], [4.0, 7.0], [6.0, 6.0], [8.0, 7.5], [7.0, 5.0]],
closed=True, fill=True, color='#8B4513', alpha=0.4)
city = Rectangle((8, 1.5), 1.5, 1.5, color='#A9A9A9', alpha=0.8)
forest = Polygon([[1.0, 6.0], [2.0, 7.0], [3.0, 6.5], [4.0, 7.2], [3.0, 5.5]],
closed=True, fill=True, color='#2E8B57', alpha=0.5)
# 添加地形到画布
ax.add_patch(river)
ax.add_patch(mountain)
ax.add_patch(city)
ax.add_patch(forest)
# 添加地形标注
ax.text(5, 0.5, '河流', color='blue', fontsize=10, ha='center')
ax.text(5.5, 6.5, '山脉', color='#8B4513', fontsize=10, ha='center')
ax.text(8.75, 1.0, '目标城市', color='black', fontsize=10, ha='center')
ax.text(2.5, 6.2, '森林', color='#2E8B57', fontsize=10, ha='center')
# 初始部队位置
red_team = {
'main': {'pos': np.array([1.0, 3.5]), 'size': 8},
'diversion': {'pos': np.array([2.0, 6.0]), 'size': 4}
}
blue_team = {
'defense_east': {'pos': np.array([6.0, 6.5]), 'size': 10},
'defense_west': {'pos': np.array([7.0, 3.0]), 'size': 6}
}
# 创建部队标记
red_main = Circle(red_team['main']['pos'], radius=0.15, color='red', ec='black')
red_diversion = Circle(red_team['diversion']['pos'], radius=0.12, color='red', ec='black')
blue_east = Circle(blue_team['defense_east']['pos'], radius=0.15, color='blue', ec='black')
blue_west = Circle(blue_team['defense_west']['pos'], radius=0.12, color='blue', ec='black')
# 添加部队标记
ax.add_patch(red_main)
ax.add_patch(red_diversion)
ax.add_patch(blue_east)
ax.add_patch(blue_west)
# 添加部队标注
ax.text(1.0, 3.0, '红军主力', color='red', fontsize=10, ha='center')
ax.text(2.0, 5.7, '佯攻部队', color='red', fontsize=9, ha='center')
ax.text(6.0, 6.0, '蓝军东侧防线', color='blue', fontsize=10, ha='center')
ax.text(7.0, 2.5, '蓝军西侧防线', color='blue', fontsize=9, ha='center')
# 添加策略说明
strategy_text = ax.text(2.0, 7.5, "策略: 佯攻东侧(山脉),实攻西侧(城市)",
fontsize=14, color='darkred', ha='left')
strategy_text.set_path_effects([path_effects.withStroke(linewidth=3, foreground='w')])
# 创建动态元素
diversion_arrow = Arrow(2.0, 6.0, 1.5, 1.0, width=0.1, color='red', alpha=0.7)
main_arrow = Arrow(1.0, 3.5, 0.5, 0.0, width=0.1, color='red', alpha=0.7)
diversion_path, = ax.plot([], [], 'r--', lw=1, alpha=0.5)
main_path, = ax.plot([], [], 'r-', lw=2)
ax.add_patch(diversion_arrow)
ax.add_patch(main_arrow)
# 动画更新函数
def update(frame):
# 更新佯攻部队位置和箭头
if frame < 20:
dx = 0.15
dy = 0.08
red_diversion.center = red_team['diversion']['pos'] + np.array([dx * frame, dy * frame])
diversion_arrow.set_data(
x=red_diversion.center[0],
y=red_diversion.center[1],
dx=1.5,
dy=1.0
)
# 更新佯攻路径
x_data = np.linspace(red_team['diversion']['pos'][0], red_diversion.center[0], 10)
y_data = np.linspace(red_team['diversion']['pos'][1], red_diversion.center[1], 10)
diversion_path.set_data(x_data, y_data)
# 更新主力部队位置
if frame > 5:
red_main.center = red_team['main']['pos'] + np.array([0.2 * (frame - 5), 0])
main_arrow.set_data(
x=red_main.center[0],
y=red_main.center[1],
dx=0.5,
dy=0
)
# 更新主力路径
x_data = np.linspace(red_team['main']['pos'][0], red_main.center[0], 10)
y_data = np.linspace(red_team['main']['pos'][1], red_main.center[1], 10)
main_path.set_data(x_data, y_data)
# 第二阶段:主力加速进攻
elif frame < 40:
# 佯攻部队继续前进
dx = 0.15
dy = 0.08
red_diversion.center = red_diversion.center + np.array([dx, dy])
diversion_arrow.set_data(
x=red_diversion.center[0],
y=red_diversion.center[1],
dx=1.5,
dy=1.0
)
# 主力部队加速前进
red_main.center = red_main.center + np.array([0.4, 0])
main_arrow.set_data(
x=red_main.center[0],
y=red_main.center[1],
dx=0.5,
dy=0
)
# 更新路径
x_data = np.append(diversion_path.get_xdata(), red_diversion.center[0])
y_data = np.append(diversion_path.get_ydata(), red_diversion.center[1])
diversion_path.set_data(x_data, y_data)
x_data = np.append(main_path.get_xdata(), red_main.center[0])
y_data = np.append(main_path.get_ydata(), red_main.center[1])
main_path.set_data(x_data, y_data)
# 蓝军东侧部队被吸引
if frame > 25:
blue_east.center = blue_east.center + np.array([0.1, 0.05])
# 第三阶段:主力到达目标
else:
if frame < 60:
# 主力部队到达城市
if np.linalg.norm(red_main.center - np.array([8.75, 2.25])) > 0.5:
direction = (np.array([8.75, 2.25]) - red_main.center) * 0.1
red_main.center = red_main.center + direction
main_arrow.set_data(
x=red_main.center[0],
y=red_main.center[1],
dx=direction[0] * 2,
dy=direction[1] * 2
)
else:
# 占领城市
city.set_color('red')
city.set_alpha(0.6)
strategy_text.set_text("策略成功: 佯攻部队吸引敌军主力,红军主力攻占城市!")
# 更新路径
x_data = np.append(main_path.get_xdata(), red_main.center[0])
y_data = np.append(main_path.get_ydata(), red_main.center[1])
main_path.set_data(x_data, y_data)
return red_diversion, diversion_arrow, diversion_path, red_main, main_arrow, main_path, blue_east, city
# 创建动画
ani = FuncAnimation(fig, update, frames=60, interval=100, blit=False)
# 添加图例和说明
ax.text(0.5, 0.2, '三十六计·声东击西:\n"敌志乱萃,不虞,坤下兑上之象。利其不自主而取之。"',
fontsize=12, color='#8B0000', ha='left', va='bottom', wrap=True,
bbox=dict(boxstyle='round', alpha=0.2, color='#FFE4E1'))
# 保存动画
ani.save('声东击西.gif', writer='pillow', fps=10)
plt.tight_layout()
plt.show()
敌战计(势均力敌时的对抗策略)
无中生有
诳也,非诳也,实其所诳也。少阴、太阴、太阳。
制造假象迷惑敌人,后化虚为实。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, Ellipse
import matplotlib.patheffects as path_effects
import random
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 8))
ax.set_xlim(0, 12)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off')
ax.set_title('无中生有策略示意图', fontsize=20, pad=20, color='darkred')
# 绘制地形元素
# 城池
city_wall = Rectangle((2, 2), 5, 4, fill=False, color='#8B4513', lw=3)
city_gate = Rectangle((4.5, 2), 1, 0.5, color='#A52A2A', alpha=0.8)
city_inner = Rectangle((2.5, 2.5), 4, 3, fill=False, color='gray', lw=1, ls='--')
# 河流
river = Polygon([[0, 0], [1, 1.5], [3, 0.5], [5, 2], [7, 1], [9, 3], [12, 2]],
closed=False, fill=False, color='blue', lw=2, alpha=0.7)
# 山脉
mountains = [
Polygon([[9, 5], [10, 7], [11, 6], [12, 7]], closed=True, fill=True, color='#8B4513', alpha=0.6),
Polygon([[0, 7], [1, 6], [2, 7], [3, 6.5]], closed=True, fill=True, color='#8B4513', alpha=0.6)
]
# 森林
forest = Polygon([[10, 1], [11, 2], [11.5, 1.5], [12, 2], [11.5, 0.5]],
closed=True, fill=True, color='#2E8B57', alpha=0.6)
# 添加地形到画布
ax.add_patch(city_wall)
ax.add_patch(city_gate)
ax.add_patch(city_inner)
ax.add_patch(river)
ax.add_patch(forest)
for mountain in mountains:
ax.add_patch(mountain)
# 添加地形标注
ax.text(4.5, 1.8, '城门', color='#8B4513', fontsize=10, ha='center')
ax.text(7, 0.5, '河流', color='blue', fontsize=10, ha='center')
ax.text(10.5, 6.5, '山脉', color='#8B4513', fontsize=10, ha='center')
ax.text(11, 1.2, '森林', color='#2E8B57', fontsize=10, ha='center')
ax.text(4.5, 4.5, '城池', color='black', fontsize=12, ha='center', weight='bold')
# 初始部队位置
red_team_real = {'pos': np.array([10.5, 3.5]), 'size': 8} # 真实主力
red_team_fake = {'pos': np.array([1.5, 3.0]), 'size': 5} # 假部队
blue_team = {'pos': np.array([4.5, 4.0]), 'size': 10} # 守城部队
# 创建部队标记
red_real = Circle(red_team_real['pos'], radius=0.2, color='red', ec='black', alpha=0.8)
red_fake = Circle(red_team_fake['pos'], radius=0.2, color='red', ec='black', alpha=0.3) # 半透明表示虚假
blue_army = Circle(blue_team['pos'], radius=0.25, color='blue', ec='black', alpha=0.8)
# 添加部队标记
ax.add_patch(red_real)
ax.add_patch(red_fake)
ax.add_patch(blue_army)
# 添加部队标注
ax.text(10.5, 3.2, '红军主力(隐藏)', color='red', fontsize=10, ha='center')
ax.text(1.5, 2.7, '红军佯动部队(虚假)', color='red', fontsize=10, ha='center', alpha=0.7)
ax.text(4.5, 3.7, '守城部队', color='blue', fontsize=10, ha='center')
# 创建虚假部队元素(用于动画)
fake_troops = []
for i in range(15):
# 创建半透明的假士兵
troop = Circle((0, 0), radius=0.1, color='red', ec='black', alpha=0)
ax.add_patch(troop)
fake_troops.append(troop)
# 添加策略说明
strategy_text = ax.text(1.0, 7.5, "策略: 制造假象,迷惑敌人",
fontsize=16, color='darkred', ha='left')
strategy_text.set_path_effects([path_effects.withStroke(linewidth=3, foreground='w')])
# 创建动态元素
fake_arrow = Arrow(red_team_fake['pos'][0], red_team_fake['pos'][1], 1, 0,
width=0.2, color='red', alpha=0.3)
real_arrow = Arrow(red_team_real['pos'][0], red_team_real['pos'][1], -1, 0,
width=0.2, color='red', alpha=0)
ax.add_patch(fake_arrow)
ax.add_patch(real_arrow)
# 添加烟雾效果
smoke_particles = []
for _ in range(30):
smoke = Ellipse((0, 0), width=0.2, height=0.3, angle=0,
color='#AAAAAA', alpha=0)
ax.add_patch(smoke)
smoke_particles.append(smoke)
# 添加计策解释
quote_text = ax.text(0.5, 0.8,
'三十六计·无中生有:\n"诳也,非诳也,实其所诳也。少阴、太阴、太阳。"\n——用假象欺骗敌人,但并非一假到底,而是假中有真。\n由虚假逐渐转化为真实,以造成敌人的错觉。',
fontsize=14, color='#8B0000', ha='left', va='bottom', wrap=True,
bbox=dict(boxstyle='round', alpha=0.2, color='#FFE4E1'))
# 动画更新函数
def update(frame):
# 第一阶段:制造假象(1-20帧)
if frame < 20:
# 显示虚假部队
if frame < 15:
# 逐渐显示虚假部队
for i in range(min(frame, len(fake_troops))):
fake_troops[i].set_alpha(0.3)
fake_troops[i].center = (
red_team_fake['pos'][0] + random.uniform(-1.0, 1.0),
red_team_fake['pos'][1] + random.uniform(-0.8, 0.8)
)
# 制造烟雾效果
for i, smoke in enumerate(smoke_particles):
if frame > 5 and i < frame - 5:
smoke.set_alpha(0.5)
smoke.set_center((
1.0 + random.uniform(0, 3),
2.5 + random.uniform(0, 2)
))
smoke.set_width(random.uniform(0.1, 0.3))
smoke.set_height(random.uniform(0.2, 0.5))
# 虚假部队向前移动
if frame > 8:
dx = 0.1
red_fake.center = red_team_fake['pos'] + np.array([dx * (frame - 8), 0])
fake_arrow.set_data(
x=red_fake.center[0],
y=red_fake.center[1],
dx=1,
dy=0
)
# 更新策略文本
strategy_text.set_text(f"策略: 制造假象,迷惑敌人 (显示虚假部队)")
# 第二阶段:吸引敌军注意(20-40帧)
elif frame < 40:
# 虚假部队继续前进
dx = 0.1
red_fake.center = red_fake.center + np.array([dx, 0])
fake_arrow.set_data(
x=red_fake.center[0],
y=red_fake.center[1],
dx=1,
dy=0
)
# 守城部队被吸引
if frame > 25:
dy = 0.08
blue_army.center = blue_team['pos'] + np.array([0, dy * (frame - 25)])
# 更新策略文本
strategy_text.set_text(f"策略: 成功吸引守军注意!")
# 第三阶段:真实部队出击(40-60帧)
elif frame < 60:
# 虚假部队逐渐消失(透明度降低)
for troop in fake_troops:
alpha = troop.get_alpha()
if alpha > 0:
troop.set_alpha(max(0, alpha - 0.02))
# 真实部队出击
if frame < 50:
dx = -0.25
red_real.center = red_team_real['pos'] + np.array([dx * (frame - 40), 0])
real_arrow.set_alpha(0.8)
real_arrow.set_data(
x=red_real.center[0],
y=red_real.center[1],
dx=-1,
dy=0
)
else:
# 真实部队到达城门
red_real.center = (5.0, 2.5)
real_arrow.set_data(
x=5.0,
y=2.5,
dx=0,
dy=0.5
)
strategy_text.set_text("策略成功: 真实部队趁虚而入!")
# 第四阶段:揭示真相(60-75帧)
else:
if frame == 61:
# 添加揭示文本
reveal_text = ax.text(3.0, 7.0, "真相揭示:",
fontsize=18, color='darkgreen', ha='left')
reveal_text.set_path_effects([path_effects.withStroke(linewidth=2, foreground='w')])
# 添加解释文本
ax.text(3.0, 6.2, "• 东部部队只是假象\n• 真实主力从西部森林出击\n• 守军被假象迷惑,未及时防御西部",
fontsize=14, color='darkgreen', ha='left')
# 添加成功标志
success_text = ax.text(8.0, 6.0, "无中生有成功!",
fontsize=24, color='red', ha='center', weight='bold')
success_text.set_path_effects([path_effects.withStroke(linewidth=4, foreground='yellow')])
# 添加箭头指示
ax.annotate('假象', xy=(2.0, 3.0), xytext=(0.5, 4.0),
arrowprops=dict(arrowstyle='->', color='red', alpha=0.5),
fontsize=12, color='red')
ax.annotate('真实', xy=(5.0, 2.5), xytext=(8.0, 1.0),
arrowprops=dict(arrowstyle='->', color='red'),
fontsize=12, color='red')
# 添加策略总结
ax.text(8.0, 0.8, "无中生有精髓:\n以虚掩实,假中藏真\n虚张声势,实攻其虚",
fontsize=14, color='darkred', ha='center',
bbox=dict(boxstyle='round', alpha=0.2, color='#FFE4E1'))
return fake_troops + [red_fake, red_real, blue_army, fake_arrow, real_arrow] + smoke_particles
# 创建动画
ani = FuncAnimation(fig, update, frames=75, interval=150, blit=False)
# 添加来源注释
plt.figtext(0.5, 0.01, "三十六计 - 无中生有: 制造假象,迷惑敌人 | 可视化: Python Matplotlib",
ha="center", fontsize=10, color='gray')
plt.tight_layout()
plt.show()
# 保存动画
ani.save('无中生有.gif', writer='pillow', fps=8, dpi=120)
暗渡陈仓
示之以动,利其静而有主,“益动而巽”。
明面佯动吸引注意,暗地实施真实计划。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Polygon, Circle
from matplotlib.collections import PatchCollection
import matplotlib.patheffects as path_effects
# 创建图形和坐标轴
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(-1, 15)
ax.set_ylim(-1, 10)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 设置背景颜色 - 古代地图风格
fig.patch.set_facecolor('#f0e6d2')
ax.set_facecolor('#f0e6d2')
# 添加标题
title = ax.set_title('暗度陈仓策略示意图', fontsize=22, fontweight='bold', fontfamily='SimHei')
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#8B4513')])
# 绘制山脉
mountains = [
Polygon(np.array([[1, 3], [3, 6], [5, 3]]), closed=True, color='#6B8E23'),
Polygon(np.array([[8, 2], [10, 5], [12, 2]]), closed=True, color='#556B2F'),
Polygon(np.array([[4, 1], [5.5, 4], [7, 1]]), closed=True, color='#5F9EA0'),
Polygon(np.array([[11, 4], [13, 7], [14, 4]]), closed=True, color='#4682B4'),
]
ax.add_collection(PatchCollection(mountains, match_original=True))
# 添加山脉纹理
for i, mountain in enumerate(mountains):
x, y = np.mean(mountain.xy, axis=0)
ax.text(x, y, '山', fontsize=14, ha='center', va='center',
color='#333333', fontfamily='SimHei',
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 绘制河流
river_x = np.array([-0.5, 3, 7, 10, 15])
river_y = np.array([8, 6.5, 7.5, 5, 6])
ax.plot(river_x, river_y, 'b-', linewidth=3, alpha=0.6)
ax.plot(river_x, river_y-0.4, 'b-', linewidth=3, alpha=0.4)
ax.text(7, 8, '河', fontsize=14, ha='center', va='center',
color='#1E90FF', fontfamily='SimHei',
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 绘制主要道路
main_road_x = np.array([0, 5, 10, 14])
main_road_y = np.array([1, 1.5, 2, 1])
ax.plot(main_road_x, main_road_y, 'k--', linewidth=2, alpha=0.7)
ax.text(7, 1.2, '主道', fontsize=12, ha='center', va='center',
fontfamily='SimHei', color='#8B4513')
# 绘制秘密小路
secret_path_x = np.array([0.5, 3, 4.5, 7, 9, 13])
secret_path_y = np.array([2.5, 4, 6, 7, 5, 4])
ax.plot(secret_path_x, secret_path_y, ':', color='#8B4513', linewidth=3, alpha=0.8)
ax.text(7, 6.5, '秘道', fontsize=12, ha='center', va='center',
fontfamily='SimHei', color='#8B4513', rotation=15)
# 绘制城市
city = Circle((13, 2), 0.8, color='#CD5C5C')
ax.add_patch(city)
ax.text(13, 2, '陈仓', fontsize=14, ha='center', va='center',
fontfamily='SimHei', color='white', weight='bold')
# 绘制要塞
fortress = Circle((4, 1.5), 0.6, color='#8B4513')
ax.add_patch(fortress)
ax.text(4, 1.5, '要塞', fontsize=12, ha='center', va='center',
fontfamily='SimHei', color='white', weight='bold')
# 绘制我方营地
camp = Circle((0.5, 2), 0.6, color='#4169E1')
ax.add_patch(camp)
ax.text(0.5, 2, '我军', fontsize=12, ha='center', va='center',
fontfamily='SimHei', color='white', weight='bold')
# 绘制敌方营地
enemy_camp = Circle((12, 1), 0.6, color='#DC143C')
ax.add_patch(enemy_camp)
ax.text(12, 1, '敌军', fontsize=12, ha='center', va='center',
fontfamily='SimHei', color='white', weight='bold')
# 绘制佯攻部队(红色箭头)
ax.arrow(1, 2, 3, 0, head_width=0.4, head_length=0.4, fc='#DC143C', ec='#8B0000',
width=0.1, length_includes_head=True)
ax.arrow(4, 2, 3, 0, head_width=0.4, head_length=0.4, fc='#DC143C', ec='#8B0000',
width=0.1, length_includes_head=True)
ax.arrow(7, 2, 2, 0, head_width=0.4, head_length=0.4, fc='#DC143C', ec='#8B0000',
width=0.1, length_includes_head=True)
# 绘制偷袭部队(蓝色箭头)
ax.arrow(1.5, 2.5, 1.0, 1.0, head_width=0.4, head_length=0.4, fc='#4169E1', ec='#00008B',
width=0.1, length_includes_head=True)
ax.arrow(3, 4, 1.0, 1.5, head_width=0.4, head_length=0.4, fc='#4169E1', ec='#00008B',
width=0.1, length_includes_head=True)
ax.arrow(4.5, 6, 1.5, 0.5, head_width=0.4, head_length=0.4, fc='#4169E1', ec='#00008B',
width=0.1, length_includes_head=True)
ax.arrow(7, 7, 1.0, -1.0, head_width=0.4, head_length=0.4, fc='#4169E1', ec='#00008B',
width=0.1, length_includes_head=True)
ax.arrow(9, 5, 2.5, -0.5, head_width=0.4, head_length=0.4, fc='#4169E1', ec='#00008B',
width=0.1, length_includes_head=True)
ax.arrow(12.5, 4, 0.5, -1.5, head_width=0.4, head_length=0.4, fc='#4169E1', ec='#00008B',
width=0.1, length_includes_head=True)
# 添加说明文本
ax.text(5, 0.5, '佯攻部队吸引敌军注意力', fontsize=14, ha='center', va='center',
fontfamily='SimHei', color='#8B0000', weight='bold',
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
ax.text(5, 8.5, '偷袭部队通过秘道直取陈仓', fontsize=14, ha='center', va='center',
fontfamily='SimHei', color='#00008B', weight='bold',
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 添加策略说明
explanation = """
暗度陈仓策略解析:
1. 我军派出佯攻部队沿主道进攻,吸引敌军主力注意
2. 同时派出精锐部队通过秘密小路迂回至敌军后方
3. 偷袭部队避开敌军主力,直取战略要地"陈仓"
4. 当敌军发现中计时,已失去战略要地,陷入被动
"""
ax.text(0.3, 9.6, explanation, fontsize=13, ha='left', va='top',
fontfamily='SimHei', color='#2F4F4F', linespacing=1.8)
# 添加图例
legend_text = """
图例说明:
红色箭头: 佯攻部队
蓝色箭头: 偷袭部队
虚线: 主道
点线: 秘密小路
红色城池: 战略目标"陈仓"
"""
ax.text(12, 9.5, legend_text, fontsize=11, ha='left', va='top',
fontfamily='SimHei', color='#2F4F4F', linespacing=1.6,
bbox=dict(boxstyle='round,pad=0.5', fc='#FFFAF0', ec='#8B4513', alpha=0.8))
# 添加装饰边框
border = plt.Rectangle((-1, -1), 16, 11, fill=False, ec='#8B4513', lw=3, linestyle='--', alpha=0.5)
ax.add_patch(border)
plt.tight_layout()
plt.savefig('暗度陈仓.png', dpi=300, bbox_inches='tight', facecolor='#ecf0f1')
plt.show()
隔岸观火
阳乖序乱,阴以待逆。暴戾恣睢,其势自毙。
静待敌人内部分裂,再伺机行动。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 9))
fig.patch.set_facecolor('#F0F8FF') # 设置背景色为淡蓝色
# 设置标题
plt.suptitle('隔岸观火策略示意图', fontsize=24, fontweight='bold', color='#8B0000')
plt.title('静观敌营内乱,待其自相残杀', fontsize=18, color='#2F4F4F')
# 绘制策略说明文本
strategy_text = (
'"隔岸观火"源于《孙子兵法》:"敌之害大,就势取利,刚决柔也。"\n'
'当敌人内部矛盾激化时,我方应静观其变,待其自相残杀、力量削弱后再采取行动。'
)
plt.figtext(0.5, 0.03, strategy_text, ha='center', fontsize=16,
bbox=dict(boxstyle="round,pad=0.5", fc="#FFF8DC", ec="#8B4513", lw=2))
# 绘制河流
river = Rectangle((4.5, 0), 1, 9, color='#4682B4', alpha=0.7)
ax.add_patch(river)
# 添加河流波纹
for i in range(50):
x = np.random.uniform(4.5, 5.5)
y = np.random.uniform(0, 9)
size = np.random.uniform(0.05, 0.2)
ax.add_patch(Circle((x, y), size, color='#87CEEB', alpha=0.6))
# 绘制敌方阵营(左岸 - 着火)
# 营地围栏
ax.add_patch(Rectangle((0.5, 1), 3, 6, fill=None, ec='#8B4513', lw=2, ls='--'))
# 帐篷
tent = Polygon(np.array([[1.5, 3], [2.5, 5], [3.5, 3]]), color='#CD5C5C', alpha=0.8)
ax.add_patch(tent)
# 着火点
fires = []
for _ in range(15):
x = np.random.uniform(1, 4)
y = np.random.uniform(2, 6)
size = np.random.uniform(0.1, 0.3)
color = np.random.choice(['#FF4500', '#FF8C00', '#FFD700'])
fires.append(Circle((x, y), size, color=color, alpha=0.8))
for fire in fires:
ax.add_patch(fire)
# 绘制敌方内斗人物
# 人物1(持剑)
ax.add_patch(Circle((1.2, 4.5), 0.3, color='#FFDEAD'))
ax.add_patch(Rectangle((1.2, 3.9), 0.15, 0.8, color='#2F4F4F'))
ax.add_patch(Polygon(np.array([[1.2, 4.2], [1.0, 3.5], [1.4, 3.5]]), color='#2F4F4F'))
ax.add_patch(Polygon(np.array([[1.35, 4.2], [1.35, 3.0], [1.45, 3.0]]), color='#696969')) # 剑
# 人物2(持矛)
ax.add_patch(Circle((3.2, 3.8), 0.3, color='#FFDEAD'))
ax.add_patch(Rectangle((3.2, 3.2), 0.15, 0.8, color='#556B2F'))
ax.add_patch(Polygon(np.array([[3.2, 3.5], [3.0, 2.8], [3.4, 2.8]]), color='#556B2F'))
ax.add_patch(Polygon(np.array([[3.2, 3.5], [2.7, 2.5], [2.9, 2.4]]), color='#808080')) # 矛
# 绘制敌方标签
plt.text(2, 0.5, '敌方阵营', fontsize=16, ha='center', color='#8B0000',
fontweight='bold', path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
plt.text(2, 7.5, '内乱爆发', fontsize=14, ha='center', color='#FF4500',
bbox=dict(boxstyle="round,pad=0.3", fc="#FFF8DC", ec="#FF4500", lw=2))
# 绘制我方阵营(右岸 - 观火)
# 观察台
ax.add_patch(Rectangle((7, 2), 2, 1.5, color='#D2B48C'))
ax.add_patch(Rectangle((7.5, 3.5), 1, 3, color='#A0522D'))
ax.add_patch(Rectangle((7.8, 6.5), 0.4, 0.5, color='#DAA520'))
# 我方观察者
ax.add_patch(Circle((8, 7), 0.3, color='#FFDEAD')) # 头
ax.add_patch(Rectangle((7.9, 6.4), 0.2, 0.6, color='#1E90FF')) # 身体
# 望远镜
ax.add_patch(Polygon(np.array([[8.1, 6.9], [8.8, 6.7], [8.8, 6.8], [8.1, 7.0]]), color='#2F4F4F'))
# 绘制我方旗帜
flag_pole = Rectangle((8.5, 6.5), 0.05, 1.5, color='#8B4513')
flag = Polygon(np.array([[8.55, 8], [8.55, 7.5], [9.0, 7.75]]), color='#FF0000')
ax.add_patch(flag_pole)
ax.add_patch(flag)
# 绘制我方标签
plt.text(8, 0.5, '我方阵营', fontsize=16, ha='center', color='#000080',
fontweight='bold', path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
plt.text(8, 1.5, '静观其变', fontsize=14, ha='center', color='#000080',
bbox=dict(boxstyle="round,pad=0.3", fc="#ADD8E6", ec="#000080", lw=2))
# 绘制策略箭头
# 观察视线
ax.annotate('', xy=(5.5, 5), xytext=(8, 6.8),
arrowprops=dict(arrowstyle='->', color='#4169E1', lw=2, linestyle='-', alpha=0.7),
annotation_clip=False)
plt.text(6.8, 6.5, '观察敌情', fontsize=14, ha='center', color='#000080',
bbox=dict(boxstyle="round,pad=0.3", fc="#E6E6FA", ec="#4169E1", lw=2))
# 策略文本
plt.text(7, 8, '待其自相残杀后', fontsize=15, ha='center', color='#006400',
bbox=dict(boxstyle="round,pad=0.5", fc="#90EE90", ec="#006400", lw=2))
plt.text(7, 8.5, '再一举出击', fontsize=15, ha='center', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.5", fc="#FFB6C1", ec="#8B0000", lw=2))
# 绘制山丘(背景)
hill1 = Polygon(np.array([[0, 0], [0, 3], [2, 4], [4, 2], [5, 0]]), color='#2E8B57', alpha=0.7)
hill2 = Polygon(np.array([[5, 0], [6, 2], [8, 3], [10, 1], [14, 0]]), color='#3CB371', alpha=0.7)
ax.add_patch(hill1)
ax.add_patch(hill2)
# 添加树木
def draw_tree(x, y, size=1):
trunk = Rectangle((x, y), 0.2*size, 0.8*size, color='#8B4513')
crown = Circle((x+0.1*size, y+1*size), 0.5*size, color='#228B22')
ax.add_patch(trunk)
ax.add_patch(crown)
# 左岸树木
draw_tree(0.8, 1.5, 0.8)
draw_tree(3.8, 1.2, 1.0)
draw_tree(2.5, 0.8, 0.7)
# 右岸树木
draw_tree(6.5, 1.5, 1.2)
draw_tree(9.5, 1.0, 0.9)
draw_tree(8.2, 0.7, 1.1)
# 添加云朵
def draw_cloud(x, y, size):
cloud = []
cloud.append(Circle((x, y), size, color='white', alpha=0.9))
cloud.append(Circle((x+size*0.8, y), size*0.8, color='white', alpha=0.9))
cloud.append(Circle((x-size*0.8, y), size*0.8, color='white', alpha=0.9))
cloud.append(Circle((x+size*1.5, y), size*0.7, color='white', alpha=0.9))
for c in cloud:
ax.add_patch(c)
draw_cloud(1, 8, 0.4)
draw_cloud(4, 8.5, 0.5)
draw_cloud(7, 8.2, 0.6)
draw_cloud(10, 8, 0.4)
# 添加烟雾效果
def draw_smoke(x, y, size):
for i in range(1, 6):
ax.add_patch(Circle((x + i*0.3, y + i*0.4), size*(1-i*0.1),
color='#A9A9A9', alpha=0.5/(i*0.5)))
draw_smoke(2.5, 5.5, 0.5)
draw_smoke(3.0, 4.0, 0.4)
draw_smoke(1.8, 4.8, 0.6)
# 设置坐标轴范围
plt.xlim(0, 14)
plt.ylim(0, 9)
# 隐藏坐标轴
plt.axis('off')
# 添加水印
plt.text(13.5, 0.5, '三十六计', fontsize=12, rotation=90, color='gray', alpha=0.3)
plt.tight_layout(rect=[0, 0.05, 1, 0.95])
plt.savefig('隔岸观火.png', dpi=300, bbox_inches='tight')
plt.show()
笑里藏刀
信而安之,阴以图之;备而后动,勿使有变。刚中柔外也。
表面友好,暗中准备攻击。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, Ellipse, Wedge
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
fig.patch.set_facecolor('#FFF8DC') # 设置背景色为浅黄色
# 设置标题
plt.suptitle('笑里藏刀策略示意图', fontsize=24, fontweight='bold', color='#8B0000')
plt.title('表面友好和善,暗藏杀机', fontsize=18, color='#2F4F4F')
# 绘制策略说明文本
strategy_text = (
'"笑里藏刀"出自《旧唐书·李义府传》:"义府貌状温恭,与人语必嬉怡微笑,而褊忌阴贼。...故时人言义府笑中有刀。"\n'
'此计强调表面友善以麻痹敌人,暗中准备致命一击。'
)
plt.figtext(0.5, 0.03, strategy_text, ha='center', fontsize=16,
bbox=dict(boxstyle="round,pad=0.5", fc="#FFF0F5", ec="#8B4513", lw=2))
# 创建两个子图区域展示双面性
ax_left = fig.add_axes([0.05, 0.15, 0.4, 0.7])
ax_right = fig.add_axes([0.55, 0.15, 0.4, 0.7])
# 设置子图背景
ax_left.set_facecolor('#F5FFFA') # 浅绿色背景表示表面和平
ax_right.set_facecolor('#FFF0F5') # 浅红色背景表示暗藏危险
# 隐藏坐标轴
for ax in [ax_left, ax_right]:
ax.set_xticks([])
ax.set_yticks([])
ax.set_xlim(0, 10)
ax.set_ylim(0, 10)
# 添加标题
ax_left.set_title('表面现象:友好和善', fontsize=18, color='#006400', pad=20)
ax_right.set_title('内在本质:暗藏杀机', fontsize=18, color='#8B0000', pad=20)
# ===================== 左侧:表面友好 =====================
# 绘制笑脸人物
face = Circle((5, 6), 1.5, color='#FFDEAD', ec='black')
ax_left.add_patch(face)
# 绘制笑脸眼睛
left_eye = Ellipse((4.3, 6.3), 0.4, 0.6, angle=10, color='white', ec='black')
right_eye = Ellipse((5.7, 6.3), 0.4, 0.6, angle=-10, color='white', ec='black')
ax_left.add_patch(left_eye)
ax_left.add_patch(right_eye)
# 绘制眼珠
ax_left.add_patch(Circle((4.4, 6.3), 0.15, color='black'))
ax_left.add_patch(Circle((5.6, 6.3), 0.15, color='black'))
# 绘制微笑嘴巴
smile = Wedge((5, 5.5), 0.8, 140, 40, color='none', ec='black', lw=2)
ax_left.add_patch(smile)
# 绘制友好手势
# 右手
ax_left.add_patch(Polygon(np.array([[6.5, 5], [7.5, 4], [7.2, 3.5], [6.2, 4.5]]), color='#FFDEAD'))
# 左手
ax_left.add_patch(Polygon(np.array([[3.5, 5], [2.5, 4], [2.8, 3.5], [3.8, 4.5]]), color='#FFDEAD'))
# 绘制身体
ax_left.add_patch(Rectangle((4, 3), 2, 2, color='#1E90FF'))
# 绘制和平鸽
dove_body = Ellipse((7, 7), 1.5, 0.7, angle=30, color='white', ec='black', alpha=0.9)
dove_head = Circle((7.8, 7.3), 0.4, color='white', ec='black')
dove_wing = Ellipse((6.5, 7), 1, 0.5, angle=-20, color='white', ec='black')
ax_left.add_patch(dove_body)
ax_left.add_patch(dove_head)
ax_left.add_patch(dove_wing)
# 添加橄榄枝
olive = Polygon(np.array([[6.5, 6.5], [6.2, 6.2], [6.8, 5.8], [7.2, 6.0]]), color='#32CD32')
ax_left.add_patch(olive)
# 添加友好元素 - 花朵
for i, pos in enumerate([(2, 8), (8, 8), (3, 2), (7, 2)]):
flower_color = ['#FF69B4', '#FFD700', '#9370DB', '#00FA9A'][i]
# 花瓣
for angle in range(0, 360, 45):
rad = np.deg2rad(angle)
x = pos[0] + 0.5 * np.cos(rad)
y = pos[1] + 0.5 * np.sin(rad)
petal = Ellipse((x, y), 0.6, 0.3, angle=angle, color=flower_color, alpha=0.7)
ax_left.add_patch(petal)
# 花蕊
ax_left.add_patch(Circle(pos, 0.2, color='#FFD700'))
# 添加文字
ax_left.text(5, 1.5, '友好握手\n热情款待\n礼物相赠', fontsize=14, ha='center', color='#006400',
bbox=dict(boxstyle="round,pad=0.5", fc="#F0FFF0", ec="#006400", lw=2))
# ===================== 右侧:暗藏杀机 =====================
# 绘制双面人物
# 正面笑脸
face_front = Circle((5, 6), 1.5, color='#FFDEAD', ec='black')
ax_right.add_patch(face_front)
# 笑脸眼睛
left_eye_front = Ellipse((4.3, 6.3), 0.4, 0.6, angle=10, color='white', ec='black')
right_eye_front = Ellipse((5.7, 6.3), 0.4, 0.6, angle=-10, color='white', ec='black')
ax_right.add_patch(left_eye_front)
ax_right.add_patch(right_eye_front)
# 眼珠
ax_right.add_patch(Circle((4.4, 6.3), 0.15, color='black'))
ax_right.add_patch(Circle((5.6, 6.3), 0.15, color='black'))
# 微笑嘴巴
smile_front = Wedge((5, 5.5), 0.8, 220, 320, color='none', ec='black', lw=2)
ax_right.add_patch(smile_front)
# 身体
ax_right.add_patch(Rectangle((4, 3), 2, 2, color='#1E90FF'))
# 背后的阴影面孔
shadow_face = Ellipse((3, 6), 1.8, 1.5, angle=20, color='#696969', alpha=0.8)
ax_right.add_patch(shadow_face)
# 阴影眼睛
shadow_eye = Ellipse((2.7, 6.2), 0.5, 0.4, angle=20, color='#8B0000')
ax_right.add_patch(shadow_eye)
# 阴影嘴巴
shadow_mouth = Polygon(np.array([[2.2, 5.5], [3.5, 5.2], [3.2, 5.0]]), color='#8B0000')
ax_right.add_patch(shadow_mouth)
# 藏在背后的刀
blade = Polygon(np.array([[3, 4], [2, 3.5], [2.5, 3], [3.5, 3.5]]), color='#C0C0C0')
handle = Rectangle((3, 4), 1.5, 0.3, color='#8B4513')
ax_right.add_patch(blade)
ax_right.add_patch(handle)
# 添加危险元素 - 毒药瓶
bottle = Polygon(np.array([[7, 7], [6.8, 6], [7.2, 6]]), color='#9370DB')
bottle_neck = Rectangle((6.9, 7), 0.2, 0.3, color='#9370DB')
bottle_label = Rectangle((6.95, 6.5), 0.1, 0.5, color='#FF0000')
ax_right.add_patch(bottle)
ax_right.add_patch(bottle_neck)
ax_right.add_patch(bottle_label)
ax_right.text(7, 6.2, '毒', fontsize=12, ha='center', color='white', fontweight='bold')
# 添加危险元素 - 炸弹
bomb_body = Circle((8, 3), 0.8, color='#2F4F4F')
bomb_fuse = Polygon(np.array([[8, 3.8], [8.2, 4.2], [8.1, 4.1]]), color='#FF4500')
ax_right.add_patch(bomb_body)
ax_right.add_patch(bomb_fuse)
ax_right.text(8, 3, '爆', fontsize=12, ha='center', color='white', fontweight='bold')
# 添加危险元素 - 匕首
dagger_blade = Polygon(np.array([[2, 2], [3, 1.5], [2.8, 1.2]]), color='#A9A9A9')
dagger_handle = Rectangle((2, 2), 0.2, 0.8, color='#8B4513')
ax_right.add_patch(dagger_blade)
ax_right.add_patch(dagger_handle)
# 添加文字
ax_right.text(5, 1.5, '暗中部署\n背后捅刀\n陷阱埋伏', fontsize=14, ha='center', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.5", fc="#FFE4E1", ec="#8B0000", lw=2))
# 添加策略核心说明
strategy_core = (
'核心策略:\n'
'1. 伪装友善:以笑容、礼物、友好姿态降低对方戒心\n'
'2. 隐藏杀机:暗中准备致命手段\n'
'3. 伺机而动:等待最佳时机发动攻击\n'
'4. 一击致命:在对方毫无防备时给予致命打击'
)
plt.figtext(0.5, 0.125, strategy_core, ha='center', fontsize=15,
bbox=dict(boxstyle="round,pad=0.8", fc="#FFFACD", ec="#DAA520", lw=2))
# 添加历史案例
history_example = (
'历史案例:\n'
'三国时期,吕蒙白衣渡江取荆州:\n'
'吕蒙假称病重,陆逊接任后写信恭关羽,\n'
'关羽放松警惕,吕蒙趁机白衣渡江夺取荆州。'
)
plt.figtext(0.5, 0.75, history_example, ha='center', fontsize=14,
bbox=dict(boxstyle="round,pad=0.5", fc="#E6E6FA", ec="#9370DB", lw=1))
plt.savefig('笑里藏刀.png', dpi=300, bbox_inches='tight')
plt.show()
李代桃僵
势必有损,损阴以益阳。
牺牲局部保全整体。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(12, 8))
fig.patch.set_facecolor('#f5f5dc') # 设置背景色为浅黄色
# 设置标题
plt.suptitle('李代桃僵策略示意图', fontsize=20, fontweight='bold', color='#8B0000')
plt.title('牺牲局部利益以保全整体利益', fontsize=16, color='#556B2F')
# 绘制策略说明文本
strategy_text = (
'"李代桃僵"出自《乐府诗集·鸡鸣篇》:"桃生露井上,李树生桃旁。虫来啮桃根,李树代桃僵。树木身相代,兄弟还相忘?"\n'
'此计在军事上指在敌我双方势均力敌,或者敌优我劣的情况下,用小的代价,换取大的胜利的谋略。'
)
plt.figtext(0.5, 0.05, strategy_text, ha='center', fontsize=14,
bbox=dict(boxstyle="round,pad=0.5", fc="#FFF8DC", ec="#8B4513", lw=2))
# 绘制桃树
peach_trunk = Rectangle((2, 1), 0.5, 3, color='#8B4513', zorder=2)
peach_crown = Circle((2.25, 5), 2, color='#FFB6C1', alpha=0.8, zorder=1)
peach_flowers = []
for _ in range(30):
x = np.random.uniform(0.5, 4)
y = np.random.uniform(3.5, 6.5)
size = np.random.uniform(0.1, 0.3)
peach_flowers.append(Circle((x, y), size, color='#FF69B4', alpha=0.7))
# 绘制李树
plum_trunk = Rectangle((8, 1), 0.5, 3, color='#8B4513', zorder=2)
plum_crown = Circle((8.25, 5), 2, color='#98FB98', alpha=0.8, zorder=1)
plum_flowers = []
for _ in range(30):
x = np.random.uniform(6.5, 10)
y = np.random.uniform(3.5, 6.5)
size = np.random.uniform(0.1, 0.3)
plum_flowers.append(Circle((x, y), size, color='#32CD32', alpha=0.7))
# 添加树木到图中
ax.add_patch(peach_trunk)
ax.add_patch(peach_crown)
for flower in peach_flowers:
ax.add_patch(flower)
ax.add_patch(plum_trunk)
ax.add_patch(plum_crown)
for flower in plum_flowers:
ax.add_patch(flower)
# 添加树标签
plt.text(2.25, 7.5, '桃树', fontsize=14, ha='center', color='#8B0000',
fontweight='bold', path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
plt.text(8.25, 7.5, '李树', fontsize=14, ha='center', color='#006400',
fontweight='bold', path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 绘制虫子
worms = []
for _ in range(15):
x = np.random.uniform(1, 3.5)
y = np.random.uniform(1.5, 4)
angle = np.random.uniform(0, 360)
worms.append(Circle((x, y), 0.1, color='#8B0000'))
for worm in worms:
ax.add_patch(worm)
# 绘制箭头表示策略
arrow = Arrow(3.5, 4, 3.5, 0, width=0.5, color='#FF4500', alpha=0.8)
ax.add_patch(arrow)
plt.text(5.25, 4.5, '李代桃僵', fontsize=18, ha='center', color='#8B0000',
fontweight='bold', rotation=0,
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 添加被虫蛀的李树效果
damaged_plum = []
for _ in range(10):
x = np.random.uniform(6.5, 10)
y = np.random.uniform(3.5, 6.5)
size = np.random.uniform(0.2, 0.4)
damaged_plum.append(Circle((x, y), size, color='#A9A9A9', alpha=0.6))
for damage in damaged_plum:
ax.add_patch(damage)
# 添加文本说明
plt.text(2.25, 3.5, '害虫侵袭', fontsize=12, ha='center', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.3", fc="#FFE4E1", ec="#8B0000", lw=1))
plt.text(8.25, 3.5, '代替承受', fontsize=12, ha='center', color='#006400',
bbox=dict(boxstyle="round,pad=0.3", fc="#F0FFF0", ec="#006400", lw=1))
plt.text(2.25, 2, '保全整体', fontsize=12, ha='center', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.3", fc="#FFE4E1", ec="#8B0000", lw=1))
plt.text(8.25, 2, '牺牲局部', fontsize=12, ha='center', color='#006400',
bbox=dict(boxstyle="round,pad=0.3", fc="#F0FFF0", ec="#006400", lw=1))
# 绘制地面
ground = Rectangle((0, 0), 10.5, 1, color='#DEB887', zorder=0)
ax.add_patch(ground)
# 设置坐标轴范围
plt.xlim(0, 10.5)
plt.ylim(0, 8)
# 隐藏坐标轴
plt.axis('off')
# 添加装饰元素 - 云朵
def draw_cloud(x, y, size):
cloud = []
cloud.append(Circle((x, y), size, color='white', alpha=0.9))
cloud.append(Circle((x + size * 0.8, y), size * 0.8, color='white', alpha=0.9))
cloud.append(Circle((x - size * 0.8, y), size * 0.8, color='white', alpha=0.9))
cloud.append(Circle((x + size * 1.5, y), size * 0.7, color='white', alpha=0.9))
cloud.append(Circle((x - size * 1.5, y), size * 0.7, color='white', alpha=0.9))
for c in cloud:
ax.add_patch(c)
draw_cloud(1, 7, 0.4)
draw_cloud(9, 7.2, 0.35)
draw_cloud(5, 7.5, 0.5)
# 添加装饰元素 - 小鸟
def draw_bird(x, y):
bird_body = Circle((x, y), 0.2, color='#4682B4')
bird_head = Circle((x + 0.25, y), 0.15, color='#4682B4')
wing_points = np.array([
[x - 0.1, y],
[x - 0.3, y + 0.2],
[x, y]
])
bird_wing = Polygon(wing_points, color='#4169E1')
ax.add_patch(bird_body)
ax.add_patch(bird_head)
ax.add_patch(bird_wing)
draw_bird(0.8, 6.5)
draw_bird(9.8, 6.8)
# 添加装饰元素 - 太阳
sun = Circle((0.8, 7.5), 0.6, color='#FFD700')
sun_rays = []
for i in range(8):
angle = i * np.pi / 4
x1, y1 = 0.8 + 0.7 * np.cos(angle), 7.5 + 0.7 * np.sin(angle)
x2, y2 = 0.8 + 1.2 * np.cos(angle), 7.5 + 1.2 * np.sin(angle)
sun_rays.append(plt.plot([x1, x2], [y1, y2], color='#FFD700', linewidth=2, alpha=0.7)[0])
ax.add_patch(sun)
plt.tight_layout()
plt.savefig('李代桃僵.png', dpi=300, bbox_inches='tight')
plt.show()
顺手牵羊
微隙在所必乘,微利在所必得。少阴,少阳。
抓住敌方疏漏,获取小利。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon, Ellipse
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
fig.patch.set_facecolor('#F0FFF0') # 设置背景色为浅绿色
# 设置标题
plt.suptitle('顺手牵羊策略示意图', fontsize=24, fontweight='bold', color='#8B4513')
plt.title('趁敌小隙,取利顺势', fontsize=18, color='#2F4F4F')
# 绘制策略说明文本
strategy_text = (
'"顺手牵羊"出自《草庐经略》:"伺敌之隙,乘间取利。"\n'
'指在完成主要目标的同时,抓住敌人暴露出的微小漏洞或疏忽,趁机获取额外利益。'
)
plt.figtext(0.5, 0.03, strategy_text, ha='center', fontsize=16,
bbox=dict(boxstyle="round,pad=0.5", fc="#FFF8DC", ec="#8B4513", lw=2))
# 绘制主要目标 - 城堡
# 城堡主体
castle_base = Rectangle((1, 1), 8, 3, color='#A9A9A9')
castle_wall = Rectangle((2, 3), 6, 2, color='#808080')
castle_tower1 = Rectangle((2, 5), 2, 3, color='#696969')
castle_tower2 = Rectangle((6, 5), 2, 3, color='#696969')
castle_roof1 = Polygon(np.array([[2, 8], [3, 8.5], [4, 8]]), color='#8B0000')
castle_roof2 = Polygon(np.array([[6, 8], [7, 8.5], [8, 8]]), color='#8B0000')
castle_gate = Rectangle((4.5, 1), 1, 2, color='#8B4513')
ax.add_patch(castle_base)
ax.add_patch(castle_wall)
ax.add_patch(castle_tower1)
ax.add_patch(castle_tower2)
ax.add_patch(castle_roof1)
ax.add_patch(castle_roof2)
ax.add_patch(castle_gate)
# 城堡窗户
for x in [2.5, 3.5, 6.5, 7.5]:
for y in [5.5, 6.5]:
ax.add_patch(Rectangle((x, y), 0.5, 0.5, color='#FFD700'))
# 城堡旗帜
ax.add_patch(Polygon(np.array([[3, 8.5], [3, 9.5], [4, 9]]), color='#FF0000'))
ax.add_patch(Polygon(np.array([[7, 8.5], [7, 9.5], [8, 9]]), color='#FF0000'))
# 添加城堡标签
plt.text(5, 4.5, '主要目标:攻占城堡', fontsize=16, ha='center', color='#8B0000',
fontweight='bold', path_effects=[path_effects.withStroke(linewidth=2, foreground='white')],
bbox=dict(boxstyle="round,pad=0.5", fc="#FFE4E1", ec="#8B0000", lw=2))
# 绘制次要目标 - 羊群
# 草地
grass = Rectangle((9, 1), 4, 3, color='#32CD32', alpha=0.7)
ax.add_patch(grass)
# 绘制草地纹理
for _ in range(100):
x = np.random.uniform(9, 13)
y = np.random.uniform(1, 4)
size = np.random.uniform(0.05, 0.15)
angle = np.random.uniform(0, 180)
ax.add_patch(Ellipse((x, y), size, size / 3, angle=angle, color='#228B22'))
# 绘制羊
def draw_sheep(x, y, size=1):
# 羊身体
body = Ellipse((x, y), 1.5 * size, 1 * size, angle=-10, color='white', ec='black')
# 羊头
head = Ellipse((x - 0.8 * size, y + 0.3 * size), 0.7 * size, 0.6 * size, angle=20, color='white', ec='black')
# 羊腿
leg1 = Rectangle((x - 0.3 * size, y - 0.7 * size), 0.2 * size, 0.6 * size, color='black')
leg2 = Rectangle((x + 0.3 * size, y - 0.7 * size), 0.2 * size, 0.6 * size, color='black')
leg3 = Rectangle((x - 0.7 * size, y - 0.5 * size), 0.2 * size, 0.4 * size, color='black')
leg4 = Rectangle((x + 0.7 * size, y - 0.5 * size), 0.2 * size, 0.4 * size, color='black')
ax.add_patch(body)
ax.add_patch(head)
for leg in [leg1, leg2, leg3, leg4]:
ax.add_patch(leg)
# 羊眼睛
ax.add_patch(Circle((x - 0.9 * size, y + 0.4 * size), 0.08 * size, color='black'))
# 羊毛卷
for i, pos in enumerate(
[(x - 0.2 * size, y + 0.3 * size), (x + 0.3 * size, y + 0.2 * size), (x + 0.5 * size, y + 0.4 * size)]):
ax.add_patch(Circle(pos, 0.15 * size, color='white', ec='black'))
# 绘制多只羊
draw_sheep(10, 2.5)
draw_sheep(11.5, 2)
draw_sheep(10.5, 3.2, 0.8)
draw_sheep(12, 3, 0.9)
# 添加羊群标签
plt.text(11, 1.5, '次要目标:羊群', fontsize=16, ha='center', color='#006400',
fontweight='bold', path_effects=[path_effects.withStroke(linewidth=2, foreground='white')],
bbox=dict(boxstyle="round,pad=0.5", fc="#F0FFF0", ec="#006400", lw=2))
# 绘制士兵
# 士兵1:进攻城堡
soldier_body = Rectangle((4.5, 4.5), 0.5, 1.2, color='#4169E1')
soldier_head = Circle((4.75, 6), 0.3, color='#FFDEAD')
soldier_leg1 = Rectangle((4.5, 4.5), 0.2, 0.8, color='#2F4F4F')
soldier_leg2 = Rectangle((4.8, 4.5), 0.2, 0.8, color='#2F4F4F')
soldier_sword = Polygon(np.array([[4.75, 5.5], [4.75, 4.0], [4.85, 4.1]]), color='#C0C0C0')
ax.add_patch(soldier_body)
ax.add_patch(soldier_head)
ax.add_patch(soldier_leg1)
ax.add_patch(soldier_leg2)
ax.add_patch(soldier_sword)
# 士兵2:牵羊
soldier2_body = Rectangle((9.5, 3.5), 0.5, 1.2, color='#4169E1')
soldier2_head = Circle((9.75, 5), 0.3, color='#FFDEAD')
soldier2_leg1 = Rectangle((9.5, 3.5), 0.2, 0.8, color='#2F4F4F')
soldier2_leg2 = Rectangle((9.8, 3.5), 0.2, 0.8, color='#2F4F4F')
soldier2_rope = plt.Line2D([9.75, 10.2], [4.5, 3.5], color='#8B4513', lw=2)
ax.add_patch(soldier2_body)
ax.add_patch(soldier2_head)
ax.add_patch(soldier2_leg1)
ax.add_patch(soldier2_leg2)
ax.add_line(soldier2_rope)
# 添加士兵标签
plt.text(4.75, 3.8, '主力部队\n进攻城堡', fontsize=12, ha='center', color='#000080',
bbox=dict(boxstyle="round,pad=0.3", fc="#ADD8E6", ec="#000080", lw=1))
plt.text(9.75, 2.8, '小分队\n顺手牵羊', fontsize=12, ha='center', color='#006400',
bbox=dict(boxstyle="round,pad=0.3", fc="#90EE90", ec="#006400", lw=1))
# 绘制行动箭头
# 主力部队路线
ax.annotate('', xy=(5, 1.5), xytext=(5, 4.5),
arrowprops=dict(arrowstyle='->', color='#000080', lw=2, linestyle='-'),
annotation_clip=False)
# 小分队路线
ax.annotate('', xy=(10, 2), xytext=(7, 4),
arrowprops=dict(arrowstyle='->', color='#006400', lw=2, linestyle='-'),
annotation_clip=False)
# 牵羊路线
ax.annotate('', xy=(10.5, 3), xytext=(9.5, 4),
arrowprops=dict(arrowstyle='->', color='#8B4513', lw=2, linestyle='-'),
annotation_clip=False)
# 添加策略说明
plt.text(7, 7, '主力部队攻击主要目标(城堡)', fontsize=14, ha='center', color='#000080',
bbox=dict(boxstyle="round,pad=0.5", fc="#ADD8E6", ec="#000080", lw=2))
plt.text(10, 6, '发现次要目标(羊群)', fontsize=14, ha='center', color='#006400',
bbox=dict(boxstyle="round,pad=0.5", fc="#90EE90", ec="#006400", lw=2))
plt.text(5, 6.5, '顺手牵羊', fontsize=20, ha='center', color='#8B4513', fontweight='bold',
path_effects=[path_effects.withStroke(linewidth=3, foreground='white')],
bbox=dict(boxstyle="round,pad=0.8", fc="#FFEBCD", ec="#8B4513", lw=3))
# 绘制策略核心要素
strategy_elements = [
('发现漏洞', (2, 0.5), '#8B0000'),
('抓住时机', (5, 0.5), '#006400'),
('顺势而为', (8, 0.5), '#000080'),
('额外获利', (11, 0.5), '#8B4513')
]
for text, pos, color in strategy_elements:
plt.text(pos[0], pos[1], text, fontsize=14, ha='center', color='white',
bbox=dict(boxstyle="round,pad=0.5", fc=color, ec='black', alpha=0.9))
# 绘制装饰元素 - 云朵
def draw_cloud(x, y, size):
ax.add_patch(Circle((x, y), size, color='white', alpha=0.9))
ax.add_patch(Circle((x + size * 0.8, y), size * 0.8, color='white', alpha=0.9))
ax.add_patch(Circle((x - size * 0.8, y), size * 0.8, color='white', alpha=0.9))
ax.add_patch(Circle((x + size * 1.5, y), size * 0.7, color='white', alpha=0.9))
draw_cloud(1, 8, 0.4)
draw_cloud(4, 8.5, 0.5)
draw_cloud(12, 8, 0.6)
# 绘制装饰元素 - 树木
def draw_tree(x, y, size=1):
trunk = Rectangle((x, y), 0.2 * size, 0.8 * size, color='#8B4513')
crown = Circle((x + 0.1 * size, y + 1 * size), 0.5 * size, color='#228B22')
ax.add_patch(trunk)
ax.add_patch(crown)
draw_tree(0.5, 1, 0.8)
draw_tree(13.5, 1.2, 1.0)
draw_tree(3, 0.2, 0.7)
draw_tree(10, 0.5, 1.1)
# 绘制装饰元素 - 山脉
mountain = Polygon(np.array([[0, 0], [2, 3], [4, 1], [6, 4], [8, 2], [10, 3], [14, 0]]),
color='#2E8B57', alpha=0.6)
ax.add_patch(mountain)
# 设置坐标轴范围
plt.xlim(0, 14)
plt.ylim(0, 10)
# 隐藏坐标轴
plt.axis('off')
plt.tight_layout(rect=[0, 0.05, 1, 0.95])
plt.savefig('顺手牵羊.png', dpi=300, bbox_inches='tight')
plt.show()
攻战计(主动进攻的策略)
打草惊蛇
疑以叩实,察而后动。复者,阴之媒也。
故意暴露行动,试探敌方反应。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon
from matplotlib.collections import PatchCollection
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 12)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off')
plt.title('打草惊蛇策略示意图', fontsize=18, fontweight='bold', pad=20)
# 添加背景
background = Rectangle((0, 0), 12, 8, color='#e8f4e3', zorder=0)
ax.add_patch(background)
# 绘制草丛
grass_colors = ['#4caf50', '#388e3c', '#2e7d32', '#1b5e20']
grass_patches = []
for _ in range(80):
x = np.random.uniform(0.5, 11.5)
y = np.random.uniform(0.5, 5.5)
width = np.random.uniform(0.2, 0.8)
height = np.random.uniform(0.3, 1.2)
angle = np.random.uniform(-15, 15)
rect = Rectangle((x, y), width, height, angle=angle,
color=np.random.choice(grass_colors))
grass_patches.append(rect)
grass_collection = PatchCollection(grass_patches, match_original=True)
ax.add_collection(grass_collection)
# 绘制隐藏的蛇
snake_body = np.array([
[2.0, 2.0], [2.5, 2.2], [3.0, 2.1], [3.5, 2.3], [4.0, 2.0],
[4.5, 1.8], [5.0, 1.9], [5.5, 1.7], [6.0, 1.8], [6.5, 2.0]
])
snake = Polygon(snake_body, closed=False, color='#4a7c59', linewidth=3, alpha=0.7)
ax.add_patch(snake)
# 蛇头
snake_head = Circle((6.7, 2.0), 0.3, color='#4a7c59', alpha=0.7)
ax.add_patch(snake_head)
# 蛇眼
snake_eye = Circle((6.8, 2.05), 0.05, color='black')
ax.add_patch(snake_eye)
# 蛇信子
ax.plot([6.9, 7.0], [2.0, 2.0], color='red', linewidth=1.5)
ax.plot([6.9, 7.0], [2.0, 1.95], color='red', linewidth=1.5)
# 绘制打草的人
# 身体
ax.plot([9.0, 9.0], [4.0, 3.0], color='#5d4037', linewidth=3)
# 头
head = Circle((9.0, 4.3), 0.3, color='#ffccbc', ec='black')
ax.add_patch(head)
# 眼睛
ax.plot([8.9, 8.9], [4.35, 4.35], 'ko', markersize=4)
# 腿
ax.plot([9.0, 9.2], [3.0, 2.5], color='#5d4037', linewidth=3)
ax.plot([9.0, 8.8], [3.0, 2.5], color='#5d4037', linewidth=3)
# 手臂
ax.plot([9.0, 9.5], [3.5, 3.0], color='#5d4037', linewidth=3)
# 打草用的棍子
stick = plt.Line2D([9.5, 10.5], [3.0, 2.0], color='#8d6e63', linewidth=4)
ax.add_line(stick)
# 打草动作的震动波
wave_x = np.linspace(10.5, 7.0, 100)
wave_y = 2.0 + 0.1 * np.sin(10 * wave_x)
ax.plot(wave_x, wave_y, 'r--', linewidth=2, alpha=0.7)
# 添加蛇被惊动的效果
for i in range(5):
angle = np.random.uniform(0, 360)
length = np.random.uniform(0.5, 1.5)
dx = length * np.cos(np.radians(angle))
dy = length * np.sin(np.radians(angle))
ax.arrow(6.7, 2.0, dx, dy, head_width=0.1, head_length=0.15,
fc='red', ec='red', alpha=0.5)
# 添加文字说明
ax.text(9.0, 5.0, "打草者", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='white', ec='black', alpha=0.8))
ax.text(7.0, 1.0, "隐藏的蛇", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='white', ec='black', alpha=0.8))
ax.text(10.5, 2.5, "打草动作", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='white', ec='black', alpha=0.8))
# 添加策略解释
explanation = (
"策略解析:打草惊蛇\n\n"
"原意:打草时惊动伏在草中的蛇\n"
"军事策略:通过试探性行动,诱使隐藏的敌人暴露位置或意图\n"
"应用场景:侦察敌情、试探对手、引蛇出洞"
)
ax.text(1.0, 7.0, explanation, fontsize=13, ha='left', va='top',
bbox=dict(boxstyle="round,pad=0.5", fc='#fff9c4', ec='#ffd54f', alpha=0.9))
# 添加三十六计标识
ax.text(11.5, 7.5, "三十六计", fontsize=14, ha='right', va='top',
fontweight='bold', color='#d32f2f',
bbox=dict(boxstyle="round,pad=0.3", fc='white', ec='#d32f2f'))
ax.text(11.5, 7.0, "第十三计", fontsize=12, ha='right', va='top',
fontweight='bold', color='#d32f2f')
# 添加装饰元素
for _ in range(15):
x = np.random.uniform(0, 12)
y = np.random.uniform(0, 8)
size = np.random.uniform(0.05, 0.2)
ax.plot(x, y, 'o', markersize=size*100,
color=np.random.choice(['#ffcc80', '#c5e1a5', '#b3e5fc']),
alpha=0.3)
plt.tight_layout()
plt.savefig('打草惊蛇.png', dpi=300, bbox_inches='tight')
plt.show()
借尸还魂
有用者,不可借;不能用者,求借。借不能用者而用之。
利用废弃资源或名义,实现新目标。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon, Arc, Ellipse
from matplotlib.collections import PatchCollection
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
plt.title('借尸还魂策略示意图', fontsize=20, fontweight='bold', pad=20, color='#8B4513')
# 添加背景
background = Rectangle((0, 0), 14, 10, color='#f5f5dc', zorder=0) # 米色背景
ax.add_patch(background)
# 绘制古战场背景
# 山
mountain = Polygon(np.array([(0,0), (2,3), (4,1), (6,4), (8,2), (10,5), (12,3), (14,0)]),
color='#8fbc8f', alpha=0.7)
ax.add_patch(mountain)
# 云
clouds = []
for i in range(3):
x = np.random.uniform(1, 13)
y = np.random.uniform(7, 9)
cloud = Circle((x, y), 0.8, color='white', alpha=0.8)
cloud2 = Circle((x+0.5, y+0.3), 0.6, color='white', alpha=0.8)
cloud3 = Circle((x-0.4, y-0.2), 0.5, color='white', alpha=0.8)
clouds.extend([cloud, cloud2, cloud3])
cloud_collection = PatchCollection(clouds, match_original=True)
ax.add_collection(cloud_collection)
# 绘制废弃的"尸" - 破旧的战车
# 车体
chariot_body = Rectangle((3, 3), 3, 1.5, angle=-10, color='#8B4513', alpha=0.7)
ax.add_patch(chariot_body)
# 车轮
wheel1 = Circle((3.5, 3), 0.5, color='#5d4037', alpha=0.7)
wheel2 = Circle((5.5, 3.2), 0.5, color='#5d4037', alpha=0.7)
ax.add_patch(wheel1)
ax.add_patch(wheel2)
# 破损效果
ax.plot([3.2, 3.8], [4.3, 4.0], 'k-', linewidth=2, alpha=0.7)
ax.plot([4.5, 4.0], [4.5, 4.0], 'k-', linewidth=2, alpha=0.7)
# 绘制"借"的过程 - 智慧的光芒
for i in range(8):
angle = np.radians(i * 45)
length = 1.5
x_end = 7 + length * np.cos(angle)
y_end = 6 + length * np.sin(angle)
ax.plot([7, x_end], [6, y_end], color='gold', linewidth=2, alpha=0.7)
# 智慧中心
wisdom_center = Circle((7, 6), 0.8, color='gold', alpha=0.9)
ax.add_patch(wisdom_center)
ax.text(7, 6, "智", fontsize=16, ha='center', va='center', color='darkred', fontweight='bold')
# 绘制"还魂"的结果 - 修复的战车变成强大的战象
# 战象身体
elephant_body = Ellipse((10, 5), 3, 2, angle=-5, color='#708090', alpha=0.8)
ax.add_patch(elephant_body)
# 战象头部
elephant_head = Ellipse((11.8, 5.5), 1.5, 1.2, angle=-20, color='#708090', alpha=0.8)
ax.add_patch(elephant_head)
# 象牙
tusk1 = Polygon(np.array([(12.2, 5.8), (12.8, 5.5), (12.5, 5.6)]), color='#f5f5f5')
tusk2 = Polygon(np.array([(12.2, 5.2), (12.8, 4.9), (12.5, 5.0)]), color='#f5f5f5')
ax.add_patch(tusk1)
ax.add_patch(tusk2)
# 象眼
eye = Circle((12.0, 5.6), 0.15, color='black')
ax.add_patch(eye)
# 象耳
ear = Arc((11.2, 6.0), 1.2, 1.0, angle=0, theta1=0, theta2=180, color='#708090', linewidth=3)
ax.add_patch(ear)
# 象腿
legs = []
for i in range(4):
x_pos = 9.0 + i * 0.8
leg = Rectangle((x_pos, 3.5), 0.5, 1.5, color='#708090', alpha=0.8)
legs.append(leg)
leg_collection = PatchCollection(legs, match_original=True)
ax.add_collection(leg_collection)
# 象尾
ax.plot([8.8, 8.0], [5.0, 4.5], color='#708090', linewidth=3)
# 战车上的装备转移到战象上
# 旗帜
ax.plot([10.5, 10.5], [6.5, 7.5], color='#8B0000', linewidth=2)
flag = Polygon(np.array([(10.5, 7.5), (11.5, 7.2), (10.5, 7.0)]), color='#8B0000')
ax.add_patch(flag)
ax.text(11.0, 7.1, "帅", color='gold', fontsize=12, ha='center', va='center')
# 武器
ax.plot([9.5, 9.5], [6.0, 6.8], color='#5d4037', linewidth=3)
ax.plot([9.5, 10.0], [6.8, 7.0], color='silver', linewidth=3)
# 绘制连接线 - 表示转化过程
ax.annotate('', xy=(10, 5), xytext=(6, 4.5),
arrowprops=dict(arrowstyle='->', color='#8B4513', linewidth=2,
connectionstyle="arc3,rad=-0.3", alpha=0.7))
# 添加文字说明
ax.text(4.5, 2.0, "废弃的战车\n('尸')", fontsize=14, ha='center', va='top',
bbox=dict(boxstyle="round,pad=0.3", fc='#d2b48c', ec='#8B4513', alpha=0.9))
ax.text(7, 7.5, "智慧\n('借')", fontsize=14, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='gold', ec='#daa520', alpha=0.9))
ax.text(10.5, 3.0, "强大的战象\n('还魂')", fontsize=14, ha='center', va='top',
bbox=dict(boxstyle="round,pad=0.3", fc='#b0c4de', ec='#6a5acd', alpha=0.9))
# 添加策略解释
explanation = (
"策略解析:借尸还魂\n\n"
"原意:利用已死之尸,赋予新的灵魂\n"
"军事策略:利用看似无用的事物或力量,赋予新的使命和用途\n"
"核心思想:变废为宝,化腐朽为神奇\n"
"应用场景:\n"
" • 利用废弃资源组建新部队\n"
" • 借助敌方力量实现己方目标\n"
" • 赋予旧事物新功能"
)
ax.text(1.0, 8.5, explanation, fontsize=14, ha='left', va='top',
bbox=dict(boxstyle="round,pad=0.5", fc='#fffaf0', ec='#d2b48c', alpha=0.9),
linespacing=1.5)
# 添加三十六计标识
ax.text(13.5, 9.0, "三十六计", fontsize=16, ha='right', va='top',
fontweight='bold', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.3", fc='#fffaf0', ec='#8B0000'))
ax.text(13.5, 8.4, "第十四计", fontsize=14, ha='right', va='top',
fontweight='bold', color='#8B0000')
# 添加装饰元素 - 古战场细节
# 草
for _ in range(30):
x = np.random.uniform(0, 14)
y = np.random.uniform(0, 3)
height = np.random.uniform(0.1, 0.5)
ax.plot([x, x], [y, y+height], color='#2e8b57', linewidth=1, alpha=0.7)
# 碎石
for _ in range(50):
x = np.random.uniform(0, 14)
y = np.random.uniform(0, 3)
size = np.random.uniform(0.05, 0.2)
ax.plot(x, y, 'o', markersize=size*10, color='#a9a9a9', alpha=0.5)
# 尘土
for _ in range(20):
x = np.random.uniform(8, 12)
y = np.random.uniform(2, 4)
size = np.random.uniform(0.1, 0.4)
ax.plot(x, y, 'o', markersize=size*10, color='#d2b48c', alpha=0.4)
# 战象脚下的震动
for i in range(5):
x = 9.0 + i * 0.8
ax.plot([x-0.2, x+0.2], [3.5, 3.5], 'k-', linewidth=1, alpha=0.7)
plt.tight_layout()
plt.savefig('借尸还魂.png', dpi=300, bbox_inches='tight')
plt.show()
调虎离山
待天以困之,用人以诱之。往蹇来返。
诱使强敌离开有利环境。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon, Arc, Ellipse
from matplotlib.collections import PatchCollection
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
plt.title('调虎离山策略示意图', fontsize=22, fontweight='bold', pad=20, color='#8B0000')
# 添加背景
background = Rectangle((0, 0), 14, 10, color='#e6f2ff', zorder=0) # 淡蓝色背景
ax.add_patch(background)
# 绘制山脉
mountains = []
mountain_colors = ['#708090', '#5f9ea0', '#4682b4']
mountain_positions = [
[(1, 1), (3, 4), (5, 2), (1, 1)],
[(4, 1), (6, 5), (8, 3), (10, 1), (4, 1)],
[(9, 1), (11, 6), (13, 3), (9, 1)]
]
for i, pos in enumerate(mountain_positions):
mountain = Polygon(pos, closed=True, color=mountain_colors[i % len(mountain_colors)], alpha=0.8)
mountains.append(mountain)
mountain_collection = PatchCollection(mountains, match_original=True)
ax.add_collection(mountain_collection)
# 标注主山(虎的巢穴)
ax.text(6, 5.5, "虎之巢穴\n(敌方有利位置)", fontsize=14, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#ff9999', ec='#cc0000', alpha=0.9))
# 绘制老虎
# 虎身体
tiger_body = Ellipse((6, 4.5), 1.8, 0.8, angle=-20, color='#ff9900', alpha=0.9)
ax.add_patch(tiger_body)
# 虎头
tiger_head = Circle((5.2, 4.8), 0.6, color='#ff9900', alpha=0.9)
ax.add_patch(tiger_head)
# 虎耳
ear1 = Polygon(np.array([(4.8, 5.3), (4.6, 5.6), (4.9, 5.4)]), color='#ff9900')
ear2 = Polygon(np.array([(5.0, 5.4), (4.9, 5.7), (5.2, 5.5)]), color='#ff9900')
ax.add_patch(ear1)
ax.add_patch(ear2)
# 虎眼
eye = Circle((5.0, 4.9), 0.1, color='black')
ax.add_patch(eye)
# 虎纹
stripes = []
for i in range(4):
x = 5.5 + i * 0.4
y = 4.5 - (i % 2) * 0.1
stripe = Rectangle((x, y), 0.2, 0.6, angle=20, color='black', alpha=0.5)
stripes.append(stripe)
stripe_collection = PatchCollection(stripes, match_original=True)
ax.add_collection(stripe_collection)
# 虎尾
ax.plot([6.8, 7.5], [4.3, 4.8], color='#ff9900', linewidth=4)
ax.plot([7.5, 7.8], [4.8, 4.5], color='#ff9900', linewidth=3)
# 绘制诱饵(羊)
# 羊身体
sheep_body = Ellipse((3, 2), 1.0, 0.6, color='white', alpha=0.9)
ax.add_patch(sheep_body)
# 羊头
sheep_head = Circle((2.3, 2.1), 0.4, color='white', alpha=0.9)
ax.add_patch(sheep_head)
# 羊腿
legs = []
for i in range(4):
x_pos = 2.7 + i * 0.3
leg = Rectangle((x_pos, 1.5), 0.15, 0.5, color='white', alpha=0.9)
legs.append(leg)
leg_collection = PatchCollection(legs, match_original=True)
ax.add_collection(leg_collection)
# 羊角
horn = Arc((2.1, 2.4), 0.4, 0.3, angle=0, theta1=0, theta2=180, color='#d2b48c', linewidth=3)
ax.add_patch(horn)
# 标注诱饵
ax.text(3, 1.2, "诱饵\n(引诱老虎离开)", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#ffff99', ec='#ffcc00', alpha=0.9))
# 绘制被引诱的老虎
# 虎身体
tiger2_body = Ellipse((4.5, 3.0), 1.8, 0.8, angle=30, color='#ff9900', alpha=0.9)
ax.add_patch(tiger2_body)
# 虎头
tiger2_head = Circle((5.2, 3.2), 0.6, color='#ff9900', alpha=0.9)
ax.add_patch(tiger2_head)
# 虎眼(盯着羊)
eye2 = Circle((5.0, 3.2), 0.1, color='black')
ax.add_patch(eye2)
ax.plot([5.0, 3.0], [3.2, 2.0], 'k--', alpha=0.3) # 视线
# 绘制移动路径
path_x = [6, 5.5, 5.0, 4.5]
path_y = [4.5, 4.0, 3.5, 3.0]
ax.plot(path_x, path_y, 'r--', linewidth=2, alpha=0.7)
ax.annotate('', xy=(4.5, 3.0), xytext=(5.0, 3.5),
arrowprops=dict(arrowstyle='->', color='red', linewidth=2, alpha=0.8))
# 绘制我方部队
# 左翼部队
for i in range(4):
x = 1.0 + i * 0.5
y = 3.0
soldier = Circle((x, y), 0.2, color='#1e90ff', alpha=0.8)
ax.add_patch(soldier)
ax.plot([x, x], [y-0.2, y-0.5], color='#1e90ff', linewidth=2) # 武器
# 右翼部队
for i in range(4):
x = 8.0 + i * 0.5
y = 2.5
soldier = Circle((x, y), 0.2, color='#1e90ff', alpha=0.8)
ax.add_patch(soldier)
ax.plot([x, x], [y-0.2, y-0.5], color='#1e90ff', linewidth=2) # 武器
# 包围箭头
ax.annotate('', xy=(4.5, 3.0), xytext=(2.0, 3.0),
arrowprops=dict(arrowstyle='->', color='blue', linewidth=2, alpha=0.8))
ax.annotate('', xy=(4.5, 3.0), xytext=(9.0, 2.5),
arrowprops=dict(arrowstyle='->', color='blue', linewidth=2, alpha=0.8))
# 标注我方部队
ax.text(2.0, 3.8, "我方左翼部队", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#add8e6', ec='#1e90ff', alpha=0.9))
ax.text(9.5, 3.3, "我方右翼部队", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#add8e6', ec='#1e90ff', alpha=0.9))
# 绘制被占据的山头
ax.text(11, 6.5, "已占领的山头", fontsize=12, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#90ee90', ec='#32cd32', alpha=0.9))
# 在山顶插上旗帜
ax.plot([11, 11], [5.5, 6.5], color='#8B0000', linewidth=2)
flag = Polygon(np.array([(11, 6.5), (11.8, 6.2), (11, 6.0)]), color='#8B0000')
ax.add_patch(flag)
ax.text(11.4, 6.1, "胜", fontsize=12, ha='center', va='center', color='white', weight='bold')
# 添加策略解释
explanation = (
"策略解析:调虎离山\n\n"
"核心思想:将强敌从其有利位置引诱出来,使其失去优势\n\n"
"• 调虎:引诱强敌(老虎)离开其巢穴(山)\n"
"• 离山:使敌人离开有利地形或防御位置\n"
"• 攻击:在敌人处于不利位置时进行攻击\n\n"
"策略步骤:\n"
"1. 识别敌人的有利位置(山)\n"
"2. 设计诱饵引诱敌人离开\n"
"3. 等待敌人进入不利环境\n"
"4. 发动攻击或占领敌人原位置"
)
ax.text(1.0, 8.5, explanation, fontsize=14, ha='left', va='top',
bbox=dict(boxstyle="round,pad=0.6", fc='#fffaf0', ec='#d2b48c', alpha=0.9),
linespacing=1.6)
# 添加策略优势对比
ax.text(10.0, 8.0, "策略优势对比", fontsize=14, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#ffcc99', ec='#ff9900'))
# 敌方在山上时的优势
ax.text(9.0, 7.2, "敌方在山上时:", fontsize=12, ha='right', va='center')
ax.text(9.5, 7.2, "• 地形优势\n• 防御坚固\n• 视野开阔", fontsize=11)
# 敌方离山后的劣势
ax.text(12.0, 7.2, "敌方离山后:", fontsize=12, ha='right', va='center')
ax.text(12.5, 7.2, "• 失去地形保护\n• 暴露弱点\n• 补给困难", fontsize=11)
# 添加三十六计标识
ax.text(13.5, 9.5, "三十六计", fontsize=18, ha='right', va='top',
fontweight='bold', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.4", fc='#fffaf0', ec='#8B0000'))
ax.text(13.5, 8.8, "第十五计", fontsize=16, ha='right', va='top',
fontweight='bold', color='#8B0000')
# 添加装饰元素
# 云
clouds = []
for i in range(3):
x = np.random.uniform(2, 12)
y = np.random.uniform(8, 9.5)
cloud = Circle((x, y), 0.6, color='white', alpha=0.8)
cloud2 = Circle((x+0.4, y+0.2), 0.5, color='white', alpha=0.8)
cloud3 = Circle((x-0.3, y-0.1), 0.4, color='white', alpha=0.8)
clouds.extend([cloud, cloud2, cloud3])
cloud_collection = PatchCollection(clouds, match_original=True)
ax.add_collection(cloud_collection)
# 鸟
for i in range(5):
x = np.random.uniform(1, 13)
y = np.random.uniform(7, 9)
size = np.random.uniform(0.05, 0.1)
ax.plot(x, y, 'v', markersize=10*size, color='k', alpha=0.6)
# 树
for i in range(10):
x = np.random.uniform(0.5, 13.5)
y = np.random.uniform(0, 2)
# 树干
ax.plot([x, x], [y, y+0.8], color='#8B4513', linewidth=1+2*i/10)
# 树冠
crown = Circle((x, y+1.0), 0.5, color='#2e8b57', alpha=0.7)
ax.add_patch(crown)
# 草丛
for _ in range(50):
x = np.random.uniform(0, 14)
y = np.random.uniform(0, 3)
height = np.random.uniform(0.1, 0.4)
ax.plot([x, x], [y, y+height], color='#2e8b57', linewidth=1, alpha=0.5)
# 老虎的威慑范围
danger_zone = Ellipse((6, 4.5), 4.0, 2.5, angle=0, fill=False,
ec='#ff0000', linestyle='--', alpha=0.5, linewidth=2)
ax.add_patch(danger_zone)
ax.text(6, 3.0, "危险区域\n(老虎威慑范围)", fontsize=10, ha='center', va='center', color='red')
# 安全区域
safe_zone = Ellipse((4.5, 3.0), 3.0, 2.0, angle=0, fill=False,
ec='#00aa00', linestyle='--', alpha=0.5, linewidth=2)
ax.add_patch(safe_zone)
ax.text(4.5, 2.0, "安全区域\n(老虎离开后)", fontsize=10, ha='center', va='center', color='green')
plt.tight_layout()
plt.savefig('调虎离山.png', dpi=300, bbox_inches='tight')
plt.show()
欲擒故纵
逼则反兵,走则减势。紧随勿迫,累其气力,消其斗志,散而后擒。
暂时放松逼迫,待敌松懈时再擒获。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建图形和坐标轴
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 10)
ax.set_ylim(0, 6)
ax.set_aspect('equal')
ax.axis('off') # 关闭坐标轴
# 设置背景色
fig.patch.set_facecolor('#FFF8E7')
ax.set_facecolor('#FFF8E7')
# 添加标题
title = plt.text(5, 5.5, '欲擒故纵策略示意图',
fontsize=24, ha='center', va='center',
fontweight='bold', color='#8B0000')
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#FFD700')])
# 添加副标题
subtitle = plt.text(5, 5.0, '欲擒故纵:为了捉住敌人,故意先放开他,使他放松戒备,充分暴露,然后再把他捉住',
fontsize=14, ha='center', va='center',
color='#8B4513', fontstyle='italic')
# 绘制山脉
mountain_x = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0])
mountain_y = np.array([1.0, 2.0, 1.5, 2.5, 1.8, 2.2, 1.0])
ax.fill(mountain_x, mountain_y, color='#5D8A66', alpha=0.7)
# 绘制河流
river_x = np.linspace(4.5, 9.5, 100)
river_y = 1.0 + 0.3 * np.sin(5 * river_x)
ax.plot(river_x, river_y, 'b-', linewidth=3, alpha=0.6)
ax.fill_between(river_x, river_y, 0.8, color='#87CEEB', alpha=0.4)
# 绘制营寨(防守方)
fortress = Rectangle((1.0, 2.8), 2.0, 1.0, color='#CD5C5C', alpha=0.9)
ax.add_patch(fortress)
# 绘制营寨旗帜
ax.plot([2.0, 2.0], [3.8, 4.5], color='#8B0000', linewidth=2)
ax.add_patch(Rectangle((1.95, 4.5), 0.1, 0.3, color='#8B0000'))
# 绘制防守方士兵
for i in range(4):
ax.add_patch(Circle((1.5 + i * 0.4, 3.3), 0.15, color='#CD5C5C'))
ax.plot([1.5 + i * 0.4, 1.5 + i * 0.4], [3.45, 3.8], color='#8B0000', linewidth=2)
# 绘制进攻方士兵(红色)
attackers = []
for i in range(3):
for j in range(3):
x = 4.0 + i * 0.5
y = 3.0 + j * 0.5
attackers.append((x, y))
ax.add_patch(Circle((x, y), 0.15, color='#B22222'))
ax.plot([x, x], [y + 0.15, y + 0.5], color='#8B0000', linewidth=2)
# 绘制撤退路线
retreat_x = [4.0, 5.0, 6.0, 7.0, 8.0, 8.5]
retreat_y = [3.0, 2.5, 2.0, 1.5, 1.2, 1.0]
ax.plot(retreat_x, retreat_y, 'r--', linewidth=2, alpha=0.7)
# 绘制追击路线
pursuit_x = [1.0, 3.0, 5.0, 7.0, 8.5]
pursuit_y = [3.3, 2.0, 1.5, 1.3, 1.0]
ax.plot(pursuit_x, pursuit_y, 'g--', linewidth=2, alpha=0.7)
# 绘制策略说明
strategy_text = [
"1. 包围敌人,但故意留出退路",
"2. 敌人撤退,放松戒备",
"3. 追击敌人,消耗其体力",
"4. 在敌人疲惫时一举擒获"
]
for i, text in enumerate(strategy_text):
ax.text(0.5, 4.5 - i * 0.5, text, fontsize=14, color='#2F4F4F',
bbox=dict(facecolor='#FFFACD', alpha=0.7, boxstyle='round,pad=0.5'))
# 绘制策略示意图元素
# 1. 包围阶段
ax.annotate('包围', xy=(4.5, 3.5), xytext=(4.0, 4.0),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=2),
fontsize=14, color='#8B0000', ha='center')
# 2. 撤退阶段
ax.annotate('撤退', xy=(6.5, 1.8), xytext=(7.0, 2.5),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=2),
fontsize=14, color='#8B0000', ha='center')
# 3. 追击阶段
ax.annotate('追击', xy=(5.0, 1.5), xytext=(4.0, 1.0),
arrowprops=dict(arrowstyle='->', color='#006400', lw=2),
fontsize=14, color='#006400', ha='center')
# 4. 擒获阶段
ax.add_patch(Circle((8.5, 1.0), 0.3, color='#FFD700', alpha=0.8))
ax.text(8.5, 1.0, '擒', fontsize=18, ha='center', va='center', color='#8B0000', fontweight='bold')
# 添加图例
legend_elements = [
plt.Line2D([0], [0], marker='o', color='w', label='防守方', markerfacecolor='#CD5C5C', markersize=10),
plt.Line2D([0], [0], marker='o', color='w', label='进攻方', markerfacecolor='#B22222', markersize=10),
plt.Line2D([0], [0], color='r', linestyle='--', lw=2, label='撤退路线'),
plt.Line2D([0], [0], color='g', linestyle='--', lw=2, label='追击路线')
]
ax.legend(handles=legend_elements, loc='lower right', fontsize=12, framealpha=0.9)
# 添加三十六计引用
quote = plt.text(5, 0.4, '《三十六计·欲擒故纵》:"逼则反兵,走则减势。紧随勿迫,累其气力,消其斗志,散而后擒,兵不血刃。"',
fontsize=12, ha='center', va='center', color='#556B2F', fontstyle='italic')
plt.tight_layout()
plt.savefig('欲擒故纵.png', dpi=300, bbox_inches='tight')
plt.show()
抛砖引玉
类以诱之,击蒙也。
以小利引诱敌人,换取更大利益。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon, Ellipse
from matplotlib.collections import PatchCollection
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
plt.title('抛砖引玉策略示意图', fontsize=22, fontweight='bold', pad=20, color='#8B4513')
# 添加背景
background = Rectangle((0, 0), 14, 10, color='#f0f8ff', zorder=0) # 淡蓝色背景
ax.add_patch(background)
# 绘制装饰性边框
border = Rectangle((0.1, 0.1), 13.8, 9.8, fill=None, ec='#8B4513', lw=3, linestyle='--', alpha=0.7)
ax.add_patch(border)
# 绘制左侧阵营(抛砖方)
# 抛砖者
ax.text(3.5, 8.0, "抛砖方", fontsize=16, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.4", fc='#add8e6', ec='#1e90ff', alpha=0.9))
# 抛砖者人物
# 身体
ax.plot([3.5, 3.5], [6.0, 5.0], color='#5d4037', linewidth=3)
# 头
head = Circle((3.5, 6.3), 0.3, color='#ffccbc', ec='black')
ax.add_patch(head)
# 眼睛
ax.plot([3.45, 3.45], [6.35, 6.35], 'ko', markersize=4)
# 腿
ax.plot([3.5, 3.7], [5.0, 4.0], color='#5d4037', linewidth=3)
ax.plot([3.5, 3.3], [5.0, 4.0], color='#5d4037', linewidth=3)
# 手臂(抛出砖的动作)
ax.plot([3.5, 4.0], [5.5, 5.0], color='#5d4037', linewidth=3)
# 抛出的砖
bricks = []
brick_colors = ['#cd853f', '#8b4513', '#a0522d']
for i in range(3):
x = 4.5 + i * 0.5
y = 5.0 - i * 0.2
brick = Rectangle((x, y), 0.8, 0.4, angle=15*i, color=np.random.choice(brick_colors))
bricks.append(brick)
# 砖的纹理
ax.plot([x+0.2, x+0.6], [y+0.1, y+0.1], 'k-', lw=0.8, alpha=0.5)
ax.plot([x+0.2, x+0.6], [y+0.3, y+0.3], 'k-', lw=0.8, alpha=0.5)
brick_collection = PatchCollection(bricks, match_original=True)
ax.add_collection(brick_collection)
# 绘制砖的轨迹
for i in range(3):
ax.plot([3.8, 4.5 + i*0.5], [5.2, 5.0 - i*0.2], 'k--', alpha=0.3)
# 绘制右侧阵营(引玉方)
# 引玉者
ax.text(10.5, 8.0, "引玉方", fontsize=16, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.4", fc='#ffb6c1', ec='#ff69b4', alpha=0.9))
# 引玉者人物
# 身体
ax.plot([10.5, 10.5], [6.0, 5.0], color='#5d4037', linewidth=3)
# 头
head = Circle((10.5, 6.3), 0.3, color='#ffccbc', ec='black')
ax.add_patch(head)
# 眼睛(盯着砖)
ax.plot([10.45, 10.45], [6.35, 6.35], 'ko', markersize=4)
ax.plot([10.5, 6.0], [6.35, 5.5], 'k--', alpha=0.3) # 视线
# 腿
ax.plot([10.5, 10.7], [5.0, 4.0], color='#5d4037', linewidth=3)
ax.plot([10.5, 10.3], [5.0, 4.0], color='#5d4037', linewidth=3)
# 手臂(准备拿玉)
ax.plot([10.5, 9.5], [5.5, 5.0], color='#5d4037', linewidth=3)
# 引出的玉
jades = []
jade_colors = ['#32cd32', '#7cfc00', '#98fb98', '#00fa9a']
for i in range(4):
x = 9.0 - i * 0.5
y = 4.0 + i * 0.2
size = 0.4 + i * 0.1
jade = Ellipse((x, y), size, size*0.8, angle=-15*i,
color=np.random.choice(jade_colors), alpha=0.9)
jades.append(jade)
# 玉的光泽
ax.plot(x-0.1, y+0.1, 'wo', markersize=size*2, alpha=0.3)
ax.plot(x+0.1, y-0.1, 'wo', markersize=size*1.5, alpha=0.2)
jade_collection = PatchCollection(jades, match_original=True)
ax.add_collection(jade_collection)
# 最大的玉(代表核心利益)
big_jade = Ellipse((8.0, 5.0), 1.0, 0.8, angle=30, color='#32cd32', alpha=0.95)
ax.add_patch(big_jade)
ax.plot(8.0, 5.0, 'wo', markersize=8, alpha=0.4)
ax.plot(7.9, 4.9, 'wo', markersize=4, alpha=0.4)
ax.text(8.0, 5.0, "玉", fontsize=16, ha='center', va='center', color='white', weight='bold')
# 绘制玉的轨迹
ax.plot([9.0, 8.0], [4.2, 5.0], 'g--', alpha=0.5)
# 绘制策略箭头
ax.annotate('', xy=(6.0, 5.0), xytext=(4.0, 5.0),
arrowprops=dict(arrowstyle='->', color='#8B4513', linewidth=3, alpha=0.8))
ax.text(5.0, 5.3, "抛砖", fontsize=16, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#cd853f', ec='#8B4513', alpha=0.9))
ax.annotate('', xy=(8.0, 5.0), xytext=(9.5, 5.0),
arrowprops=dict(arrowstyle='->', color='#32cd32', linewidth=3, alpha=0.8))
ax.text(8.7, 5.3, "引玉", fontsize=16, ha='center', va='center',
bbox=dict(boxstyle="round,pad=0.3", fc='#32cd32', ec='#006400', alpha=0.9))
# 绘制隐藏意图
# 抛砖方的隐藏意图(眼睛)
hidden_eye = Ellipse((3.0, 6.0), 0.2, 0.3, angle=45, color='red', alpha=0.7)
ax.add_patch(hidden_eye)
ax.plot([3.0, 8.0], [6.0, 5.0], 'r--', alpha=0.5) # 视线
# 引玉方的陷阱
trap = Polygon(np.array([[9.5, 4.0], [10.0, 3.5], [10.5, 4.0], [10.0, 4.5]]),
color='#a52a2a', alpha=0.3)
ax.add_patch(trap)
ax.text(10.0, 4.0, "陷阱", fontsize=12, ha='center', va='center', color='#8b0000')
# 添加策略解释
explanation = (
"策略解析:抛砖引玉\n\n"
"核心思想:以小博大,以较小代价换取更大利益\n\n"
"• 抛砖:提供较小的利益或诱饵(如图中砖块)\n"
"• 引玉:引诱对方暴露更大的价值或资源(如图中美玉)\n\n"
"应用场景:\n"
" - 商业谈判中先提供小优惠\n"
" - 军事中用小股部队引诱敌人主力\n"
" - 社交中先分享小信息换取大情报"
)
ax.text(1.0, 3.0, explanation, fontsize=14, ha='left', va='top',
bbox=dict(boxstyle="round,pad=0.6", fc='#fffaf0', ec='#d2b48c', alpha=0.9),
linespacing=1.6)
# 添加策略步骤
steps = [
("1", "抛砖方抛出诱饵(砖)", (4.0, 2.5)),
("2", "引玉方被诱饵吸引", (8.0, 2.5)),
("3", "引玉方暴露核心利益(玉)", (11.0, 2.5)),
("4", "抛砖方获取更大利益", (10.0, 1.5))
]
for step in steps:
ax.text(step[2][0], step[2][1], f"{step[0]}. {step[1]}", fontsize=12,
ha='center', va='center', bbox=dict(boxstyle="round,pad=0.3", fc='#f5f5f5', ec='gray'))
# 添加三十六计标识
ax.text(13.5, 9.5, "三十六计", fontsize=18, ha='right', va='top',
fontweight='bold', color='#8B0000',
bbox=dict(boxstyle="round,pad=0.4", fc='#fffaf0', ec='#8B0000'))
ax.text(13.5, 8.8, "第十七计", fontsize=16, ha='right', va='top',
fontweight='bold', color='#8B0000')
# 添加装饰元素
# 地面
ground = Rectangle((0, 0), 14, 2, color='#deb887', alpha=0.7)
ax.add_patch(ground)
# 草
for _ in range(50):
x = np.random.uniform(0, 14)
y = np.random.uniform(0, 2.2)
height = np.random.uniform(0.1, 0.4)
ax.plot([x, x], [y, y+height], color='#2e8b57', linewidth=1, alpha=0.5)
# 云
for i in range(3):
x = 2 + i * 4
y = 9.0
ax.plot(x, y, 'o', markersize=30, color='white', alpha=0.8)
ax.plot(x+0.5, y-0.2, 'o', markersize=25, color='white', alpha=0.8)
ax.plot(x-0.5, y-0.1, 'o', markersize=20, color='white', alpha=0.8)
# 光晕效果(在玉周围)
for i in range(5):
radius = 0.8 + i * 0.2
alpha = 0.3 - i * 0.05
circle = Circle((8.0, 5.0), radius, fill=False, ec='#7cfc00', alpha=alpha, lw=2)
ax.add_patch(circle)
# 砖的光晕(较弱)
for i in range(3):
radius = 0.5 + i * 0.1
alpha = 0.2 - i * 0.05
circle = Circle((5.0, 5.0), radius, fill=False, ec='#8B4513', alpha=alpha, lw=1)
ax.add_patch(circle)
plt.tight_layout()
plt.savefig('抛砖引玉.png', dpi=300, bbox_inches='tight')
plt.show()
擒贼擒王
摧其坚,夺其魁,以解其体。龙战于野,其道穷也。
打击核心人物或关键环节,瓦解整体。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(12, 8), facecolor='#f5f5dc')
fig.suptitle('擒贼擒王策略示意图', fontsize=20, fontweight='bold', color='#8B0000')
# 设置背景
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off')
# 添加古代卷轴背景效果
rect = Rectangle((0.2, 0.2), 9.6, 7.6, fill=True, color='#f5f5dc', ec='#8B4513', lw=3)
ax.add_patch(rect)
# 绘制敌方阵营
enemy_camp = Rectangle((1, 3), 8, 4, fill=True, color='#ffb6c1', alpha=0.5, ec='#8B0000', lw=2)
ax.add_patch(enemy_camp)
# 绘制普通士兵(贼)
num_soldiers = 30
soldier_positions = []
for _ in range(num_soldiers):
while True:
x = np.random.uniform(1.5, 8.5)
y = np.random.uniform(3.5, 6.5)
# 避免位置太靠近国王
if np.sqrt((x - 5)**2 + (y - 5)**2) > 0.8:
soldier_positions.append((x, y))
circle = Circle((x, y), 0.2, color='#8B0000', alpha=0.7)
ax.add_patch(circle)
break
# 绘制国王(王)
king = Circle((5, 5), 0.5, color='gold', ec='black', lw=1.5)
ax.add_patch(king)
ax.text(5, 5, '王', fontsize=16, ha='center', va='center', fontweight='bold')
# 绘制进攻路线
arrow = Arrow(0.5, 5, 4, 0, width=0.3, color='#006400', alpha=0.8)
ax.add_patch(arrow)
ax.plot([0.5, 5], [5, 5], '--', color='#006400', lw=1.5, alpha=0.7)
# 添加策略说明
strategy_text = (
"擒贼擒王:摧毁敌人的主力,抓住敌人的首领,就可以瓦解敌人的整体力量。\n"
"语出杜甫《前出塞》诗之六:“射人先射马,擒贼先擒王。”\n\n"
"策略解析:\n"
"1. 在复杂局势中识别关键目标(王)\n"
"2. 集中优势力量直取要害\n"
"3. 瓦解敌方整体力量结构\n"
"4. 以最小代价取得最大胜利"
)
text = ax.text(1, 1.9, strategy_text, fontsize=12, color='#333333',
ha='left', va='top', wrap=True)
text.set_path_effects([path_effects.withStroke(linewidth=2, foreground='white')])
# 添加装饰元素(中国风图案)
# 左侧花纹
dec_left = Polygon(np.array([[0.1, 3], [0.3, 3.5], [0.1, 4], [0.3, 4.5],
[0.1, 5], [0.3, 5.5], [0.1, 6], [0.3, 6.5],
[0.1, 7]]), closed=False, color='#8B4513', lw=1.5)
ax.add_patch(dec_left)
# 右侧花纹
dec_right = Polygon(np.array([[9.9, 3], [9.7, 3.5], [9.9, 4], [9.7, 4.5],
[9.9, 5], [9.7, 5.5], [9.9, 6], [9.7, 6.5],
[9.9, 7]]), closed=False, color='#8B4513', lw=1.5)
ax.add_patch(dec_right)
# 添加印章
seal = Rectangle((8.5, 0.5), 1.2, 1.2, fill=True, color='#8B0000', alpha=0.8)
ax.add_patch(seal)
ax.text(9.1, 1.1, '兵法', fontsize=10, ha='center', va='center', color='white', fontweight='bold')
# 添加标题装饰
ax.plot([2, 8], [7.8, 7.8], '-', color='#8B0000', lw=2)
ax.plot([2, 8], [7.5, 7.5], '-', color='#8B0000', lw=1)
ax.plot([2, 2], [7.5, 7.8], '-', color='#8B0000', lw=1)
ax.plot([8, 8], [7.5, 7.8], '-', color='#8B0000', lw=1)
# 添加图例
ax.text(0.5, 7, '进攻路线', fontsize=10, color='#006400', ha='center')
ax.text(5, 2.5, '敌方阵营', fontsize=10, color='#8B0000', ha='center')
ax.text(5, 5.5, '王 - 敌方首领', fontsize=10, color='black', ha='center', fontweight='bold')
plt.tight_layout()
plt.savefig('擒贼擒王.png', dpi=300, bbox_inches='tight')
plt.show()
混战计(局势混乱时的策略)
釜底抽薪
不敌其力,而消其势。
从根本上削弱敌方力量。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Polygon, Arc, FancyArrowPatch
import matplotlib.path as mpath
import matplotlib.patheffects as path_effects
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10), facecolor='#f7f3e3')
fig.suptitle('釜底抽薪策略示意图', fontsize=24, fontweight='bold', color='#8B0000')
# 设置背景
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
# 添加古代卷轴背景效果
rect = Rectangle((0.5, 0.5), 13, 9, fill=True, color='#f7f3e3', ec='#8B4513', lw=4)
ax.add_patch(rect)
# 绘制大锅
pot_x, pot_y = 4, 4
pot_width, pot_height = 6, 4
pot = Arc((pot_x + pot_width / 2, pot_y), pot_width, pot_height * 0.8,
theta1=0, theta2=180, color='#333333', lw=4)
ax.add_patch(pot)
# 绘制锅底
pot_bottom = Arc((pot_x + pot_width / 2, pot_y - pot_height * 0.1), pot_width * 0.7, pot_height * 0.3,
theta1=0, theta2=180, color='#333333', lw=4)
ax.add_patch(pot_bottom)
# 绘制火焰
def create_flame(x, y, size=1.0):
flame_points = [
(x, y),
(x - 0.3 * size, y + 0.5 * size),
(x - 0.1 * size, y + 1.0 * size),
(x + 0.1 * size, y + 1.2 * size),
(x + 0.3 * size, y + 0.8 * size),
(x + 0.4 * size, y + 1.0 * size),
(x + 0.6 * size, y + 0.6 * size),
(x + 0.4 * size, y + 0.3 * size),
(x + 0.2 * size, y),
(x, y)
]
flame = Polygon(flame_points, closed=True, color='#FF4500', alpha=0.8)
ax.add_patch(flame)
inner_flame = Polygon([(x, y + 0.2 * size),
(x - 0.1 * size, y + 0.5 * size),
(x + 0.1 * size, y + 0.8 * size),
(x + 0.3 * size, y + 0.6 * size),
(x + 0.2 * size, y + 0.3 * size)],
closed=True, color='#FFFF00', alpha=0.7)
ax.add_patch(inner_flame)
# 添加火焰
for i in range(5):
x = pot_x + 1 + i * 1.0
create_flame(x, pot_y + 0.2, size=0.8 + i * 0.1)
# 绘制柴火
def create_wood(x, y, length=1.5, angle=0, burning=False):
wood = Rectangle((x, y), length, 0.3, angle=angle,
color='#8B4513', ec='#5D2906', lw=1.5)
ax.add_patch(wood)
# 添加木纹
for j in range(3):
pos = x + 0.2 + j * 0.4
ax.plot([pos, pos + 0.2], [y + 0.15, y + 0.15], 'k-', lw=0.5)
# 如果燃烧,添加小火焰
if burning:
create_flame(x + length / 2, y + 0.3, size=0.3)
# 添加柴火
wood_positions = [
(3.5, 3.0, 1.8, 10),
(4.0, 2.7, 1.6, -5),
(5.0, 2.4, 2.0, 0),
(6.0, 2.8, 1.7, 15),
(7.0, 2.5, 1.9, -10)
]
for i, (x, y, l, a) in enumerate(wood_positions):
create_wood(x, y, l, a, burning=(i != 2))
# 绘制被抽出的柴火
create_wood(10, 5.5, 2.0, 30)
create_flame(10.8, 5.8, size=0.4) # 柴火上的小火苗
# 绘制抽柴的动作(手)
hand = mpath.Path
hand_verts = [
(8.5, 4.0), # 手腕
(8.8, 4.3),
(9.0, 4.5),
(9.2, 4.8), # 手掌
(9.0, 5.0),
(8.8, 4.9),
(8.7, 4.7),
(8.5, 4.5),
(8.3, 4.3),
(8.5, 4.0)
]
hand_path = mpath.Path(hand_verts)
hand_patch = Polygon(hand_verts, closed=True, color='#FFE4C4', ec='#CD853F', lw=1.5)
ax.add_patch(hand_patch)
# 绘制抽柴的箭头
arrow = FancyArrowPatch((9.2, 4.8), (10.5, 5.5),
arrowstyle='->,head_width=0.3,head_length=0.5',
color='#006400', lw=2, mutation_scale=20)
ax.add_patch(arrow)
# 绘制策略说明
strategy_text = (
"釜底抽薪:不从正面直接对抗敌人的锋芒,而是从根本上削弱敌人的气势和力量来源。\n"
"语出《吕氏春秋·尽数》:“夫以汤止沸,沸愈不止,去其火则止矣。”\n\n"
"策略解析:\n"
"1. 识别敌人的根本力量来源(如资源、后勤、盟友)\n"
"2. 避免与敌人正面冲突\n"
"3. 攻击敌人依赖的基础和根本\n"
"4. 从根本上瓦解敌人的力量"
)
text = ax.text(10.5, 2.5, strategy_text, fontsize=14, color='#333333',
ha='left', va='top', wrap=True, linespacing=1.8)
text.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#f7f3e3')])
# 添加标题装饰
ax.plot([3, 11], [9.2, 9.2], '-', color='#8B0000', lw=3)
ax.plot([3, 11], [8.8, 8.8], '-', color='#8B0000', lw=1.5)
ax.plot([3, 3], [8.8, 9.2], '-', color='#8B0000', lw=1.5)
ax.plot([11, 11], [8.8, 9.2], '-', color='#8B0000', lw=1.5)
# 添加图例和标签
ax.text(7, 3.8, '釜中之火(表面问题)', fontsize=12, color='#8B0000', ha='center')
ax.text(7, 2.2, '薪柴(根本力量来源)', fontsize=12, color='#8B4513', ha='center')
ax.text(10.5, 6.5, '抽薪(消除根本)', fontsize=12, color='#006400', ha='center')
ax.text(9, 4.5, '釜底抽薪行动', fontsize=12, color='#CD853F', ha='center', rotation=-30)
# 添加印章
seal = Rectangle((12.2, 0.8), 1.2, 1.2, fill=True, color='#8B0000', alpha=0.8)
ax.add_patch(seal)
ax.text(12.8, 1.4, '兵法', fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 添加装饰花纹
def draw_pattern(x, y, size=1.0):
angles = np.linspace(0, 2 * np.pi, 5, endpoint=False)
points = []
for angle in angles:
points.append((x + size * np.cos(angle), y + size * np.sin(angle)))
pattern = Polygon(points, closed=True, fill=False, ec='#8B4513', lw=1.5, alpha=0.7)
ax.add_patch(pattern)
draw_pattern(1.5, 1.5)
draw_pattern(1.5, 8.5)
draw_pattern(12.5, 1.5)
draw_pattern(12.5, 8.5)
plt.tight_layout()
plt.savefig('釜底抽薪.png', dpi=300, bbox_inches='tight')
plt.show()
浑水摸鱼
乘其阴乱,利其弱而无主。随,以向晦入宴息。
趁混乱谋取利益。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle, Polygon, Ellipse
import matplotlib.patheffects as path_effects
import random
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10), facecolor='#f0f8ff')
fig.suptitle('浑水摸鱼策略示意图', fontsize=24, fontweight='bold', color='#2F4F4F')
# 设置背景
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
# 添加古代卷轴背景效果
rect = Rectangle((0.5, 0.5), 13, 9, fill=True, color='#f5f5f0', ec='#8B4513', lw=4)
ax.add_patch(rect)
# 绘制池塘
pond = Ellipse((7, 5), 10, 6, fill=True, color='#4682B4', alpha=0.4, ec='#2E4B62', lw=2)
ax.add_patch(pond)
# 添加水波效果
def create_wave(x, y, size=1.0):
wave = Ellipse((x, y), size * 1.5, size * 0.5, fill=False, ec='#87CEEB', lw=1, alpha=0.6)
ax.add_patch(wave)
return wave
# 创建多个水波
for _ in range(20):
x = random.uniform(2, 12)
y = random.uniform(3, 7)
size = random.uniform(0.5, 2)
create_wave(x, y, size)
# 绘制浑浊效果(气泡和泥沙)
def create_bubble(x, y, size=0.2):
bubble = Circle((x, y), size, fill=True, color='white', alpha=0.5)
ax.add_patch(bubble)
def create_sediment(x, y):
size = random.uniform(0.05, 0.1)
sediment = Ellipse((x, y), size * 2, size, fill=True, color='#8B4513', alpha=0.5)
ax.add_patch(sediment)
# 添加气泡和泥沙
for _ in range(50):
x = random.uniform(2, 12)
y = random.uniform(3, 7)
if random.random() < 0.7:
create_bubble(x, y, random.uniform(0.1, 0.3))
else:
create_sediment(x, y)
# 绘制鱼
def create_fish(x, y, size=1.0, direction=1):
# 鱼身体
body = Ellipse((x, y), size * 1.2, size * 0.6, angle=random.uniform(-20, 20),
fill=True, color='#FF6347', alpha=0.9)
ax.add_patch(body)
# 鱼尾
tail_points = [
(x - direction * size * 0.6, y),
(x - direction * size * 0.9, y - size * 0.3),
(x - direction * size * 1.1, y),
(x - direction * size * 0.9, y + size * 0.3)
]
tail = Polygon(tail_points, closed=True, fill=True, color='#FF4500', alpha=0.9)
ax.add_patch(tail)
# 鱼鳍
fin = Ellipse((x + direction * size * 0.2, y), size * 0.3, size * 0.15,
angle=random.uniform(-30, 30), fill=True, color='#CD5C5C', alpha=0.9)
ax.add_patch(fin)
# 鱼眼
eye = Circle((x + direction * size * 0.4, y), size * 0.1, fill=True, color='black')
ax.add_patch(eye)
# 鱼嘴
ax.plot([x + direction * size * 0.5, x + direction * size * 0.55], [y, y], 'k-', lw=1)
# 创建多条鱼
fish_positions = [
(3, 4, 0.8, 1), (5, 5.5, 1.0, -1), (6.5, 4.2, 0.7, 1),
(8, 6, 0.9, -1), (9.5, 4.8, 1.1, 1), (10.5, 5.5, 0.8, -1),
(4.5, 6.2, 1.0, 1), (7.5, 3.8, 0.9, -1)
]
for x, y, size, dir in fish_positions:
create_fish(x, y, size, dir)
# 绘制搅浑水的人
# 身体
body = Ellipse((3.5, 7.5), 1.2, 2.0, fill=True, color='#FFEBCD', ec='#CD853F', lw=1)
ax.add_patch(body)
# 头
head = Circle((3.5, 8.8), 0.8, fill=True, color='#FFEBCD', ec='#CD853F', lw=1)
ax.add_patch(head)
# 眼睛
eye = Circle((3.7, 8.9), 0.1, fill=True, color='black')
ax.add_patch(eye)
# 嘴
ax.plot([3.3, 3.7], [8.7, 8.7], 'k-', lw=1.5)
# 手臂(搅水)
arm_points = [
(3.5, 8.0),
(4.0, 7.5),
(5.0, 6.0),
(6.0, 5.0),
(7.0, 4.5)
]
ax.plot(*zip(*arm_points), 'k-', lw=2.5, color='#FFEBCD')
# 手
hand = Circle((7.0, 4.5), 0.3, fill=True, color='#FFEBCD', ec='#CD853F', lw=1)
ax.add_patch(hand)
# 绘制摸鱼的人
# 身体
body2 = Ellipse((11, 7.5), 1.2, 2.0, fill=True, color='#F5DEB3', ec='#CD853F', lw=1)
ax.add_patch(body2)
# 头
head2 = Circle((11, 8.8), 0.8, fill=True, color='#F5DEB3', ec='#CD853F', lw=1)
ax.add_patch(head2)
# 眼睛(看向鱼)
eye2 = Circle((11.2, 8.9), 0.1, fill=True, color='black')
ax.add_patch(eye2)
# 嘴(微笑)
theta = np.linspace(0.2 * np.pi, 0.8 * np.pi, 30)
x_smile = 11 + 0.4 * np.cos(theta)
y_smile = 8.6 + 0.2 * np.sin(theta)
ax.plot(x_smile, y_smile, 'k-', lw=1.5)
# 手臂(摸鱼)
arm_points2 = [
(11, 8.0),
(10.5, 7.0),
(9.5, 6.0),
(8.5, 5.0),
(8.0, 4.8)
]
ax.plot(*zip(*arm_points2), 'k-', lw=2.5, color='#F5DEB3')
# 手(抓住鱼)
hand2 = Circle((8.0, 4.8), 0.3, fill=True, color='#F5DEB3', ec='#CD853F', lw=1)
ax.add_patch(hand2)
# 被抓的鱼
create_fish(7.8, 4.5, 0.6, 1)
# 绘制策略说明
strategy_text = """浑水摸鱼:趁混乱之际获取利益,利用混乱局面达成自己的目的。
语出《孙子兵法·势篇》:“乱生于治,怯生于勇,弱生于强。乱而不能治,则不可为也。”
策略解析:
1. 主动制造混乱或利用现有混乱局面
2. 在混乱中隐藏自己的真实意图
3. 趁他人不备或无力应对时行动
4. 获取利益后迅速撤离混乱中心"""
text = ax.text(1.5, 1.5, strategy_text, fontsize=14, color='#2F4F4F',
ha='left', va='top', wrap=True, linespacing=1.8)
text.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#f5f5f0')])
# 添加标题装饰
ax.plot([3, 11], [9.2, 9.2], '-', color='#2F4F4F', lw=3)
ax.plot([3, 11], [8.8, 8.8], '-', color='#2F4F4F', lw=1.5)
ax.plot([3, 3], [8.8, 9.2], '-', color='#2F4F4F', lw=1.5)
ax.plot([11, 11], [8.8, 9.2], '-', color='#2F4F4F', lw=1.5)
# 添加图例和标签
ax.text(3.5, 9.0, '制造混乱者', fontsize=12, color='#8B4513', ha='center')
ax.text(11, 9.0, '趁乱取利者', fontsize=12, color='#8B4513', ha='center')
ax.text(7, 2.5, '浑水(混乱局面)', fontsize=12, color='#4682B4', ha='center')
ax.text(8.0, 4.0, '摸鱼(获取利益)', fontsize=12, color='#FF6347', ha='center')
# 添加水纹箭头
ax.annotate('搅浑水', xy=(5, 6), xytext=(3.5, 7.5),
arrowprops=dict(arrowstyle='->', color='#8B4513', lw=1.5),
fontsize=12, color='#2F4F4F')
ax.annotate('摸鱼', xy=(8.5, 5), xytext=(10, 7),
arrowprops=dict(arrowstyle='->', color='#8B4513', lw=1.5),
fontsize=12, color='#2F4F4F')
# 添加印章
seal = Rectangle((12.2, 0.8), 1.2, 1.2, fill=True, color='#8B0000', alpha=0.8)
ax.add_patch(seal)
ax.text(12.8, 1.4, '兵法', fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 添加装饰花纹
def draw_pattern(x, y, size=1.0):
angles = np.linspace(0, 2 * np.pi, 6, endpoint=False)
points = []
for angle in angles:
points.append((x + size * np.cos(angle), y + size * np.sin(angle)))
pattern = Polygon(points, closed=True, fill=False, ec='#8B4513', lw=1.5, alpha=0.7)
ax.add_patch(pattern)
draw_pattern(1.5, 1.5)
draw_pattern(1.5, 8.5)
draw_pattern(12.5, 1.5)
draw_pattern(12.5, 8.5)
plt.tight_layout()
plt.savefig('浑水摸鱼.png', dpi=300, bbox_inches='tight')
plt.show()
金蝉脱壳
存其形,完其势;友不疑,敌不动。巽而止,蛊。
伪装撤退或转移,暗中脱离险境。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle, Polygon, Ellipse, Arc
import random
import matplotlib.patheffects as path_effects
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10), facecolor='#f0f8ff')
fig.suptitle('金蝉脱壳策略示意图', fontsize=24, fontweight='bold', color='#2F4F4F')
# 设置背景
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
# 添加古代卷轴背景效果
rect = Rectangle((0.5, 0.5), 13, 9, fill=True, color='#f5f5f0', ec='#8B4513', lw=4)
ax.add_patch(rect)
# 绘制树干
trunk = Rectangle((2, 2), 0.8, 6, fill=True, color='#8B4513')
ax.add_patch(trunk)
# 绘制树冠
def create_leaf(x, y, size=1.0, angle=0):
leaf = Ellipse((x, y), size * 2, size, angle=angle,
fill=True, color='#228B22', alpha=0.8)
ax.add_patch(leaf)
# 添加树叶
for _ in range(50):
x = random.uniform(1.5, 3.5)
y = random.uniform(6, 9)
size = random.uniform(0.5, 1.5)
angle = random.uniform(0, 180)
create_leaf(x, y, size, angle)
# 绘制蝉蜕(壳)
def draw_cicada_shell(x, y, size=1.0, angle=0):
# 身体
body = Ellipse((x, y), size * 1.5, size * 0.8, angle=angle,
fill=True, color='#D2B48C', ec='#8B4513', lw=1, alpha=0.8)
ax.add_patch(body)
# 头部
head = Ellipse((x + size * 0.5 * np.cos(np.radians(angle)),
y + size * 0.5 * np.sin(np.radians(angle))),
size * 0.7, size * 0.7, angle=angle,
fill=True, color='#D2B48C', ec='#8B4513', lw=1, alpha=0.8)
ax.add_patch(head)
# 眼睛(空壳)
eye1 = Circle((x + size * 0.7 * np.cos(np.radians(angle)) + size * 0.2 * np.cos(np.radians(angle + 30)),
y + size * 0.7 * np.sin(np.radians(angle)) + size * 0.2 * np.sin(np.radians(angle + 30))),
size * 0.1, color='black', alpha=0.5)
ax.add_patch(eye1)
eye2 = Circle((x + size * 0.7 * np.cos(np.radians(angle)) + size * 0.2 * np.cos(np.radians(angle - 30)),
y + size * 0.7 * np.sin(np.radians(angle)) + size * 0.2 * np.sin(np.radians(angle - 30))),
size * 0.1, fill=True, color='black', alpha=0.5)
ax.add_patch(eye2)
# 翅膀(透明)
wing1 = Ellipse((x - size * 0.3 * np.cos(np.radians(angle)) + size * 0.4 * np.cos(np.radians(angle + 90)),
y - size * 0.3 * np.sin(np.radians(angle)) + size * 0.4 * np.sin(np.radians(angle + 90))),
size * 1.8, size * 0.5, angle=angle + 30,
fill=True, color='#F5F5F5', alpha=0.3, ec='#C0C0C0', lw=0.5)
ax.add_patch(wing1)
wing2 = Ellipse((x - size * 0.3 * np.cos(np.radians(angle)) + size * 0.4 * np.cos(np.radians(angle - 90)),
y - size * 0.3 * np.sin(np.radians(angle)) + size * 0.4 * np.sin(np.radians(angle - 90))),
size * 1.8, size * 0.5, angle=angle - 30,
fill=True, color='#F5F5F5', alpha=0.3, ec='#C0C0C0', lw=0.5)
ax.add_patch(wing2)
# 腿
for i in range(-2, 3):
if i == 0:
continue
leg_angle = angle + i * 20
ax.plot([x, x + size * 0.5 * np.cos(np.radians(leg_angle))],
[y, y + size * 0.5 * np.sin(np.radians(leg_angle))],
color='#8B4513', lw=1.5, alpha=0.8)
return body
# 绘制金蝉(活蝉)
def draw_cicada(x, y, size=1.0, angle=0, color='#32CD32'):
# 身体
body = Ellipse((x, y), size * 1.5, size * 0.8, angle=angle,
fill=True, color='#D2B48C', ec='#8B4513', lw=1, alpha=0.8)
ax.add_patch(body)
# 头部
head = Ellipse((x + size * 0.5 * np.cos(np.radians(angle)),
y + size * 0.5 * np.sin(np.radians(angle))),
size * 0.7, size * 0.7, angle=angle,
fill=True, color='#D2B48C', ec='#8B4513', lw=1, alpha=0.8)
ax.add_patch(head)
# 眼睛
eye1 = Circle((x + size * 0.7 * np.cos(np.radians(angle)) + size * 0.2 * np.cos(np.radians(angle + 30)),
y + size * 0.7 * np.sin(np.radians(angle)) + size * 0.2 * np.sin(np.radians(angle + 30))),
size * 0.1, fill=True, color='black', alpha=0.5)
ax.add_patch(eye1)
eye2 = Circle((x + size * 0.7 * np.cos(np.radians(angle)) + size * 0.2 * np.cos(np.radians(angle - 30)),
y + size * 0.7 * np.sin(np.radians(angle)) + size * 0.2 * np.sin(np.radians(angle - 30))),
size * 0.1, fill=True, color='black', alpha=0.5)
ax.add_patch(eye2)
# 翅膀
wing2 = Ellipse((x - size * 0.3 * np.cos(np.radians(angle)) + size * 0.4 * np.cos(np.radians(angle - 90)),
y - size * 0.3 * np.sin(np.radians(angle)) + size * 0.4 * np.sin(np.radians(angle - 90))),
size * 1.8, size * 0.5, angle=angle - 30,
fill=True, color='#F5F5F5', alpha=0.3, ec='#C0C0C0', lw=0.5)
ax.add_patch(wing2)
wing2 = Ellipse((x - size * 0.3 * np.cos(np.radians(angle)) + size * 0.4 * np.cos(np.radians(angle - 90)),
y - size * 0.3 * np.sin(np.radians(angle)) + size * 0.4 * np.sin(np.radians(angle - 90))),
size * 1.8, size * 0.5, angle=angle - 30,
fill=True, color='#E0FFFF', alpha=0.5, ec='#87CEEB', lw=1)
ax.add_patch(wing2)
# 腿
for i in range(-2, 3):
if i == 0:
continue
leg_angle = angle + i * 20
ax.plot([x, x + size * 0.5 * np.cos(np.radians(leg_angle))],
[y, y + size * 0.5 * np.sin(np.radians(leg_angle))],
color='#8B4513', lw=1.5, alpha=0.8)
return body
# 绘制敌人(鸟)
def draw_bird(x, y, size=1.0, direction=1):
# 身体
body = Ellipse((x, y), size * 1.2, size * 0.8, angle=10,
fill=True, color='#A9A9A9', ec='#696969', lw=1.5)
ax.add_patch(body)
# 头
head = Circle((x + direction * size * 0.5, y + size * 0.2), size * 0.4,
fill=True, color='#A9A9A9', ec='#696969', lw=1.5)
ax.add_patch(head)
# 眼睛
eye = Circle((x + direction * size * 0.6, y + size * 0.3), size * 0.08,
fill=True, color='black')
ax.add_patch(eye)
# 嘴
beak = Polygon(np.array([
(x + direction * size * 0.7, y + size * 0.2),
(x + direction * size * 1.0, y + size * 0.2),
(x + direction * size * 0.8, y + size * 0.1)
]), fill=True, color='#FFD700')
ax.add_patch(beak)
# 翅膀
wing = Ellipse((x - direction * size * 0.2, y), size * 1.0, size * 0.4, angle=-30,
fill=True, color='#808080', ec='#696969', lw=1, alpha=0.8)
ax.add_patch(wing)
# 尾巴
tail = Polygon(np.array([
(x - direction * size * 0.8, y),
(x - direction * size * 1.0, y + size * 0.3),
(x - direction * size * 1.0, y - size * 0.3),
]), fill=True, color='#808080', ec='#696969', lw=1)
ax.add_patch(tail)
# 腿
ax.plot([x - direction * size * 0.2, x - direction * size * 0.2], [y - size * 0.4, y - size * 0.7],
'k-', lw=1.5)
ax.plot([x - direction * size * 0.4, x - direction * size * 0.4], [y - size * 0.4, y - size * 0.7],
'k-', lw=1.5)
# 绘制蝉蜕(壳)在树干上
shell = draw_cicada_shell(2.4, 6.5, 0.8, angle=90)
# 绘制金蝉(活蝉)正在飞走
cicada = draw_cicada(8, 7, 0.7, angle=20, color='#32CD32')
# 绘制敌人(鸟)盯着蝉蜕
bird = draw_bird(4, 8, 1.0, direction=1)
# 绘制脱壳轨迹(虚线)
ax.plot([2.4, 4, 6, 8], [6.5, 7, 7.2, 7], 'g--', lw=2, alpha=0.7)
# 添加轨迹箭头
ax.annotate('', xy=(7.5, 7.1), xytext=(8.5, 7.1),
arrowprops=dict(arrowstyle='->', color='green', lw=2))
# 绘制策略说明
strategy_text = (
"金蝉脱壳:在危险情况下巧妙地脱身,留下虚假表象迷惑敌人。\n"
"语出《元曲选·朱砂担》第一折:“兄弟,与你一搭儿做买卖呀,他倒是个金蝉脱壳计。”\n\n"
"策略解析:\n"
"1. 制造假象:留下外表完整的表象(蝉蜕)\n"
"2. 秘密转移:主力或核心秘密撤离\n"
"3. 迷惑敌人:使敌人误以为目标仍在原处\n"
"4. 安全脱身:在敌人未察觉时完成转移"
)
text = ax.text(3, 5, strategy_text, fontsize=14, color='#2F4F4F',
ha='left', va='top', wrap=True, linespacing=1.8)
text.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#f5f5f0')])
# 添加标题装饰
ax.plot([3, 11], [9.2, 9.2], '-', color='#2F4F4F', lw=3)
ax.plot([3, 11], [8.8, 8.8], '-', color='#2F4F4F', lw=1.5)
ax.plot([3, 3], [8.8, 9.2], '-', color='#2F4F4F', lw=1.5)
ax.plot([11, 11], [8.8, 9.2], '-', color='#2F4F4F', lw=1.5)
# 添加图例和标签
ax.text(2.4, 5.8, '蝉蜕(虚假表象)', fontsize=12, color='#8B4513', ha='center', rotation=90)
ax.text(8.5, 7.5, '金蝉(安全脱身)', fontsize=12, color='#32CD32', ha='center')
ax.text(4.5, 8.9, '敌人(被迷惑)', fontsize=12, color='#696969', ha='center')
ax.text(5, 6.8, '脱壳轨迹', fontsize=12, color='green', ha='center')
# 添加注释箭头
ax.annotate('敌人注意力', xy=(2.8, 6.5), xytext=(4, 8.5),
arrowprops=dict(arrowstyle='->', color='red', lw=1.5, connectionstyle="arc3,rad=-0.2"),
fontsize=12, color='#8B0000')
ax.annotate('秘密转移', xy=(6, 7.1), xytext=(7, 8),
arrowprops=dict(arrowstyle='->', color='green', lw=1.5),
fontsize=12, color='#006400')
# 添加印章
seal = Rectangle((12.2, 0.8), 1.2, 1.2, fill=True, color='#8B0000', alpha=0.8)
ax.add_patch(seal)
ax.text(12.8, 1.4, '兵法', fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 添加装饰花纹
def draw_pattern(x, y, size=1.0):
angles = np.linspace(0, 2 * np.pi, 5, endpoint=False)
points = []
for angle in angles:
points.append((x + size * np.cos(angle), y + size * np.sin(angle)))
pattern = Polygon(points, closed=True, fill=False, ec='#8B4513', lw=1.5, alpha=0.7)
ax.add_patch(pattern)
draw_pattern(1.5, 1.5)
draw_pattern(1.5, 8.5)
draw_pattern(12.5, 1.5)
draw_pattern(12.5, 8.5)
# 添加背景蝉鸣符号
for _ in range(20):
x = random.uniform(0.5, 13.5)
y = random.uniform(0.5, 9.5)
if random.random() < 0.3: # 只有部分位置添加
size = random.uniform(0.1, 0.3)
angle = random.uniform(0, 360)
symbol = Arc((x, y), size, size, theta1=0, theta2=180,
color='#32CD32', alpha=0.1, lw=1)
ax.add_patch(symbol)
plt.tight_layout()
plt.savefig('金蝉脱壳.png', dpi=300, bbox_inches='tight')
plt.show()
关门捉贼
小敌困之。剥,不利有攸往。
包围敌人,断其退路后歼灭。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle, Polygon
import matplotlib.patheffects as path_effects
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
plt.figure(figsize=(12, 10), dpi=100)
ax = plt.subplot(111)
ax.set_facecolor('#f0f8ff') # 设置背景色
# 设置坐标轴范围
ax.set_xlim(-1, 11)
ax.set_ylim(-1, 11)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 添加标题
title = plt.title("关门捉贼策略示意图", fontsize=24, fontweight='bold', pad=20)
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='black')])
# 添加策略描述
description = "策略思想:关起门来捉进入屋内的盗贼。对小股敌人要即时围困消灭,而不利于去急追或者远袭。"
plt.figtext(0.5, 0.85, description, ha="center", fontsize=16, style='italic', color='#333333')
# 绘制城墙
wall = Rectangle((1, 1), 8, 8, linewidth=3, edgecolor='#8B4513', facecolor='#DEB887', alpha=0.7)
ax.add_patch(wall)
# 绘制城门
gate = Rectangle((4.5, 0.5), 1, 0.5, linewidth=2, edgecolor='#8B4513', facecolor='#A52A2A', alpha=0.9)
ax.add_patch(gate)
# 绘制关上的门
left_door = Rectangle((4.5, 0.5), 0.5, 1.5, linewidth=2, edgecolor='#8B4513', facecolor='#A52A2A', alpha=0.9)
right_door = Rectangle((5, 0.5), 0.5, 1.5, linewidth=2, edgecolor='#8B4513', facecolor='#A52A2A', alpha=0.9)
ax.add_patch(left_door)
ax.add_patch(right_door)
# 绘制门环
left_ring = Circle((4.7, 1.2), 0.1, facecolor='gold', edgecolor='#8B4513', linewidth=1)
right_ring = Circle((5.3, 1.2), 0.1, facecolor='gold', edgecolor='#8B4513', linewidth=1)
ax.add_patch(left_ring)
ax.add_patch(right_ring)
# 绘制城墙上的旗帜
flags_x = [1.5, 8.5, 1.5, 8.5]
flags_y = [8.5, 8.5, 1.5, 1.5]
for x, y in zip(flags_x, flags_y):
flag = Polygon(np.array([[x, y], [x, y+0.5], [x+0.4, y+0.25]]),
closed=True, facecolor='red', edgecolor='darkred')
ax.add_patch(flag)
pole = plt.Line2D([x, x], [y, y+0.7], color='#8B4513', linewidth=2)
ax.add_line(pole)
# 绘制敌人(红点)
enemies_x = np.random.uniform(2, 8, 8)
enemies_y = np.random.uniform(2, 8, 8)
ax.scatter(enemies_x, enemies_y, s=200, color='red', alpha=0.8, zorder=10)
# 添加敌人标签
for i, (x, y) in enumerate(zip(enemies_x, enemies_y), 1):
ax.text(x, y, f'敌{i}', color='white', ha='center', va='center', fontsize=10, fontweight='bold')
# 绘制我方部队(蓝点)包围城市
def create_arc_points(center_x, center_y, radius, start_angle, end_angle, num_points):
angles = np.linspace(np.radians(start_angle), np.radians(end_angle), num_points)
x = center_x + radius * np.cos(angles)
y = center_y + radius * np.sin(angles)
return x, y
# 绘制包围圈
x1, y1 = create_arc_points(5, 5, 6, 45, 135, 6)
x2, y2 = create_arc_points(5, 5, 6, 135, 225, 6)
x3, y3 = create_arc_points(5, 5, 6, 225, 315, 6)
x4, y4 = create_arc_points(5, 5, 6, 315, 405, 6)
allies_x = np.concatenate([x1, x2, x3, x4])
allies_y = np.concatenate([y1, y2, y3, y4])
ax.scatter(allies_x, allies_y, s=150, color='blue', alpha=0.8, zorder=10)
# 添加我方部队标签
for i, (x, y) in enumerate(zip(allies_x, allies_y), 1):
ax.text(x, y, f'我{i}', color='white', ha='center', va='center', fontsize=9, fontweight='bold')
# 绘制包围箭头
for i in range(len(allies_x)):
angle = np.arctan2(5 - allies_y[i], 5 - allies_x[i])
ax.arrow(allies_x[i], allies_y[i],
0.5 * np.cos(angle), 0.5 * np.sin(angle),
head_width=0.3, head_length=0.4,
fc='blue', ec='darkblue', alpha=0.7)
# 添加策略说明
explanations = [
"1. 敌人进入我方预设的包围区域(城内)",
"2. 我方部队迅速包围敌人并关闭城门",
"3. 切断敌人所有退路和补给线",
"4. 集中优势兵力歼灭被困之敌"
]
for i, text in enumerate(explanations):
plt.text(10.5, 9 - i*0.8, text, fontsize=14, ha='left', va='top',
bbox=dict(facecolor='lightyellow', alpha=0.8, edgecolor='gold', boxstyle='round,pad=0.5'))
# 添加策略图示标签
plt.text(5, 9.5, "包围圈", fontsize=14, ha='center', va='center', color='blue',
bbox=dict(facecolor='white', alpha=0.7, edgecolor='blue'))
plt.text(5, 5, "敌人被困区域", fontsize=14, ha='center', va='center', color='red',
bbox=dict(facecolor='white', alpha=0.7, edgecolor='red'))
plt.text(4.7, 0.3, "关闭的城门", fontsize=12, ha='center', va='center', color='#8B4513')
# 添加三十六计标志
seal = plt.Circle((10.5, 0.5), 0.8, color='red', alpha=0.8)
ax.add_patch(seal)
plt.text(10.5, 0.5, "三十六计", fontsize=12, ha='center', va='center', color='white', fontweight='bold')
plt.tight_layout()
plt.savefig('关门捉贼.png', dpi=120, bbox_inches='tight')
plt.show()
远交近攻
频更其阵,抽其劲旅,待其自败,而后乘之。
结交远方势力,打击邻近对手。
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.patheffects as path_effects
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 12))
ax.set_facecolor('#f0f8ff') # 设置背景色
ax.set_xlim(0, 14)
ax.set_ylim(0, 12)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 添加标题
title = ax.set_title("远交近攻策略示意图", fontsize=26, fontweight='bold', pad=20)
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='black')])
# 添加策略描述
description = "策略思想:结交远方的国家,进攻邻近的国家。这样既防止了腹背受敌,又能逐步扩张领土。"
plt.figtext(0.6, 0.743, description, ha="center", fontsize=18, style='italic', color='#333333')
# 绘制中心国家(己方)
center_country = patches.Circle((7, 6), 1.0, facecolor='#1f77b4', edgecolor='darkblue', linewidth=2, alpha=0.9)
ax.add_patch(center_country)
plt.text(7, 6, '己方', fontsize=16, ha='center', va='center', color='white', fontweight='bold')
# 绘制邻近国家(攻击目标)
nearby_countries = [
{'pos': (4.5, 6), 'name': '邻国A', 'color': '#ff7f0e'},
{'pos': (9.5, 6), 'name': '邻国B', 'color': '#ff7f0e'},
{'pos': (7, 3.5), 'name': '邻国C', 'color': '#ff7f0e'},
{'pos': (7, 8.5), 'name': '邻国D', 'color': '#ff7f0e'}
]
for country in nearby_countries:
c = patches.Circle(country['pos'], 0.8, facecolor=country['color'], edgecolor='#8B0000', linewidth=2, alpha=0.9)
ax.add_patch(c)
plt.text(country['pos'][0], country['pos'][1], country['name'],
fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 绘制远方国家(结盟对象)
distant_countries = [
{'pos': (2, 2), 'name': '远国甲', 'color': '#2ca02c'},
{'pos': (2, 10), 'name': '远国乙', 'color': '#2ca02c'},
{'pos': (12, 2), 'name': '远国丙', 'color': '#2ca02c'},
{'pos': (12, 10), 'name': '远国丁', 'color': '#2ca02c'}
]
for country in distant_countries:
c = patches.Circle(country['pos'], 0.8, facecolor=country['color'], edgecolor='#006400', linewidth=2, alpha=0.9)
ax.add_patch(c)
plt.text(country['pos'][0], country['pos'][1], country['name'],
fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 绘制攻击箭头(己方 -> 邻近国家)
for country in nearby_countries:
dx = country['pos'][0] - 7
dy = country['pos'][1] - 6
distance = np.sqrt(dx ** 2 + dy ** 2)
# 调整箭头起始点,使其从边界开始
start_x = 7 + (dx / distance) * 1.0
start_y = 6 + (dy / distance) * 1.0
end_x = country['pos'][0] - (dx / distance) * 0.8
end_y = country['pos'][1] - (dy / distance) * 0.8
ax.arrow(start_x, start_y, dx * 0.85, dy * 0.85,
head_width=0.3, head_length=0.4,
fc='red', ec='darkred', alpha=0.8, linewidth=2)
# 绘制结盟线条(己方 -> 远方国家)
for country in distant_countries:
dx = country['pos'][0] - 7
dy = country['pos'][1] - 6
distance = np.sqrt(dx ** 2 + dy ** 2)
# 调整线条起始点
start_x = 7 + (dx / distance) * 1.0
start_y = 6 + (dy / distance) * 1.0
end_x = country['pos'][0] - (dx / distance) * 0.8
end_y = country['pos'][1] - (dy / distance) * 0.8
# 绘制虚线表示结盟
ax.plot([start_x, end_x], [start_y, end_y], '--',
color='green', linewidth=2, alpha=0.7)
# 在中间添加握手图标
mid_x = (start_x + end_x) / 2
mid_y = (start_y + end_y) / 2
ax.plot(mid_x, mid_y, 'o', markersize=15,
marker='$\u270B$', color='green', alpha=0.8)
# 添加策略说明
explanations = [
"策略核心:结交远方的国家(绿色),进攻邻近的国家(橙色)",
"实施步骤:",
"1. 避免同时与多方为敌,优先攻击邻近威胁",
"2. 与远方国家建立友好关系,防止腹背受敌",
"3. 逐步扩张领土,先近后远,各个击破",
"4. 在消灭邻近国家后,再考虑与远方国家的关系"
]
for i, text in enumerate(explanations):
y_pos = 11.2 - i * 0.7
plt.text(-5.6, y_pos, text, fontsize=14, ha='left', va='top',
bbox=dict(facecolor='#FFFACD', alpha=0.8, edgecolor='gold', boxstyle='round,pad=0.5'))
# 添加战略优势说明
advantages = [
"✓ 避免多线作战",
"✓ 集中力量消灭邻近威胁",
"✓ 获得战略纵深",
"✓ 逐步扩张领土"
]
for i, text in enumerate(advantages):
x_pos = 16.8
y_pos = 11.2 - i * 0.7
plt.text(x_pos, y_pos, text, fontsize=14, ha='right', va='top',
bbox=dict(facecolor='#E0FFFF', alpha=0.8, edgecolor='#1E90FF', boxstyle='round,pad=0.5'))
# 添加图例
legend_elements = [
patches.Patch(facecolor='#1f77b4', edgecolor='darkblue', label='己方国家'),
patches.Patch(facecolor='#ff7f0e', edgecolor='#8B0000', label='邻近国家(攻击目标)'),
patches.Patch(facecolor='#2ca02c', edgecolor='#006400', label='远方国家(结盟对象)'),
plt.Line2D([0], [0], color='red', lw=2, label='进攻方向'),
plt.Line2D([0], [0], color='green', linestyle='--', lw=2, label='结盟关系')
]
ax.legend(handles=legend_elements, loc='lower center',
bbox_to_anchor=(0.5, 0.02), ncol=3, fontsize=14, framealpha=0.9)
# 添加三十六计标志
seal = patches.Circle((13.5, 0.8), 0.6, color='red', alpha=0.8)
ax.add_patch(seal)
plt.text(13.5, 0.8, "三十六计", fontsize=12, ha='center', va='center',
color='white', fontweight='bold')
plt.tight_layout()
plt.subplots_adjust(top=0.92, bottom=0.08)
plt.savefig('远交近攻.png', dpi=120, bbox_inches='tight')
plt.show()
假道伐虢
两大之间,敌胁以从,我假以势。困,有言不信。
借路通行,顺势占领地盘。
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.patheffects as path_effects
# 设置中文字体支持
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_facecolor('#f0f8ff') # 设置背景色
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 添加标题
title = ax.set_title("假道伐虢策略示意图", fontsize=26, fontweight='bold', pad=20)
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='black')])
# 添加策略描述
description = "策略思想:借道他国去攻打另一个国家,在归途中顺势将借道的国家也灭掉。一箭双雕,消灭两个敌人。"
plt.figtext(0.5, 0.9, description, ha="center", fontsize=18, style='italic', color='#333333')
# 绘制三个国家
# 己方国家
our_country = patches.Circle((2, 5), 1.0, facecolor='#1f77b4', edgecolor='darkblue', linewidth=2, alpha=0.9)
ax.add_patch(our_country)
plt.text(2, 5, '己方\n(A)', fontsize=16, ha='center', va='center', color='white', fontweight='bold')
# 被借道的国家
path_country = patches.Rectangle((6, 3.5), 2, 3, facecolor='#2ca02c', edgecolor='#006400', linewidth=2, alpha=0.9)
ax.add_patch(path_country)
plt.text(7, 5, '借道国\n(B)', fontsize=16, ha='center', va='center', color='white', fontweight='bold')
# 目标国家
target_country = patches.Circle((11, 5), 1.2, facecolor='#ff7f0e', edgecolor='#8B0000', linewidth=2, alpha=0.9)
ax.add_patch(target_country)
plt.text(11, 5, '目标国\n(C)', fontsize=16, ha='center', va='center', color='white', fontweight='bold')
# 绘制策略路线
# 第一阶段:借道B国去攻打C国
arrow1 = patches.FancyArrowPatch((3, 5), (5.5, 5),
arrowstyle='->', mutation_scale=20,
color='blue', linewidth=3, alpha=0.8)
ax.add_patch(arrow1)
plt.text(4.25, 5.5, '1. 借道请求\n"假道于B"', fontsize=14, ha='center', va='bottom',
bbox=dict(facecolor='lightblue', alpha=0.8, boxstyle='round,pad=0.5'))
# 第二阶段:通过B国领土
arrow2 = patches.FancyArrowPatch((5.5, 5), (8.5, 5),
arrowstyle='->', mutation_scale=20,
color='blue', linewidth=3, alpha=0.8)
ax.add_patch(arrow2)
plt.text(7, 4.5, '2. 通过B国领土\n"借道行军"', fontsize=14, ha='center', va='top',
bbox=dict(facecolor='lightblue', alpha=0.8, boxstyle='round,pad=0.5'))
# 第三阶段:攻打C国
arrow3 = patches.FancyArrowPatch((8.5, 5), (9.8, 5),
arrowstyle='->', mutation_scale=20,
color='red', linewidth=3, alpha=0.8)
ax.add_patch(arrow3)
plt.text(9.15, 5.5, '3. 攻打目标国\n"伐虢"', fontsize=14, ha='center', va='bottom',
bbox=dict(facecolor='lightcoral', alpha=0.8, boxstyle='round,pad=0.5'))
# 绘制战斗标志
battle = plt.Circle((10.5, 5.5), 0.5, color='red', alpha=0.6)
ax.add_patch(battle)
plt.text(10.5, 5.5, '战', fontsize=16, ha='center', va='center', color='white', fontweight='bold')
# 第四阶段:回师途中攻打B国
arrow4 = patches.FancyArrowPatch((9.8, 5), (8.5, 5),
arrowstyle='->', mutation_scale=20,
color='red', linewidth=3, alpha=0.8, linestyle='dashed')
ax.add_patch(arrow4)
plt.text(9.15, 4.5, '4. 回师途中\n"顺势攻B"', fontsize=14, ha='center', va='top',
bbox=dict(facecolor='lightcoral', alpha=0.8, boxstyle='round,pad=0.5'))
# 第五阶段:消灭B国
arrow5 = patches.FancyArrowPatch((8.5, 5), (5.5, 5),
arrowstyle='->', mutation_scale=20,
color='red', linewidth=3, alpha=0.8, linestyle='dashed')
ax.add_patch(arrow5)
plt.text(7, 5.5, '5. 占领B国\n"一箭双雕"', fontsize=14, ha='center', va='bottom',
bbox=dict(facecolor='lightcoral', alpha=0.8, boxstyle='round,pad=0.5'))
# 第六阶段:返回己方
arrow6 = patches.FancyArrowPatch((5.5, 5), (3, 5),
arrowstyle='->', mutation_scale=20,
color='darkred', linewidth=3, alpha=0.8, linestyle='dashed')
ax.add_patch(arrow6)
plt.text(4.25, 4.5, '6. 凯旋而归\n领土扩张', fontsize=14, ha='center', va='top',
bbox=dict(facecolor='#FFD700', alpha=0.8, boxstyle='round,pad=0.5'))
# 添加策略说明
explanations = [
"策略核心:借道他国攻打目标国,返程时顺势消灭借道国",
"历史典故:",
" 春秋时期,晋国向虞国借道攻打虢国",
" 灭虢国后,晋军在归途中突袭虞国,将其消灭",
"关键要素:",
" 1. 寻找合适的借口向B国借道",
" 2. 隐藏真实意图,使B国放松警惕",
" 3. 在B国境内秘密侦察地形和军情",
" 4. 灭C国后迅速回师,趁B国不备发动攻击"
]
for i, text in enumerate(explanations):
y_pos = 9.5 - i * 0.65
plt.text(-4.0, y_pos, text, fontsize=14, ha='left', va='top',
bbox=dict(facecolor='#FFFACD', alpha=0.8, edgecolor='gold', boxstyle='round,pad=0.5'))
# 添加战略优势说明
advantages = [
"✓ 一石二鸟,消灭两个敌人",
"✓ 减少行军距离和补给困难",
"✓ 借道国通常放松警惕,易于攻取",
"✓ 获得对方领土和资源",
"✓ 避免两线作战的风险"
]
for i, text in enumerate(advantages):
x_pos = 13.0
y_pos = 9.5 - i * 0.65
plt.text(x_pos, y_pos, text, fontsize=14, ha='right', va='top',
bbox=dict(facecolor='#E0FFFF', alpha=0.8, edgecolor='#1E90FF', boxstyle='round,pad=0.5'))
# 添加策略阶段图例
legend_elements = [
patches.FancyArrowPatch((0,0), (1,0), arrowstyle='->', color='blue', linewidth=2, label='借道行军阶段'),
patches.FancyArrowPatch((0,0), (1,0), arrowstyle='->', color='red', linewidth=2, label='攻打目标国'),
patches.FancyArrowPatch((0,0), (1,0), arrowstyle='->', color='red', linestyle='dashed', linewidth=2, label='回师灭借道国'),
patches.Circle((0.5,0.5), 0.1, facecolor='#1f77b4', label='己方 (A)'),
patches.Rectangle((0,0), 0.1, 0.1, facecolor='#2ca02c', label='借道国 (B)'),
patches.Circle((0.5,0.5), 0.1, facecolor='#ff7f0e', label='目标国 (C)')
]
ax.legend(handles=legend_elements, loc='lower center',
bbox_to_anchor=(0.5, 0.02), ncol=3, fontsize=12, framealpha=0.9)
# 添加三十六计标志
seal = patches.Circle((13.5, 0.8), 0.6, color='red', alpha=0.8)
ax.add_patch(seal)
plt.text(13.5, 0.8, "三十六计", fontsize=12, ha='center', va='center',
color='white', fontweight='bold')
plt.tight_layout()
plt.subplots_adjust(top=0.92, bottom=0.12)
plt.savefig('假道伐虢.png', dpi=120, bbox_inches='tight')
plt.show()
并战计(应对盟友或潜在对手的策略)
偷梁换柱
频更其阵,抽其劲旅,待其自败,而后乘之。
暗中替换关键要素,改变局势。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle, Polygon
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
# 创建图形和坐标轴
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 设置背景颜色
fig.patch.set_facecolor('#f0f8ff')
ax.set_facecolor('#f0f8ff')
# 绘制策略名称
text = ax.text(7, 9.2, '偷梁换柱策略示意图', fontsize=48, ha='center',
fontname='SimHei', color='#8B0000', fontweight='bold')
text.set_path_effects([path_effects.withStroke(linewidth=4, foreground='#FFD700')])
# 绘制策略解释
explanation = "策略说明:暗中更换事物的关键部分,以达到改变事物本质的目的。比喻暗中玩弄手法,以假代真。"
ax.text(7, 0.7, explanation, fontsize=16, ha='center',
fontname='SimHei', color='#2F4F4F')
# 绘制古代建筑(柱梁结构)
def draw_building(x, y, scale=1.0):
# 地基
foundation = Rectangle((x - 1.5 * scale, y - 0.3 * scale), 3 * scale, 0.3 * scale,
color='#8B4513', alpha=0.9)
ax.add_patch(foundation)
# 柱子
for i in range(4):
col_x = x - 1.2 * scale + i * 0.8 * scale
column = Rectangle((col_x, y), 0.3 * scale, 3 * scale,
color='#CD853F', alpha=0.9, ec='#8B4513', lw=1.5)
ax.add_patch(column)
# 柱础
base = Circle((col_x + 0.15 * scale, y), 0.2 * scale, color='#8B4513')
ax.add_patch(base)
# 梁
beam = Rectangle((x - 1.5 * scale, y + 3 * scale), 3 * scale, 0.25 * scale,
color='#A52A2A', alpha=0.9, ec='#8B4513', lw=1.5)
ax.add_patch(beam)
# 屋顶
roof_points = [(x - 2 * scale, y + 3.25 * scale),
(x, y + 4.5 * scale),
(x + 2 * scale, y + 3.25 * scale)]
roof = Polygon(roof_points, closed=True, color='#B22222', alpha=0.8)
ax.add_patch(roof)
return column, beam
# 绘制原始建筑(左侧)
original_col, original_beam = draw_building(3.5, 2)
# 添加柱子标签
ax.text(3.5 - 1.2, 4.5, '柱', fontsize=18, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4169E1', alpha=0.8, boxstyle='round'))
ax.text(3.5 - 1.2 + 0.8, 4.5, '柱', fontsize=18, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4169E1', alpha=0.8, boxstyle='round'))
ax.text(3.5 - 1.2 + 1.6, 4.5, '柱', fontsize=18, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4169E1', alpha=0.8, boxstyle='round'))
ax.text(3.5 - 1.2 + 2.4, 4.5, '柱', fontsize=18, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4169E1', alpha=0.8, boxstyle='round'))
# 添加梁标签
ax.text(3.5, 3.8, '梁', fontsize=20, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#8B0000', alpha=0.8, boxstyle='round'))
# 绘制被替换建筑(右侧)
replaced_col, replaced_beam = draw_building(10.5, 2)
# 添加被替换的柱子标签
ax.text(10.5 - 1.2, 4.5, '伪柱', fontsize=14, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4682B4', alpha=0.8, boxstyle='round'))
ax.text(10.5 - 1.2 + 0.8, 4.5, '伪柱', fontsize=14, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4682B4', alpha=0.8, boxstyle='round'))
ax.text(10.5 - 1.2 + 1.6, 4.5, '伪柱', fontsize=14, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4682B4', alpha=0.8, boxstyle='round'))
ax.text(10.5 - 1.2 + 2.4, 4.5, '伪柱', fontsize=14, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4682B4', alpha=0.8, boxstyle='round'))
# 添加被替换的梁标签
ax.text(10.5, 3.8, '伪梁', fontsize=16, ha='center', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#B22222', alpha=0.8, boxstyle='round'))
# 绘制被偷走的梁柱
def draw_stolen_items():
# 被偷的柱子
stolen_col = Rectangle((6.5, 5.5), 0.3, 1.5, color='#4169E1', alpha=0.8)
ax.add_patch(stolen_col)
ax.text(6.65, 6.5, '被偷的柱', fontsize=12, ha='left', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4169E1', alpha=0.8))
# 被偷的梁
stolen_beam = Rectangle((7.5, 6.2), 1.5, 0.25, color='#8B0000', alpha=0.8)
ax.add_patch(stolen_beam)
ax.text(7.5, 6.1, '被偷的梁', fontsize=12, ha='center', va='bottom',
fontname='SimHei', color='white', bbox=dict(facecolor='#8B0000', alpha=0.8))
# 伪柱
fake_col = Rectangle((8.5, 5.7), 0.3, 1.5, color='#4682B4', alpha=0.8)
ax.add_patch(fake_col)
ax.text(8.65, 6.3, '伪柱', fontsize=12, ha='left', va='center',
fontname='SimHei', color='white', bbox=dict(facecolor='#4682B4', alpha=0.8))
# 伪梁
fake_beam = Rectangle((5.5, 6.2), 1.5, 0.25, color='#B22222', alpha=0.8)
ax.add_patch(fake_beam)
ax.text(5.5, 6.1, '伪梁', fontsize=12, ha='center', va='bottom',
fontname='SimHei', color='white', bbox=dict(facecolor='#B22222', alpha=0.8))
draw_stolen_items()
# 绘制偷梁换柱的过程
def draw_process():
# 偷梁
ax.annotate('', xy=(5.5, 6), xytext=(3.5, 3.5),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=2,
connectionstyle="arc3,rad=-0.2"))
ax.text(4, 5.2, '偷梁', fontsize=16, ha='center',
fontname='SimHei', color='#8B0000', fontweight='bold')
# 换柱
ax.annotate('', xy=(10.5, 3.5), xytext=(8.5, 6.3),
arrowprops=dict(arrowstyle='->', color='#4682B4', lw=2,
connectionstyle="arc3,rad=-0.2"))
ax.text(9.5, 4.8, '换柱', fontsize=16, ha='center',
fontname='SimHei', color='#4682B4', fontweight='bold')
# 偷柱
ax.annotate('', xy=(6.5, 6.3), xytext=(3.5, 4.5),
arrowprops=dict(arrowstyle='->', color='#4169E1', lw=2,
connectionstyle="arc3,rad=0.2"))
ax.text(5, 5.8, '偷柱', fontsize=16, ha='center',
fontname='SimHei', color='#4169E1', fontweight='bold')
# 换梁
ax.annotate('', xy=(10.5, 3.8), xytext=(7.5, 6),
arrowprops=dict(arrowstyle='->', color='#B22222', lw=2,
connectionstyle="arc3,rad=0.2"))
ax.text(8.8, 5.2, '换梁', fontsize=16, ha='center',
fontname='SimHei', color='#B22222', fontweight='bold')
draw_process()
# 绘制人物
def draw_person(x, y, scale=1.0, color='blue', face_color='#FFEBCD', direction='right'):
# 身体
body = Circle((x, y), 0.4 * scale, color=color, alpha=0.8)
ax.add_patch(body)
# 头
head = Circle((x, y + 0.6 * scale), 0.3 * scale, color=face_color, ec='black', lw=0.8)
ax.add_patch(head)
# 眼睛
eye_offset = 0.1 * scale if direction == 'right' else -0.1 * scale
ax.plot(x + eye_offset, y + 0.65 * scale, 'ko', markersize=2 * scale)
# 手臂
if direction == 'right':
ax.plot([x, x + 0.5 * scale], [y, y + 0.2 * scale], color=color, lw=2 * scale)
else:
ax.plot([x, x - 0.5 * scale], [y, y + 0.2 * scale], color=color, lw=2 * scale)
# 腿
ax.plot([x, x + 0.2 * scale], [y - 0.3 * scale, y - 0.8 * scale], color=color, lw=2 * scale)
ax.plot([x, x - 0.2 * scale], [y - 0.3 * scale, y - 0.8 * scale], color=color, lw=2 * scale)
# 绘制偷梁换柱的人物
draw_person(5.5, 6.8, 0.8, '#32CD32', direction='left') # 偷梁者
ax.text(5.5, 7.5, '偷换者', fontsize=12, ha='center', fontname='SimHei', color='#006400')
draw_person(2, 5, 0.7, '#8B0000', direction='right') # 守卫(睡觉)
ax.text(2, 5.8, '守卫', fontsize=12, ha='center', fontname='SimHei', color='#8B0000')
# 绘制睡觉的ZZZ
ax.text(2.5, 5.2, 'Z', fontsize=10, ha='center', fontname='SimHei', color='#8B0000', rotation=30)
ax.text(2.7, 5.1, 'Z', fontsize=12, ha='center', fontname='SimHei', color='#8B0000', rotation=15)
ax.text(2.9, 5.0, 'Z', fontsize=14, ha='center', fontname='SimHei', color='#8B0000')
# 绘制被替换后的危险状态
ax.text(10.5, 1.5, '危险!', fontsize=20, ha='center', fontname='SimHei',
color='red', fontweight='bold')
danger_sign = Polygon(np.array([(10.5, 0.8), (10.3, 0.5), (10.7, 0.5)]),
color='red', alpha=0.8)
ax.add_patch(danger_sign)
ax.text(10.5, 0.4, '结构不稳', fontsize=14, ha='center',
fontname='SimHei', color='#8B0000')
# 添加装饰元素 - 云朵
def draw_cloud(x, y, size=1.0):
cloud = Circle((x, y), size * 0.7, color='white', alpha=0.9)
ax.add_patch(cloud)
cloud2 = Circle((x + size * 0.5, y + size * 0.3), size * 0.6, color='white', alpha=0.9)
ax.add_patch(cloud2)
cloud3 = Circle((x + size * 0.9, y), size * 0.5, color='white', alpha=0.9)
ax.add_patch(cloud3)
cloud4 = Circle((x + size * 0.5, y - size * 0.3), size * 0.6, color='white', alpha=0.9)
ax.add_patch(cloud4)
draw_cloud(1.5, 8.5, 0.8)
draw_cloud(12.5, 8.8, 1.0)
# 添加装饰元素 - 月亮
moon = Circle((12, 8), 0.6, color='#F0E68C')
ax.add_patch(moon)
moon_dark = Circle((12.2, 8), 0.5, color='#f0f8ff')
ax.add_patch(moon_dark)
# 添加装饰元素 - 星星
for i in range(8):
x = np.random.uniform(0.5, 13.5)
y = np.random.uniform(8.5, 9.5)
size = np.random.uniform(0.05, 0.15)
star = Circle((x, y), size, color='#FFD700')
ax.add_patch(star)
# 添加装饰元素 - 树木
def draw_tree(x, y, size=1.0):
trunk = Rectangle((x - 0.1 * size, y), 0.2 * size, 0.8 * size, color='#8B4513')
ax.add_patch(trunk)
leaves = Circle((x, y + 1.2 * size), 0.5 * size, color='#2E8B57')
ax.add_patch(leaves)
leaves2 = Circle((x + 0.3 * size, y + 0.9 * size), 0.4 * size, color='#3CB371')
ax.add_patch(leaves2)
leaves3 = Circle((x - 0.3 * size, y + 0.9 * size), 0.4 * size, color='#3CB371')
ax.add_patch(leaves3)
draw_tree(1.0, 1.0)
draw_tree(13.0, 1.0)
draw_tree(0.5, 1.5, 0.8)
# 添加时间标注
ax.text(1, 9.2, '夜', fontsize=16, ha='center', fontname='SimHei', color='#4B0082')
ax.text(13, 9.2, '间', fontsize=16, ha='center', fontname='SimHei', color='#4B0082')
# 添加区域标注
ax.text(3.5, 1.0, '原始结构', fontsize=16, ha='center', fontname='SimHei',
color='#006400', bbox=dict(facecolor='#F0FFF0', alpha=0.7, boxstyle='round'))
ax.text(10.5, 1.0, '被替换结构', fontsize=16, ha='center', fontname='SimHei',
color='#8B0000', bbox=dict(facecolor='#FFF0F5', alpha=0.7, boxstyle='round'))
ax.text(7, 7.0, '偷换过程', fontsize=16, ha='center', fontname='SimHei',
color='#4B0082', bbox=dict(facecolor='#F0F8FF', alpha=0.7, boxstyle='round'))
plt.tight_layout()
plt.savefig('偷梁换柱.png', dpi=300, bbox_inches='tight')
plt.show()
指桑骂槐
大凌小者,警以诱之。刚中而应,行险而顺。
借批评他人警示目标对象。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Wedge, Ellipse, ConnectionPatch
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建图形
plt.figure(figsize=(12, 8))
ax = plt.subplot(111)
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 设置背景颜色
ax.set_facecolor('#f0f8ff')
# 标题
plt.title('指桑骂槐策略示意图',
fontsize=20, fontweight='bold',
color='#8B4513', pad=20)
# 添加副标题
plt.figtext(0.5, 0.85,
"表面上指责桑树,实则暗骂槐树\n指此说彼,借题发挥",
ha="center", fontsize=16, color='#556B2F',
bbox=dict(facecolor='#f5f5dc', alpha=0.5, edgecolor='#d2b48c', boxstyle='round,pad=0.5'))
# 绘制桑树
mulberry_x, mulberry_y = 3, 4
mulberry_trunk = plt.Rectangle((mulberry_x-0.2, mulberry_y), 0.4, 2,
facecolor='#8B4513', edgecolor='#654321', lw=2)
ax.add_patch(mulberry_trunk)
# 桑树叶子 (使用散点表示叶子)
for _ in range(40):
x = mulberry_x + np.random.uniform(-1.5, 1.5)
y = mulberry_y + 1 + np.random.uniform(0, 3)
size = np.random.uniform(20, 80)
color = np.random.choice(['#228B22', '#32CD32', '#006400'])
plt.scatter(x, y, s=size, c=color, alpha=0.7, edgecolors='#006400', linewidths=0.5)
# 添加桑树标签
plt.text(mulberry_x, mulberry_y-0.5, "桑树",
fontsize=14, ha='center', color='#006400', fontweight='bold',
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 绘制槐树
locust_x, locust_y = 7, 4
locust_trunk = plt.Rectangle((locust_x-0.3, locust_y), 0.6, 2.5,
facecolor='#8B4513', edgecolor='#654321', lw=2)
ax.add_patch(locust_trunk)
# 槐树叶子 (更大的叶子)
for _ in range(50):
x = locust_x + np.random.uniform(-2, 2)
y = locust_y + 1.5 + np.random.uniform(0, 3.5)
size = np.random.uniform(30, 100)
color = np.random.choice(['#2E8B57', '#3CB371', '#2F4F4F'])
plt.scatter(x, y, s=size, c=color, alpha=0.8, edgecolors='#2F4F4F', linewidths=0.5)
# 添加槐树标签
plt.text(locust_x, locust_y-0.5, "槐树",
fontsize=14, ha='center', color='#2F4F4F', fontweight='bold',
path_effects=[path_effects.withStroke(linewidth=2, foreground='white')])
# 绘制人物
person_x, person_y = 1.5, 2
person_body = Circle((person_x, person_y), 0.5, facecolor='#FFE4C4', edgecolor='#8B4513', lw=1.5)
ax.add_patch(person_body)
# 绘制头部
head = Circle((person_x, person_y+0.7), 0.3, facecolor='#FFE4C4', edgecolor='#8B4513', lw=1.5)
ax.add_patch(head)
# 绘制眼睛
plt.plot([person_x-0.1, person_x-0.05], [person_y+0.75, person_y+0.75],
color='k', lw=1.5, solid_capstyle='round')
plt.plot([person_x+0.1, person_x+0.05], [person_y+0.75, person_y+0.75],
color='k', lw=1.5, solid_capstyle='round')
# 绘制嘴巴 (愤怒的表情)
mouth_x = [person_x-0.15, person_x, person_x+0.15]
mouth_y = [person_y+0.6, person_y+0.55, person_y+0.6]
plt.plot(mouth_x, mouth_y, color='red', lw=1.5)
# 绘制指向桑树的箭头 (实线)
arrow = plt.Arrow(person_x+0.5, person_y+0.5, 1.5, 1.5,
width=0.2, color='red', alpha=0.8)
ax.add_patch(arrow)
# 添加箭头标签
plt.text(person_x+1.5, person_y+1.8, "明指桑树",
fontsize=12, ha='center', color='red', fontweight='bold',
bbox=dict(facecolor='#fff0f5', edgecolor='pink', alpha=0.8, boxstyle='round,pad=0.3'))
# 绘制指向槐树的箭头 (虚线)
dashed_arrow = ConnectionPatch(
(mulberry_x+0.5, mulberry_y+1), (locust_x-0.5, locust_y+1.5),
"data", "data",
arrowstyle="->", shrinkA=5, shrinkB=5,
linestyle="--", linewidth=1.5, color='purple', alpha=0.7
)
ax.add_patch(dashed_arrow)
# 添加虚线箭头标签
plt.text(5, 5.5, "实骂槐树",
fontsize=12, ha='center', color='purple', fontweight='bold',
rotation=20,
bbox=dict(facecolor='#f0e6ff', edgecolor='#d8bfd8', alpha=0.8, boxstyle='round,pad=0.3'))
# 添加策略解释
explanation = "策略解析:\n\n" \
"1. 表面上指责一个对象(桑树)\n" \
"2. 实际意图是批评另一个对象(槐树)\n" \
"3. 避免直接冲突,间接表达不满\n" \
"4. 常用于政治斗争和人际关系中\n\n" \
"应用场景:\n" \
"· 批评下属时,不直接点名\n" \
"· 表达不满时,借其他事物发挥\n" \
"· 警示他人时,通过批评第三者"
plt.text(5, 2, explanation,
fontsize=12, ha='center', va='center',
bbox=dict(facecolor='#f5f5f5', edgecolor='#d3d3d3', alpha=0.9, boxstyle='round,pad=1'))
# 添加装饰元素 - 云朵
def draw_cloud(x, y, size=1.0):
cloud = plt.Circle((x, y), 0.3*size, color='white', alpha=0.8)
ax.add_patch(cloud)
cloud = plt.Circle((x+0.3*size, y), 0.4*size, color='white', alpha=0.8)
ax.add_patch(cloud)
cloud = plt.Circle((x+0.6*size, y), 0.3*size, color='white', alpha=0.8)
ax.add_patch(cloud)
cloud = plt.Circle((x+0.2*size, y+0.2*size), 0.3*size, color='white', alpha=0.8)
ax.add_patch(cloud)
cloud = plt.Circle((x+0.5*size, y+0.2*size), 0.3*size, color='white', alpha=0.8)
ax.add_patch(cloud)
# 绘制云朵
draw_cloud(1, 7)
draw_cloud(8.5, 6.5, 1.2)
draw_cloud(4, 7.5, 0.8)
# 添加装饰性小鸟
def draw_bird(x, y):
# 鸟的身体
body = Ellipse((x, y), 0.5, 0.3, angle=-20, color='#8B4513', alpha=0.8)
ax.add_patch(body)
# 翅膀
wing = Wedge((x-0.1, y), 0.3, 40, 140, color='#A0522D', alpha=0.7)
ax.add_patch(wing)
# 头部
head = Circle((x+0.2, y+0.05), 0.1, color='#8B4513')
ax.add_patch(head)
# 眼睛
eye = Circle((x+0.22, y+0.07), 0.015, color='black')
ax.add_patch(eye)
# 嘴
beak = plt.Arrow(x+0.25, y+0.05, 0.1, 0, width=0.03, color='orange')
ax.add_patch(beak)
# 绘制小鸟
draw_bird(2.5, 6.5)
draw_bird(7, 7)
plt.tight_layout()
plt.savefig('指桑骂槐.png', dpi=120, bbox_inches='tight')
plt.show()
假痴不癫
宁伪作不知不为,不伪作假知妄为。静不露机,云雷屯也。
假装糊涂,麻痹对手。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, Arc, ConnectionPatch, Ellipse
from matplotlib.collections import PatchCollection
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建图形
plt.figure(figsize=(14, 10))
ax = plt.subplot(111)
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 设置背景颜色 (淡黄色羊皮纸风格)
ax.set_facecolor('#fdf5e6')
# 标题
plt.title('假痴不癫策略示意图',
fontsize=24, fontweight='bold',
color='#8B4513', pad=25)
# 添加副标题
plt.figtext(0.5, 0.87,
"表面装疯卖傻,实则韬光养晦\n大智若愚,伺机而动",
ha="center", fontsize=18, color='#556B2F',
bbox=dict(facecolor='#f5f5dc', alpha=0.7, edgecolor='#d2b48c', boxstyle='round,pad=0.8'))
# 绘制左侧人物 (假装疯癫)
def draw_crazy_person(x, y):
# 身体
body = Circle((x, y), 1.0, facecolor='#87CEEB', edgecolor='#4682B4', lw=2, alpha=0.8)
ax.add_patch(body)
# 头部
head = Circle((x, y + 1.5), 0.7, facecolor='#FFE4C4', edgecolor='#8B4513', lw=1.5)
ax.add_patch(head)
# 眼睛 (眯眼)
eye_left = Arc((x - 0.3, y + 1.6), 0.4, 0.3, angle=0, theta1=0, theta2=180,
color='black', lw=1.5)
eye_right = Arc((x + 0.3, y + 1.6), 0.4, 0.3, angle=0, theta1=0, theta2=180,
color='black', lw=1.5)
ax.add_patch(eye_left)
ax.add_patch(eye_right)
# 嘴巴 (傻笑)
mouth = Arc((x, y + 1.3), 0.8, 0.5, angle=0, theta1=180, theta2=360,
color='red', lw=1.5)
ax.add_patch(mouth)
# 头发 (乱糟糟)
for i in range(8):
angle = np.random.uniform(0, 360)
length = np.random.uniform(0.3, 0.8)
dx = length * np.cos(np.radians(angle))
dy = length * np.sin(np.radians(angle))
plt.plot([x, x + dx], [y + 1.5 + 0.7, y + 1.5 + 0.7 + dy],
color='#8B4513', lw=np.random.uniform(1.0, 2.0))
# 衣服补丁
patches = [
Polygon(np.array([[x - 0.5, y - 0.5], [x - 0.7, y - 0.8], [x - 0.3, y - 0.9]]),
facecolor='#FF6347', alpha=0.7),
Polygon(np.array([[x + 0.4, y + 0.2], [x + 0.6, y + 0.1], [x + 0.5, y + 0.4]]),
facecolor='#32CD32', alpha=0.7),
Polygon(np.array([[x, y - 0.8], [x - 0.2, y - 1.2], [x + 0.2, y - 1.1]]),
facecolor='#9370DB', alpha=0.7)
]
ax.add_collection(PatchCollection(patches, match_original=True))
# 手中的玩具风车
plt.plot([x + 0.5, x + 1.5], [y + 0.5, y + 1.5], color='#D2691E', lw=1.5)
windmill = Polygon(np.array([
[x + 1.5, y + 1.5],
[x + 1.5 + 0.5, y + 1.5],
[x + 1.5 + 0.5, y + 1.5 + 0.5],
[x + 1.5, y + 1.5 + 0.5]
]), facecolor='#FFD700', alpha=0.8)
ax.add_patch(windmill)
# 脚 (不同方向)
foot_left = Rectangle((x - 0.4, y - 1.5), 0.4, 0.3, angle=30,
facecolor='#000080', alpha=0.7)
foot_right = Rectangle((x + 0.3, y - 1.6), 0.4, 0.3, angle=-20,
facecolor='#000080', alpha=0.7)
ax.add_patch(foot_left)
ax.add_patch(foot_right)
# 标签
plt.text(x, y - 2.2, "表面:疯癫痴傻",
fontsize=14, ha='center', color='#4169E1', fontweight='bold',
bbox=dict(facecolor='#f0f8ff', edgecolor='#87CEEB', alpha=0.8, boxstyle='round,pad=0.3'))
# 绘制右侧人物 (真实状态)
def draw_real_person(x, y):
# 身体 (隐藏在暗处)
body = Circle((x, y), 1.0, facecolor='#2E8B57', edgecolor='#006400', lw=2, alpha=0.9)
ax.add_patch(body)
# 头部
head = Circle((x, y + 1.5), 0.7, facecolor='#FFE4C4', edgecolor='#8B4513', lw=1.5)
ax.add_patch(head)
# 眼睛 (锐利)
plt.plot([x - 0.3, x - 0.1], [y + 1.6, y + 1.6], color='black', lw=2, solid_capstyle='round')
plt.plot([x + 0.3, x + 0.1], [y + 1.6, y + 1.6], color='black', lw=2, solid_capstyle='round')
# 嘴巴 (坚毅)
plt.plot([x - 0.3, x + 0.3], [y + 1.3, y + 1.3], color='black', lw=2, solid_capstyle='round')
# 头发 (整齐)
hair = Rectangle((x - 0.7, y + 1.5 + 0.7), 1.4, 0.3, angle=0,
facecolor='#8B4513', edgecolor='#654321')
ax.add_patch(hair)
# 智慧之光
for i in range(12):
angle = i * 30
length = 1.2
dx = length * np.cos(np.radians(angle))
dy = length * np.sin(np.radians(angle))
plt.plot([x, x + dx], [y + 1.5, y + 1.5 + dy],
color='gold', lw=1.5, alpha=0.6)
# 手中的剑
plt.plot([x - 0.5, x - 1.5], [y, y - 1.5], color='#C0C0C0', lw=3)
sword_tip = Polygon(np.array([
[x - 1.5, y - 1.5],
[x - 1.7, y - 1.8],
[x - 1.3, y - 1.8]
]), facecolor='#C0C0C0')
ax.add_patch(sword_tip)
# 背后的阴影
shadow = Ellipse((x, y), 3.5, 2.0, angle=0,
facecolor='black', alpha=0.2)
ax.add_patch(shadow)
# 标签
plt.text(x, y - 2.2, "实质:深谋远虑",
fontsize=14, ha='center', color='#006400', fontweight='bold',
bbox=dict(facecolor='#f0fff0', edgecolor='#98FB98', alpha=0.8, boxstyle='round,pad=0.3'))
# 绘制假痴不癫的人物
draw_crazy_person(3.5, 4)
draw_real_person(10.5, 4)
# 添加策略说明箭头
arrow1 = ConnectionPatch(
(4.5, 4), (8, 5.5),
"data", "data",
arrowstyle="->", shrinkA=5, shrinkB=5,
linestyle="-", linewidth=2, color='#8A2BE2', alpha=0.8,
connectionstyle="arc3,rad=0.2"
)
ax.add_patch(arrow1)
plt.text(6.5, 6.2, "迷惑敌人",
fontsize=14, ha='center', color='#8A2BE2', fontweight='bold',
bbox=dict(facecolor='#f0e6ff', edgecolor='#d8bfd8', alpha=0.8))
arrow2 = ConnectionPatch(
(4.5, 3.5), (8, 2.5),
"data", "data",
arrowstyle="->", shrinkA=5, shrinkB=5,
linestyle="-", linewidth=2, color='#8A2BE2', alpha=0.8,
connectionstyle="arc3,rad=-0.2"
)
ax.add_patch(arrow2)
plt.text(6.5, 2.2, "隐藏实力",
fontsize=14, ha='center', color='#8A2BE2', fontweight='bold',
bbox=dict(facecolor='#f0e6ff', edgecolor='#d8bfd8', alpha=0.8))
# 添加时间箭头
time_arrow = plt.Arrow(7, 4.5, 3.5, 0, width=0.3, color='#FF4500', alpha=0.8)
ax.add_patch(time_arrow)
plt.text(8.5, 5.0, "等待时机",
fontsize=14, ha='center', color='#FF4500', fontweight='bold',
rotation=0,
bbox=dict(facecolor='#fff0f5', edgecolor='#FFB6C1', alpha=0.8))
# 添加策略解释
explanation = "策略解析:\n\n" \
"1. 表面装疯卖傻,迷惑敌人\n" \
"2. 暗中积蓄力量,隐藏真实意图\n" \
"3. 等待最佳时机,一举制胜\n" \
"4. 避免过早暴露,减少对抗压力\n\n" \
"历史案例:\n" \
"· 司马懿装病骗曹爽\n" \
"· 孙膑装疯脱险\n" \
"· 朱棣装疯起兵"
plt.text(7, 7.5, explanation,
fontsize=16, ha='center', va='center',
bbox=dict(facecolor='#faf0e6', edgecolor='#d2b48c', alpha=0.9,
boxstyle='round,pad=1.0'))
# 添加中心思想
center_thought = "大智若愚\n大巧若拙"
plt.text(8.2, 1.5, center_thought,
fontsize=22, ha='center', va='center', color='#8B4513', fontweight='bold',
bbox=dict(facecolor='#fffacd', edgecolor='#eee8aa', alpha=0.9, boxstyle='round,pad=1.0'))
# 添加三十六计标识
plt.text(13.5, 0.8, "三十六计 · 第二十七计",
fontsize=14, ha='right', color='#8B4513', fontstyle='italic')
# 添加装饰元素 - 云朵
def draw_cloud(x, y, size=1.0):
cloud = plt.Circle((x, y), 0.4 * size, color='white', alpha=0.9)
ax.add_patch(cloud)
cloud = plt.Circle((x + 0.4 * size, y), 0.5 * size, color='white', alpha=0.9)
ax.add_patch(cloud)
cloud = plt.Circle((x + 0.8 * size, y), 0.4 * size, color='white', alpha=0.9)
ax.add_patch(cloud)
cloud = plt.Circle((x + 0.2 * size, y + 0.2 * size), 0.4 * size, color='white', alpha=0.9)
ax.add_patch(cloud)
cloud = plt.Circle((x + 0.6 * size, y + 0.2 * size), 0.4 * size, color='white', alpha=0.9)
ax.add_patch(cloud)
# 绘制云朵
draw_cloud(1, 8.5, 1.5)
draw_cloud(12, 9, 1.2)
draw_cloud(5, 9.2, 1.0)
# 添加装饰性卷轴
scroll = Rectangle((6.5, 8.5), 1.5, 0.2, facecolor='#f5f5dc', edgecolor='#d2b48c', lw=2)
ax.add_patch(scroll)
scroll_top = Arc((7.25, 8.6), 1.5, 0.4, angle=0, theta1=0, theta2=180,
edgecolor='#d2b48c', lw=2, facecolor='none')
ax.add_patch(scroll_top)
plt.text(7.25, 8.5, "兵法智慧", fontsize=12, ha='center', color='#8B4513')
# 添加装饰性印章
seal = Rectangle((12.8, 1.2), 0.8, 0.8, facecolor='#8B0000', alpha=0.7)
ax.add_patch(seal)
plt.text(13.2, 1.6, "计", fontsize=16, ha='center', color='white', fontweight='bold')
plt.text(13.2, 1.3, "假痴不癫", fontsize=8, ha='center', color='white')
plt.tight_layout()
plt.savefig('假痴不癫.png', dpi=120, bbox_inches='tight')
plt.show()
上屋抽梯
假之以便,唆之使前,断其援应,陷之死地。
诱敌深入后断其退路。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon, Rectangle, Circle
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建图形和坐标轴
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 设置背景颜色
fig.patch.set_facecolor('#f0f8ff')
ax.set_facecolor('#f0f8ff')
# 绘制地面
ground = Rectangle((0, 0), 10, 1.5, color='#8B4513', alpha=0.8)
ax.add_patch(ground)
# 绘制高台(上屋)
house_height = 5
house_width = 4
house_x = 3
house_y = 1.5
# 高台主体
house = Rectangle((house_x, house_y), house_width, house_height,
color='#CD853F', alpha=0.9, ec='#8B4513', lw=2)
ax.add_patch(house)
# 绘制高台顶部
roof_points = [(house_x, house_y + house_height),
(house_x + house_width / 2, house_y + house_height + 1.5),
(house_x + house_width, house_y + house_height)]
roof = Polygon(roof_points, closed=True, color='#A52A2A', alpha=0.8)
ax.add_patch(roof)
# 绘制梯子
def draw_ladder(x, y, width, height, rungs=8, color='#8B4513', alpha=1.0):
# 梯子两侧
ax.plot([x, x], [y, y + height], color=color, lw=3, alpha=alpha)
ax.plot([x + width, x + width], [y, y + height], color=color, lw=3, alpha=alpha)
# 梯子横档
for i in range(rungs):
y_pos = y + (i + 0.5) * height / rungs
ax.plot([x, x + width], [y_pos, y_pos], color=color, lw=2, alpha=alpha)
# 绘制梯子(被抽走前)
draw_ladder(house_x + house_width - 0.5, house_y, 0.3, house_height)
# 绘制被抽走的梯子(虚线表示)
ax.plot([house_x + house_width + 0.5, house_x + house_width + 0.5],
[house_y, house_y + house_height],
color='red', lw=2, linestyle='--', alpha=0.7)
ax.plot([house_x + house_width + 0.8, house_x + house_width + 0.8],
[house_y, house_y + house_height],
color='red', lw=2, linestyle='--', alpha=0.7)
for i in range(8):
y_pos = house_y + (i + 0.5) * house_height / 8
ax.plot([house_x + house_width + 0.5, house_x + house_width + 0.8],
[y_pos, y_pos], color='red', lw=1.5, linestyle='--', alpha=0.7)
# 绘制梯子被移除的箭头
ax.arrow(house_x + house_width - 0.3, house_y + house_height / 2,
1.2, 0,
head_width=0.3, head_length=0.3,
fc='red', ec='red', alpha=0.8, width=0.05)
# 绘制士兵(被困在高台上)
def draw_soldier(x, y, size=0.3, color='blue'):
# 身体
body = Circle((x, y + size * 0.8), size * 0.4, color=color, alpha=0.8)
ax.add_patch(body)
# 头
head = Circle((x, y + size * 1.6), size * 0.3, color='#FFEBCD', ec='black', lw=0.5)
ax.add_patch(head)
# 手臂
ax.plot([x, x - size * 0.6], [y + size * 0.8, y + size * 1.1], color=color, lw=2, alpha=0.8)
ax.plot([x, x + size * 0.6], [y + size * 0.8, y + size * 1.1], color=color, lw=2, alpha=0.8)
# 腿
ax.plot([x, x - size * 0.3], [y + size * 0.4, y - size * 0.2], color=color, lw=2, alpha=0.8)
ax.plot([x, x + size * 0.3], [y + size * 0.4, y - size * 0.2], color=color, lw=2, alpha=0.8)
# 绘制我方士兵
draw_soldier(house_x + house_width / 2, house_y + house_height - 0.5, color='green')
draw_soldier(house_x + house_width / 2 - 1, house_y + house_height - 0.5, color='green')
# 绘制敌方士兵(被困)
draw_soldier(house_x + house_width / 2 + 0.8, house_y + house_height - 1.5, color='red')
draw_soldier(house_x + house_width / 2 - 0.8, house_y + house_height - 1.5, color='red')
# 绘制敌方士兵的困惑表情
ax.plot(house_x + house_width / 2 + 0.8, house_y + house_height - 1.5 + 0.3 * 1.6,
marker='o', markersize=3, color='black')
ax.plot(house_x + house_width / 2 + 0.8 - 0.07, house_y + house_height - 1.5 + 0.3 * 1.6 - 0.05,
marker='o', markersize=1.5, color='white')
ax.plot(house_x + house_width / 2 + 0.8 + 0.07, house_y + house_height - 1.5 + 0.3 * 1.6 - 0.05,
marker='o', markersize=1.5, color='white')
ax.plot([house_x + house_width / 2 + 0.8 - 0.1, house_x + house_width / 2 + 0.8 + 0.1],
[house_y + house_height - 1.5 + 0.3 * 1.6 - 0.15, house_y + house_height - 1.5 + 0.3 * 1.6 - 0.15],
color='black', lw=1.5)
# 绘制策略名称
text = ax.text(5, 7.2, '上屋抽梯策略示意图', fontsize=40, ha='center',
fontname='SimHei', color='#8B0000')
text.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#FFD700')])
# 绘制策略解释
explanation = "策略说明:引诱敌人登上高处,然后撤走梯子,切断其退路,使其陷入绝境。"
ax.text(5, 0.7, explanation, fontsize=14, ha='center',
fontname='SimHei', color='#2F4F4F')
# 添加装饰元素 - 云朵
def draw_cloud(x, y, size=1.0):
cloud = Circle((x, y), size * 0.7, color='white', alpha=0.9)
ax.add_patch(cloud)
cloud2 = Circle((x + size * 0.5, y + size * 0.3), size * 0.6, color='white', alpha=0.9)
ax.add_patch(cloud2)
cloud3 = Circle((x + size * 0.9, y), size * 0.5, color='white', alpha=0.9)
ax.add_patch(cloud3)
cloud4 = Circle((x + size * 0.5, y - size * 0.3), size * 0.6, color='white', alpha=0.9)
ax.add_patch(cloud4)
draw_cloud(1.5, 6.5, 0.8)
draw_cloud(8.5, 6.8, 1.0)
# 添加装饰元素 - 树木
def draw_tree(x, y, size=1.0):
trunk = Rectangle((x - 0.1 * size, y), 0.2 * size, 0.8 * size, color='#8B4513')
ax.add_patch(trunk)
leaves = Circle((x, y + 1.2 * size), 0.5 * size, color='#2E8B57')
ax.add_patch(leaves)
leaves2 = Circle((x + 0.3 * size, y + 0.9 * size), 0.4 * size, color='#3CB371')
ax.add_patch(leaves2)
leaves3 = Circle((x - 0.3 * size, y + 0.9 * size), 0.4 * size, color='#3CB371')
ax.add_patch(leaves3)
draw_tree(1.0, 1.5)
draw_tree(8.8, 1.5)
draw_tree(0.5, 1.5, 0.8)
# 添加装饰元素 - 旗帜
flag_pole = Rectangle((house_x - 1.5, house_y + 0.5), 0.05, 1.5, color='#8B4513')
ax.add_patch(flag_pole)
flag = Polygon(np.array([(house_x - 1.5, house_y + 2),
(house_x - 1.5, house_y + 1.8),
(house_x - 1.0, house_y + 1.9)]),
color='#B22222')
ax.add_patch(flag)
ax.text(house_x - 1.34, house_y + 1.90, '兵', fontsize=10,
fontname='SimHei', color='white', ha='center', va='center')
# 绘制太阳
sun = Circle((8.5, 6.5), 0.6, color='#FFD700')
ax.add_patch(sun)
for i in range(8):
angle = i * np.pi / 4
ax.plot([8.5 + 0.6 * np.cos(angle), 8.5 + 1.0 * np.cos(angle)],
[6.5 + 0.6 * np.sin(angle), 6.5 + 1.0 * np.sin(angle)],
color='#FFD700', lw=1.5, alpha=0.8)
# 添加装饰文字
ax.text(0.5, 7.5, '诱敌登高', fontsize=14, fontname='SimHei', color='#006400')
ax.text(8.5, 4.5, '抽梯断后', fontsize=14, fontname='SimHei', color='#8B0000')
# 添加箭头标注
ax.annotate('诱敌路线', xy=(5, house_y + 1), xytext=(6, 2.5),
arrowprops=dict(arrowstyle='->', color='#006400', lw=1.5),
fontsize=12, fontname='SimHei', color='#006400')
ax.annotate('抽走梯子', xy=(house_x + house_width + 0.65, house_y + house_height / 2),
xytext=(7.5, 5),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=1.5),
fontsize=12, fontname='SimHei', color='#8B0000')
plt.tight_layout()
plt.savefig('上屋抽梯.png', dpi=300, bbox_inches='tight')
plt.show()
树上开花
借局布势,力小势大。鸿渐于陆,其羽可用为仪也。
借势造势,虚张声势。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Polygon, Circle
import random
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(12, 10), facecolor='#f0f8ff')
ax.set_aspect('equal')
ax.set_xlim(-10, 10)
ax.set_ylim(-2, 15)
ax.axis('off')
# 添加标题
plt.title('树上开花策略示意图', fontsize=24, fontweight='bold', color='#8B4513', pad=20)
# 添加说明文字
description = "树上开花:树上本无花,但可借假花点缀,制造繁荣假象。\n此计比喻借助某种因素制造假象来壮大自己的声势。"
plt.figtext(0.5, 0.05, description, ha='center', fontsize=14, color='#2F4F4F',
bbox=dict(boxstyle='round', facecolor='#FFFACD', alpha=0.8))
# 绘制树干
trunk_points = np.array([
[-1.5, -2], [1.5, -2], [1.2, 0], [0.8, 2], [0.6, 4],
[0.4, 6], [0.3, 8], [0.2, 10], [-0.2, 10], [-0.3, 8],
[-0.4, 6], [-0.6, 4], [-0.8, 2], [-1.2, 0], [-1.5, -2]
])
trunk = Polygon(trunk_points, closed=True, color='#8B4513')
ax.add_patch(trunk)
# 绘制树冠
def create_tree_crown(x, y, size, color):
points = []
for angle in np.linspace(0, 2 * np.pi, 8):
variation = size * (0.8 + random.random() * 0.4)
px = x + variation * np.cos(angle)
py = y + variation * np.sin(angle)
points.append([px, py])
crown = Polygon(points, closed=True, color=color, alpha=0.7)
ax.add_patch(crown)
return crown
# 添加多层树冠
crown_colors = ['#3CB371', '#2E8B57', '#228B22', '#006400']
crowns = []
for i, (y, size) in enumerate(zip([5, 7, 9, 11], [3.0, 2.5, 2.0, 1.5])):
crown = create_tree_crown(0, y, size, crown_colors[i])
crowns.append(crown)
# 添加假花
def create_flower(x, y, size=0.3):
# 花蕊
center = Circle((x, y), size * 0.3, color='#FFD700')
ax.add_patch(center)
# 花瓣
petal_colors = random.sample(['#FF69B4', '#FF1493', '#FF6347', '#FF4500', '#FF0000'], 5)
for i in range(5):
angle = i * 2 * np.pi / 5
px = x + size * np.cos(angle)
py = y + size * np.sin(angle)
petal = Circle((px, py), size * 0.6, color=petal_colors[i], alpha=0.9)
ax.add_patch(petal)
# 在树上添加假花
for _ in range(80):
# 在树冠区域内随机生成花朵位置
crown_idx = random.randint(0, len(crowns) - 1)
crown = crowns[crown_idx]
# 在树冠边界框内随机生成点
xmin, ymin = np.min(crown.get_xy(), axis=0)
xmax, ymax = np.max(crown.get_xy(), axis=0)
x = random.uniform(xmin, xmax)
y = random.uniform(ymin, ymax)
# 如果点在树冠内,则添加花朵
if crown.get_path().contains_point((x, y)):
size = random.uniform(0.2, 0.4)
create_flower(x, y, size)
# 添加地面
ground = plt.Rectangle((-10, -2), 20, 2, color='#DEB887')
ax.add_patch(ground)
# 添加草地纹理
for _ in range(200):
x = random.uniform(-10, 10)
y = random.uniform(-2, 0)
height = random.uniform(0.1, 0.3)
grass = plt.Line2D([x, x], [y, y + height], color='#2E8B57', linewidth=random.uniform(0.5, 1.5))
ax.add_line(grass)
# 添加飘落的花瓣
for _ in range(30):
x = random.uniform(-8, 8)
y = random.uniform(-1, 5)
size = random.uniform(0.1, 0.2)
petal = Circle((x, y), size, color=random.choice(['#FF69B4', '#FF1493', '#FF6347']), alpha=0.7)
ax.add_patch(petal)
# 添加策略解释
plt.text(7, 10, "策略要点:", fontsize=14, fontweight='bold', color='#8B0000')
strategies = [
"1. 制造虚假繁荣",
"2. 虚张声势",
"3. 迷惑对手",
"4. 借势造势",
"5. 以假乱真"
]
for i, s in enumerate(strategies):
plt.text(7, 9 - i * 0.8, s, fontsize=12, color='#8B0000')
# 添加装饰元素 - 太阳
sun = Circle((8, 13), 1.5, color='#FFD700', alpha=0.8)
ax.add_patch(sun)
for i in range(8):
angle = i * np.pi / 4
dx = 2.0 * np.cos(angle)
dy = 2.0 * np.sin(angle)
ray = plt.Line2D([8 + 1.5 * np.cos(angle), 8 + dx], [13 + 1.5 * np.sin(angle), 13 + dy],
color='#FFA500', linewidth=2, alpha=0.6)
ax.add_line(ray)
# 添加装饰元素 - 云朵
def create_cloud(x, y, size):
for i in range(5):
dx = random.uniform(-0.5, 0.5)
dy = random.uniform(-0.3, 0.3)
r = size * (0.7 + random.random() * 0.3)
cloud_part = Circle((x + dx, y + dy), r, color='white', alpha=0.9)
ax.add_patch(cloud_part)
create_cloud(-5, 12, 0.8)
create_cloud(4, 14, 0.7)
# 添加装饰元素 - 蝴蝶
def create_butterfly(x, y, size=0.5):
# 身体
body = plt.Line2D([x, x], [y - 0.1 * size, y + 0.1 * size],
color='#8B4513', linewidth=size * 0.8)
ax.add_line(body)
# 翅膀
wing_colors = random.sample(['#FF69B4', '#9370DB', '#FF6347', '#20B2AA'], 2)
angles = [np.pi / 4, 3 * np.pi / 4, 5 * np.pi / 4, 7 * np.pi / 4]
for i, angle in enumerate(angles):
wing_size = size * (0.8 if i < 2 else 0.6)
dx = wing_size * np.cos(angle)
dy = wing_size * np.sin(angle)
wing = Polygon(np.array([
[x, y],
[x + dx, y + dy],
[x + dx * 0.7, y + dy * 1.2]
]), color=wing_colors[i // 2], alpha=0.7)
ax.add_patch(wing)
create_butterfly(2, 6)
create_butterfly(-3, 8)
create_butterfly(5, 4)
plt.tight_layout()
plt.savefig('树上开花.png', dpi=120, bbox_inches='tight')
plt.show()
反客为主
乘隙插足,扼其主机,渐之进也。
被动变主动,逐步掌控局面。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Ellipse
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 设置画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
# 设置背景颜色
ax.set_facecolor('#F5F5DC')
# 添加标题
title = plt.text(7, 9.5, '反客为主策略示意图',
fontsize=28, fontweight='bold',
ha='center', color='#8B0000')
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='gold')])
# 添加副标题
subtitle = plt.text(7, 8.8, '从被动到主动,逐步掌控局面',
fontsize=18, ha='center',
style='italic', color='#2F4F4F')
# 添加策略说明
explanation = "策略解析:\n1. 初始处于被动地位(客)\n2. 逐步渗透积累力量\n3. 抓住时机夺取主动权\n4. 最终掌控局面(主)"
plt.text(10.5, 2.5, explanation, fontsize=14,
bbox=dict(boxstyle="round,pad=0.5",
facecolor='#FFF8DC',
edgecolor='#8B4513',
alpha=0.9))
# 绘制棋盘 - 代表策略博弈
def draw_chessboard(x, y, size):
for i in range(8):
for j in range(8):
color = '#F0D9B5' if (i + j) % 2 == 0 else '#B58863'
rect = Rectangle((x + j * size, y + i * size), size, size,
facecolor=color, edgecolor='#7D5A3B')
ax.add_patch(rect)
# 添加装饰性棋子
for pos in [(2, 2), (5, 3), (3, 5), (6, 6)]:
cx = x + pos[0] * size + size / 2
cy = y + pos[1] * size + size / 2
piece = Circle((cx, cy), size * 0.4,
facecolor='#8B0000', edgecolor='black')
ax.add_patch(piece)
# 添加特殊棋子(主控方)
cx = x + 7 * size + size / 2
cy = y + 7 * size + size / 2
piece = Circle((cx, cy), size * 0.45,
facecolor='gold', edgecolor='#8B4513', linewidth=2)
ax.add_patch(piece)
# 添加特殊棋子(被控制方)
cx = x + 1 * size + size / 2
cy = y + 1 * size + size / 2
piece = Circle((cx, cy), size * 0.35,
facecolor='#A9A9A9', edgecolor='black')
ax.add_patch(piece)
# 在左侧绘制棋盘
draw_chessboard(0.5, 1, 0.6)
# 绘制策略演变过程
def draw_strategy_step(x, y, step, title, color):
# 绘制外框
rect = Rectangle((x - 0.5, y - 0.5), 3, 3,
facecolor='#FFF8DC',
edgecolor=color, linewidth=2,
alpha=0.9)
ax.add_patch(rect)
# 绘制步骤编号
plt.text(x + 1, y + 2.7, f"步骤 {step}",
fontsize=14, ha='center',
color='white', weight='bold',
bbox=dict(boxstyle="circle", facecolor=color))
# 绘制标题
plt.text(x + 1, y - 0.8, title,
fontsize=14, ha='center',
color=color, weight='bold')
# 根据步骤绘制不同内容
if step == 1:
# 被动地位
circle = Circle((x + 1, y + 1), 0.8, facecolor='#A9A9A9', edgecolor='black')
ax.add_patch(circle)
arrow = plt.Arrow(x + 2.5, y + 1, 0.8, 0, width=0.2, color='#FF6347')
ax.add_patch(arrow)
elif step == 2:
# 逐步渗透
for i, angle in enumerate(np.linspace(0, 2 * np.pi, 6, endpoint=False)):
px = x + 1 + 0.8 * np.cos(angle)
py = y + 1 + 0.8 * np.sin(angle)
small = Circle((px, py), 0.3, facecolor='#4682B4', alpha=0.7)
ax.add_patch(small)
# 指向中心的箭头
arrow = plt.Arrow(px, py, (x + 1 - px) * 0.6, (y + 1 - py) * 0.6,
width=0.1, color='#2E8B57', alpha=0.7)
ax.add_patch(arrow)
elif step == 3:
# 夺取主动权
center = Circle((x + 1, y + 1), 0.8, facecolor='gold', edgecolor='#8B4513', linewidth=1.5)
ax.add_patch(center)
# 向外辐射的箭头
for angle in np.linspace(0, 2 * np.pi, 8, endpoint=False):
dx = 1.2 * np.cos(angle)
dy = 1.2 * np.sin(angle)
arrow = plt.Arrow(x + 1, y + 1, dx, dy,
width=0.15, color='#8B0000')
ax.add_patch(arrow)
elif step == 4:
# 掌控局面
center = Circle((x + 1, y + 1), 0.8, facecolor='#8B0000', edgecolor='gold', linewidth=2)
ax.add_patch(center)
# 控制线
for i in range(4):
angle = i * np.pi / 2
px = x + 1 + 1.8 * np.cos(angle)
py = y + 1 + 1.8 * np.sin(angle)
plt.plot([x + 1, px], [y + 1, py], 'gold', linewidth=2, linestyle='--')
# 控制点
point = Circle((px, py), 0.2, facecolor='gold', edgecolor='#8B0000')
ax.add_patch(point)
# 绘制四个策略步骤
steps = [
(3.5, 5, 1, "被动地位", '#1E90FF'),
(6.5, 5, 2, "逐步渗透", '#2E8B57'),
(9.5, 5, 3, "夺取主动", '#FF8C00'),
(12.5, 5, 4, "掌控局面", '#8B0000')
]
for x, y, step, title, color in steps:
draw_strategy_step(x, y, step, title, color)
# 添加连接箭头
for i in range(3):
x1 = steps[i][0] + 2.5
y1 = steps[i][1] + 0.5
x2 = steps[i + 1][0] - 0.5
y2 = steps[i + 1][1] + 0.5
plt.annotate("", xy=(x2, y2), xytext=(x1, y1),
arrowprops=dict(arrowstyle="->",
color="#4B0082",
linewidth=2,
linestyle='-',
connectionstyle="arc3,rad=0.2"))
# 添加策略核心思想
core_idea = "策略精髓:\n\n以静制动 · 循序渐进\n\n借力打力 · 扭转乾坤"
plt.text(1.5, 4, core_idea, fontsize=16,
ha='center', va='center',
color='#8B4513',
bbox=dict(boxstyle="round",
facecolor='#FFFACD',
edgecolor='#DAA520',
alpha=0.9))
# 添加装饰元素 - 印章
seal = Ellipse((2, 7.5), 1.5, 1.0,
facecolor='#CD5C5C',
alpha=0.8)
ax.add_patch(seal)
plt.text(2, 7.5, "智", fontsize=24,
ha='center', va='center',
color='white', weight='bold')
# 添加装饰元素 - 卷轴
scroll = Rectangle((0.5, 7.8), 3, 0.5,
facecolor='#F5DEB3',
edgecolor='#8B4513')
ax.add_patch(scroll)
plt.text(2, 8.05, "三十六计·反客为主",
fontsize=12, ha='center',
color='#8B4513')
# 添加装饰元素 - 竹简
for i in range(8):
bamboo = Rectangle((0.2, 7.0 - i * 0.15), 3.6, 0.1,
facecolor='#DEB887',
edgecolor='#8B4513')
ax.add_patch(bamboo)
if i % 2 == 0:
plt.text(0.5, 7.0 - i * 0.15, "谋略之道", fontsize=8, color='#8B4513')
plt.text(3.0, 7.0 - i * 0.15, "变客为主", fontsize=8, color='#8B4513')
# 添加装饰元素 - 中国结
def draw_chinese_knot(x, y, size):
# 外框
rect = Rectangle((x, y), size, size,
facecolor='none',
edgecolor='#B22222',
linewidth=2)
ax.add_patch(rect)
# 内部装饰
circle = Circle((x + size / 2, y + size / 2), size / 4,
facecolor='none',
edgecolor='#B22222',
linewidth=2)
ax.add_patch(circle)
# 交叉线
plt.plot([x, x + size], [y, y + size], '#B22222', linewidth=1.5)
plt.plot([x, x + size], [y + size, y], '#B22222', linewidth=1.5)
# 穗子
for i in range(5):
plt.plot([x + size / 2, x + size / 2], [y, y - 0.5 - i * 0.1], '#B22222', linewidth=1)
for j in range(3):
angle = np.pi / 4 + j * np.pi / 6
length = 0.2
plt.plot([x + size / 2, x + size / 2 + length * np.cos(angle)],
[y - 0.5 - i * 0.1, y - 0.5 - i * 0.1 + length * np.sin(angle)],
'#B22222', linewidth=1)
# 在右上角添加中国结
draw_chinese_knot(12, 8, 1.2)
# 添加引用
quote = plt.text(7, 1.5, '"善战者,致人而不致于人" — 《孙子兵法》',
fontsize=16, ha='center',
style='italic', color='#556B2F',
bbox=dict(boxstyle="round", facecolor='#F0FFF0', alpha=0.7))
plt.tight_layout()
plt.savefig('反客为主.png', dpi=120, bbox_inches='tight')
plt.show()
败战计(劣势下的生存策略)
美人计
兵强者,攻其将;将智者,伐其情。将弱兵颓,其势自萎。
利用美色或诱惑瓦解敌方意志。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon, Ellipse, PathPatch
from matplotlib.path import Path
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
# 设置背景颜色 - 使用渐变色
ax.set_facecolor('#FFF0F5')
x = np.linspace(0, 14, 100)
y = np.linspace(0, 10, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(X / 2) * np.cos(Y / 2)
ax.imshow(Z, extent=[0, 14, 0, 10], cmap='Blues', alpha=0.05, aspect='auto')
# 添加标题
title = plt.text(7, 9.5, '美⼈计策略示意图',
fontsize=28, fontweight='bold',
ha='center', color='#8B0000')
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='#FFC0CB')])
# 添加副标题
plt.text(7, 8.8, '以美色为武器,惑敌心智,乱敌谋略',
fontsize=18, ha='center',
style='italic', color='#8B008B')
# 绘制屏风背景
def draw_screen(x, y, width, height, color='#FFF8DC', pattern=True):
# 屏风主体
screen = Rectangle((x, y), width, height,
facecolor=color, edgecolor='#8B4513',
linewidth=3, alpha=0.9)
ax.add_patch(screen)
# 屏风图案
if pattern:
# 梅花
for _ in range(12):
px = x + np.random.uniform(0.2, width - 0.2)
py = y + np.random.uniform(0.2, height - 0.2)
size = np.random.uniform(0.1, 0.3)
flower = Circle((px, py), size,
facecolor='#FF69B4', alpha=0.4)
ax.add_patch(flower)
# 竹子
for _ in range(6):
px = x + np.random.uniform(0.2, width - 0.2)
py = y + np.random.uniform(0.2, height - 0.2)
height_bamboo = np.random.uniform(0.5, 1.5)
plt.plot([px, px], [py, py + height_bamboo],
color='#2E8B57', linewidth=2)
# 竹节
for i in range(3):
plt.plot([px - 0.1, px + 0.1], [py + (i + 0.5) * height_bamboo / 3, py + (i + 0.5) * height_bamboo / 3],
color='#8B4513', linewidth=3)
return screen
# 绘制左侧屏风(我方)
left_screen = draw_screen(0.5, 1, 4, 7, '#FFF0F5', True)
# 绘制右侧屏风(敌方)
right_screen = draw_screen(9.5, 1, 4, 7, '#F5F5F5', True)
# 绘制美人
def draw_beauty(x, y, size=1.0):
# 头部
head = Ellipse((x, y + 0.3 * size), 0.5 * size, 0.6 * size,
facecolor='#FFE4E1', edgecolor='#FFC0CB',
linewidth=2)
ax.add_patch(head)
# 身体
body = Ellipse((x, y - 0.4 * size), 0.6 * size, 1.0 * size,
facecolor='#FF69B4', edgecolor='#8B0000',
linewidth=1, alpha=0.8)
ax.add_patch(body)
# 头发
hair = PathPatch(
Path([(x - 0.3 * size, y + 0.2 * size), (x - 0.4 * size, y + 0.4 * size),
(x - 0.2 * size, y + 0.5 * size), (x, y + 0.55 * size),
(x + 0.2 * size, y + 0.5 * size), (x + 0.4 * size, y + 0.4 * size),
(x + 0.3 * size, y + 0.2 * size), (x - 0.3 * size, y + 0.2 * size)],
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4,
Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.CLOSEPOLY]),
facecolor='#8B4513', edgecolor='#4B0082', lw=1, alpha=0.9
)
ax.add_patch(hair)
# 面部特征
# 眼睛
eye_left = Ellipse((x - 0.15 * size, y + 0.35 * size), 0.08 * size, 0.05 * size,
facecolor='black')
eye_right = Ellipse((x + 0.15 * size, y + 0.35 * size), 0.08 * size, 0.05 * size,
facecolor='black')
ax.add_patch(eye_left)
ax.add_patch(eye_right)
# 嘴巴
mouth = PathPatch(
Path([(x - 0.1 * size, y + 0.2 * size), (x, y + 0.15 * size), (x + 0.1 * size, y + 0.2 * size)],
[Path.MOVETO, Path.CURVE3, Path.CURVE3]),
fill=False, edgecolor='#8B0000', lw=1.5
)
ax.add_patch(mouth)
# 装饰 - 花朵头饰
for angle in [np.pi / 6, np.pi / 3, 2 * np.pi / 3, 5 * np.pi / 6]:
px = x + 0.25 * size * np.cos(angle)
py = y + 0.5 * size + 0.25 * size * np.sin(angle)
flower = Circle((px, py), 0.1 * size,
facecolor='#FF1493', alpha=0.8)
ax.add_patch(flower)
# 装饰 - 扇子
fan = PathPatch(
Path([(x + 0.4 * size, y - 0.3 * size), (x + 0.5 * size, y),
(x + 0.7 * size, y - 0.1 * size), (x + 0.5 * size, y - 0.4 * size),
(x + 0.4 * size, y - 0.3 * size)],
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.CLOSEPOLY]),
facecolor='#FFD700', edgecolor='#DAA520', lw=1, alpha=0.7
)
ax.add_patch(fan)
# 装饰 - 飘带
ribbon = PathPatch(
Path([(x - 0.2 * size, y - 0.9 * size), (x - 0.3 * size, y - 0.6 * size),
(x - 0.1 * size, y - 0.5 * size), (x, y - 0.7 * size),
(x + 0.1 * size, y - 0.5 * size), (x + 0.3 * size, y - 0.6 * size),
(x + 0.2 * size, y - 0.9 * size)],
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4,
Path.CURVE4, Path.CURVE4, Path.CURVE4]),
fill=False, edgecolor='#9370DB', lw=2, alpha=0.8
)
ax.add_patch(ribbon)
return (x, y)
# 在左侧绘制美人
beauty_pos = draw_beauty(2.5, 5, 1.2)
# 绘制敌方将领
def draw_general(x, y, size=1.0, distracted=False):
# 身体
body = Ellipse((x, y - 0.3 * size), 0.7 * size, 1.2 * size,
facecolor='#4682B4', edgecolor='#000080',
linewidth=2, alpha=0.8)
ax.add_patch(body)
# 头部
head = Circle((x, y + 0.4 * size), 0.3 * size,
facecolor='#FFE4E1', edgecolor='#FFC0CB',
linewidth=1.5)
ax.add_patch(head)
# 头盔/帽子
helmet = Polygon([
[x - 0.3 * size, y + 0.6 * size], [x + 0.3 * size, y + 0.6 * size],
[x + 0.4 * size, y + 0.8 * size], [x - 0.4 * size, y + 0.8 * size]
], facecolor='#A52A2A', edgecolor='#8B4513')
ax.add_patch(helmet)
# 面部特征
# 眼睛 - 如果分心则看向美人方向
if distracted:
# 分心的眼睛(看向美人)
eye_left = Ellipse((x - 0.1 * size, y + 0.45 * size), 0.08 * size, 0.05 * size,
facecolor='black')
eye_right = Ellipse((x + 0.1 * size, y + 0.45 * size), 0.08 * size, 0.05 * size,
facecolor='black')
ax.add_patch(eye_left)
ax.add_patch(eye_right)
# 添加心形
heart = PathPatch(
Path([(x + 0.5 * size, y + 0.7 * size), (x + 0.6 * size, y + 0.8 * size),
(x + 0.7 * size, y + 0.7 * size), (x + 0.6 * size, y + 0.6 * size),
(x + 0.5 * size, y + 0.7 * size)],
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.CURVE4]),
facecolor='#FF69B4', edgecolor='#8B0000', lw=1, alpha=0.6
)
ax.add_patch(heart)
else:
# 正常的眼睛
eye_left = Circle((x - 0.1 * size, y + 0.45 * size), 0.04 * size, facecolor='black')
eye_right = Circle((x + 0.1 * size, y + 0.45 * size), 0.04 * size, facecolor='black')
ax.add_patch(eye_left)
ax.add_patch(eye_right)
# 嘴巴
if distracted:
# 分心的笑容
mouth = PathPatch(
Path([(x - 0.1 * size, y + 0.35 * size), (x, y + 0.3 * size), (x + 0.1 * size, y + 0.35 * size)],
[Path.MOVETO, Path.CURVE3, Path.CURVE3]),
fill=False, edgecolor='#8B0000', lw=1.5
)
else:
# 正常的嘴巴
mouth = plt.Line2D([x - 0.1 * size, x + 0.1 * size], [y + 0.35 * size, y + 0.35 * size],
color='black', lw=1.5)
ax.add_line(mouth)
ax.add_patch(mouth)
# 武器(被丢弃)
if distracted:
sword = plt.Line2D([x - 0.8 * size, x - 0.4 * size], [y - 0.5 * size, y - 0.2 * size],
color='#C0C0C0', lw=2, linestyle=':')
ax.add_line(sword)
hilt = Rectangle((x - 0.85 * size, y - 0.52 * size), 0.1 * size, 0.1 * size,
facecolor='#8B4513')
ax.add_patch(hilt)
return (x, y)
# 在右侧绘制敌方将领(分心状态)
general_pos = draw_general(11.5, 5, 1.2, distracted=True)
# 绘制诱惑路径
def draw_temptation_path(start, end):
# 创建曲线路径
verts = [
start, # 起点
(start[0] + (end[0] - start[0]) / 3, start[1] + 2), # 控制点1
(start[0] + 2 * (end[0] - start[0]) / 3, end[1] - 1), # 控制点2
end # 终点
]
codes = [Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4]
path = Path(verts, codes)
patch = PathPatch(path, facecolor='none', edgecolor='#FF69B4',
linewidth=2, alpha=0.7, linestyle='-')
ax.add_patch(patch)
# 添加爱心标记
for t in np.linspace(0, 1, 8):
point = path.point(t)
heart = PathPatch(
Path([(point[0], point[1]), # 路径起点
(point[0] - 0.1, point[1] - 0.2), # 左控制点
(point[0], point[1] - 0.5), # 底部控制点
(point[0] + 0.1, point[1] - 0.2), # 右控制点
(point[0], point[1])], # 闭合路径
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.CLOSEPOLY]),
facecolor='#FF69B4', edgecolor='#8B0000', lw=0.5, alpha=0.7
)
ax.add_patch(heart)
# 添加小爱心
size = 0.1 + 0.05 * np.sin(t * 10)
heart = PathPatch(
Path([(point[0], point[1]),
(point[0] - 0.1, point[1] - 0.2),
(point[0], point[1] - 0.5),
(point[0] + 0.1, point[1] - 0.2),
(point[0], point[1])],
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.CLOSEPOLY]),
facecolor='#FF69B4', edgecolor='#8B0000', lw=0.5
)
ax.add_patch(heart)
# 绘制从美人到将领的诱惑路径
draw_temptation_path(beauty_pos, general_pos)
# 添加策略说明
strategy_explanation = """
美人计策略要点:
1. 精心挑选美人:选择有魅力的使者
2. 迷惑敌人:使敌人沉迷美色
3. 瓦解斗志:让敌人丧失警惕和战斗力
4. 获取情报:利用美人收集重要信息
5. 伺机行动:在敌人最松懈时发动攻击
"""
plt.text(1, 2.5, strategy_explanation, fontsize=14,
bbox=dict(boxstyle="round,pad=0.5",
facecolor='#FFF8DC',
edgecolor='#8B4513',
alpha=0.9))
# 添加历史案例
history_cases = """
历史案例:
- 西施助越灭吴
- 貂蝉离间董卓吕布
- 王昭君和亲匈奴
- 张仪献美人于楚王
"""
plt.text(12.5, 2.5, history_cases, fontsize=14,
bbox=dict(boxstyle="round,pad=0.5",
facecolor='#F0FFF0',
edgecolor='#2E8B57',
alpha=0.9))
# 添加警示
warning = plt.text(7, 1.2, "警示:美人计乃双刃剑,运用不当可能反噬其身",
fontsize=16, ha='center',
style='italic', color='#B22222',
bbox=dict(boxstyle="round", facecolor='#FFE4E1', alpha=0.8))
# 添加装饰元素 - 花朵
for _ in range(25):
x = np.random.uniform(0, 14)
y = np.random.uniform(0, 10)
size = np.random.uniform(0.1, 0.3)
color = np.random.choice(['#FF69B4', '#FF1493', '#DA70D6', '#BA55D3'])
flower = Circle((x, y), size, facecolor=color, alpha=0.3)
ax.add_patch(flower)
# 花蕊
center = Circle((x, y), size / 3, facecolor='#FFD700', alpha=0.4)
ax.add_patch(center)
# 花瓣
for i in range(5):
angle = i * 2 * np.pi / 5
px = x + size * np.cos(angle)
py = y + size * np.sin(angle)
petal = Ellipse((px, py), size / 2, size,
facecolor=color, alpha=0.2, angle=angle * 180 / np.pi)
ax.add_patch(petal)
# 添加装饰元素 - 帷幔
def draw_curtain(x, y, width, height):
# 帷幔顶部
top = Polygon([
[x, y], [x + width, y],
[x + width - 0.5, y + 0.3], [x + 0.5, y + 0.3],
[x, y]
], facecolor='#8B0000', alpha=0.7)
ax.add_patch(top)
# 帷幔褶皱
for i in range(5):
fold_x = x + i * width / 4
fold = PathPatch(
Path([(fold_x, y), (fold_x + width / 8, y - height), (fold_x + width / 4, y)]),
facecolor='#8B0000', alpha=0.5, edgecolor='#4B0082'
)
ax.add_patch(fold)
# 绘制顶部帷幔
draw_curtain(0, 9.5, 14, 0.5)
# 添加装饰元素 - 香炉
incense_burner = Ellipse((7, 8.5), 1.0, 0.4,
facecolor='#D2B48C', edgecolor='#8B4513')
ax.add_patch(incense_burner)
plt.text(7, 8.5, "香", fontsize=12, ha='center', color='#8B4513')
# 添加烟雾
for i in range(5):
smoke = PathPatch(
Path([(7, 9.0), (7 + 0.2 * i, 9.0 + 0.3 * i), (7 - 0.1 * i, 9.0 + 0.5 * i)]),
fill=False, edgecolor='#D3D3D3', lw=1, alpha=0.5
)
ax.add_patch(smoke)
# 添加策略效果箭头
plt.annotate('', xy=(11, 6), xytext=(8.5, 6.5),
arrowprops=dict(arrowstyle='->',
connectionstyle='arc3,rad=0.3',
color='#B22222', lw=2))
plt.text(9, 7, '迷惑效果', fontsize=14, color='#8B0000',
bbox=dict(facecolor='#FFE4E1', alpha=0.8))
# 添加力量对比图
plt.text(6.5, 3, '力量对比变化', fontsize=14, ha='center', color='#2F4F4F')
# 初始力量
plt.plot([5, 8], [2.5, 2.5], 'b-', lw=3, label='初始力量')
plt.text(5.5, 2.6, '敌方', color='b')
plt.text(7.5, 2.6, '我方', color='b')
# 施计后力量
plt.plot([5, 5.5], [2, 2], 'r-', lw=3, label='施计后敌方力量')
plt.plot([7.5, 8], [2.8, 2.8], 'g-', lw=3, label='施计后我方力量')
plt.text(5.2, 2.1, '敌方', color='r')
plt.text(7.7, 2.9, '我方', color='g')
# 添加图例说明
plt.text(6.5, 1.8, '美人计使敌方力量削弱,我方力量增强',
fontsize=12, ha='center', color='#8B0000')
plt.tight_layout()
plt.savefig('美人计.png', dpi=120, bbox_inches='tight')
plt.show()
空城计
虚者虚之,疑中生疑;刚柔之际,奇而复奇。
虚张声势,示弱以迷惑敌人。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Polygon, Circle, Arrow
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off')
ax.set_facecolor('#f5f5dc') # 背景色
# 标题
plt.title('空城计策略示意图', fontsize=20, fontweight='bold', color='#8B0000')
# 添加说明文本
description = "空城计:在敌众我寡的情况下,故意示弱、暴露空虚,使敌人产生怀疑而不敢贸然进攻。"
plt.figtext(0.5, 0.03, description, ha='center', fontsize=14, style='italic', color='#333333')
# 绘制城墙
wall = Rectangle((3, 2), 4, 3, facecolor='#8B4513', edgecolor='#000000', linewidth=2)
ax.add_patch(wall)
# 绘制城门
gate = Rectangle((4.5, 2), 1, 1.5, facecolor='#D2691E', edgecolor='#000000', linewidth=1.5)
ax.add_patch(gate)
# 绘制城楼
tower = Rectangle((4, 5), 2, 1, facecolor='#A52A2A', edgecolor='#000000', linewidth=2)
ax.add_patch(tower)
tower_roof = Polygon([[3.8, 6], [5, 7], [6.2, 6]], closed=True, facecolor='#8B0000', edgecolor='#000000')
ax.add_patch(tower_roof)
# 绘制旗帜
ax.plot([5, 5], [7, 7.8], color='#000000', linewidth=1.5)
flag = Polygon([[5, 7.8], [4.5, 7.6], [5, 7.4]], closed=True, facecolor='#FF0000', edgecolor='#000000')
ax.add_patch(flag)
# 绘制诸葛亮
ax.plot([5, 5], [5.5, 5], color='#000000', linewidth=1) # 身体
ax.add_patch(Circle((5, 5.6), 0.2, facecolor='#FFE4B5', edgecolor='#000000')) # 头部
ax.plot([4.8, 5.2], [5.5, 5.5], color='#000000', linewidth=1) # 手臂
# 添加诸葛亮标签
ax.text(5, 4.8, '诸葛亮', ha='center', fontsize=12, fontweight='bold', color='#8B0000')
# 绘制城墙上士兵
for i in range(3):
x = 3.5 + i * 1.5
ax.plot([x, x], [5, 4.5], color='#000000', linewidth=1) # 身体
ax.add_patch(Circle((x, 5.1), 0.15, facecolor='#FFE4B5', edgecolor='#000000')) # 头部
ax.plot([x - 0.1, x + 0.1], [4.7, 4.7], color='#000000', linewidth=1) # 手臂
# 绘制敌军
for i in range(5):
x = 0.5 + i * 0.5
y = 3 + np.random.uniform(-0.2, 0.2)
ax.plot([x, x], [y, y - 0.5], color='#000000', linewidth=1) # 身体
ax.add_patch(Circle((x, y + 0.1), 0.1, facecolor='#FFE4B5', edgecolor='#000000')) # 头部
# 绘制困惑的表情
ax.plot([x - 0.05, x - 0.02], [y, y - 0.02], color='#000000', linewidth=0.8) # 左眉毛
ax.plot([x + 0.02, x + 0.05], [y, y - 0.02], color='#000000', linewidth=0.8) # 右眉毛
ax.add_patch(Circle((x, y - 0.05), 0.03, facecolor='#000000')) # 嘴
# 添加敌军标签
ax.text(2.5, 1.5, '敌军', ha='center', fontsize=12, fontweight='bold', color='#00008B')
# 绘制问号表示困惑
for i in range(3):
x = 1.4 + i * 1.5
ax.text(x, 4, '?', fontsize=24, ha='center', color='#00008B')
# 绘制箭头表示敌军犹豫
ax.arrow(3.5, 2.5, -1, 0, head_width=0.2, head_length=0.2, fc='#00008B', ec='#00008B', linestyle='--')
ax.text(2.8, 2.7, '疑有埋伏', fontsize=10, color='#00008B')
# 添加三十六计标志
ax.text(0.5, 7.5, '三十六计', fontsize=16, fontweight='bold', color='#8B0000')
ax.text(0.5, 7.0, '第三十二计', fontsize=14, color='#8B0000')
# 添加策略说明
ax.text(8, 6.5, '策略精髓:', fontsize=14, fontweight='bold', color='#8B0000')
ax.text(8, 6.0, '虚者虚之,疑中生疑', fontsize=12, color='#333333')
ax.text(8, 5.5, '刚柔之际,奇而复奇', fontsize=12, color='#333333')
ax.text(8, 5.0, '虚虚实实,兵无常势', fontsize=12, color='#333333')
# 添加图例
ax.text(8, 4.0, '红色旗帜:守军旗帜', fontsize=10, color='#333333')
ax.text(8, 3.5, '打开城门:示敌以虚', fontsize=10, color='#333333')
ax.text(8, 3.0, '问号:敌军疑虑', fontsize=10, color='#333333')
# 显示图像
plt.tight_layout()
plt.savefig('空城计.png', dpi=120, bbox_inches='tight')
plt.show()
反间计
疑中之疑。比之自内,不自失也。
离间敌人内部,使其自损。
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# 创建画布
fig, ax = plt.subplots(figsize=(14, 10))
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
ax.set_facecolor('#f0f8ff') # 背景色
# 标题
plt.title('反间计策略示意图', fontsize=24, fontweight='bold', color='#8B0000', pad=20)
# 添加说明文本
description = "反间计:利用敌方间谍传递假情报,或离间敌方内部关系,使其互相猜疑、削弱实力。"
plt.figtext(0.5, 0, description, ha='center', fontsize=16, style='italic', color='#333333')
# 绘制我方阵营
my_camp = Rectangle((1, 1), 4, 8, fill=False, edgecolor='#006400', linewidth=3, linestyle='-')
ax.add_patch(my_camp)
ax.text(3, 9.5, '我方阵营', ha='center', fontsize=16, fontweight='bold', color='#006400')
# 绘制敌方阵营
enemy_camp = Rectangle((9, 1), 4, 8, fill=False, edgecolor='#8B0000', linewidth=3, linestyle='-')
ax.add_patch(enemy_camp)
ax.text(11, 9.5, '敌方阵营', ha='center', fontsize=16, fontweight='bold', color='#8B0000')
# 绘制间谍
def draw_person(x, y, color, name, role=None):
# 身体
ax.plot([x, x], [y, y-1.2], color=color, linewidth=2)
# 头部
ax.add_patch(Circle((x, y+0.2), 0.2, facecolor='#FFE4B5', edgecolor='#000000'))
# 手臂
ax.plot([x-0.3, x+0.3], [y-0.4, y-0.4], color=color, linewidth=2)
# 腿
ax.plot([x, x-0.3], [y-1.2, y-1.7], color=color, linewidth=2)
ax.plot([x, x+0.3], [y-1.2, y-1.7], color=color, linewidth=2)
# 名字
ax.text(x, y-2.0, name, ha='center', fontsize=12, fontweight='bold', color=color)
# 角色
if role:
ax.text(x, y-2.5, role, ha='center', fontsize=10, color=color)
# 绘制我方将军
draw_person(3, 7, '#006400', '将军', '我方统帅')
# 绘制敌方间谍
draw_person(3, 4, '#8B0000', '间谍', '敌方卧底')
# 绘制敌方将军
draw_person(11, 7, '#8B0000', '将军', '敌方统帅')
# 绘制敌方副将
draw_person(11, 4, '#8B0000', '副将', '敌方将领')
# 绘制情报传递
# 间谍向我方将军传递情报
ax.annotate('', xy=(3, 6.8), xytext=(3, 4.5),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=1.5, linestyle='-'))
ax.text(2.3, 4.6, '传递假情报', fontsize=10, rotation=90, color='#8B0000')
# 间谍向敌方将军传递情报
ax.annotate('', xy=(11, 7), xytext=(3.5, 4.5),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=1.5, linestyle='-'))
ax.text(7, 5.2, '传递假情报', fontsize=10, color='#8B0000')
# 间谍向敌方副将传递情报
ax.annotate('', xy=(11, 4.5), xytext=(3.5, 4.5),
arrowprops=dict(arrowstyle='->', color='#8B0000', lw=1.5, linestyle='-'))
ax.text(7, 3.0, '传递假情报', fontsize=10, color='#8B0000')
# 绘制猜疑关系
# 将军对副将的猜疑
ax.annotate('', xy=(10.5, 7), xytext=(10.5, 4.8),
arrowprops=dict(arrowstyle='->', color='#FF4500', lw=1.5, linestyle='--'))
ax.text(10.0, 6.0, '猜疑', fontsize=10, color='#FF4500')
# 副将对将军的猜疑
ax.annotate('', xy=(11.5, 4.8), xytext=(11.5, 7),
arrowprops=dict(arrowstyle='->', color='#FF4500', lw=1.5, linestyle='--'))
ax.text(12.0, 6.0, '猜疑', fontsize=10, color='#FF4500')
# 绘制情报信封
def draw_letter(x, y, text):
ax.add_patch(Rectangle((x-0.4, y-0.2), 0.8, 0.5, facecolor='#FFFACD', edgecolor='#8B4513'))
ax.text(x, y, text, ha='center', fontsize=9, color='#8B0000')
# 假情报信封
draw_letter(3, 5.5, '假情报')
draw_letter(8, 6.5, '假情报')
draw_letter(8, 4.0, '假情报')
# 绘制策略说明
ax.text(2, 0.5, '反间计策略步骤:', fontsize=14, fontweight='bold', color='#8B0000')
steps = [
'1. 发现敌方间谍',
'2. 不揭穿反而利用',
'3. 提供精心设计的假情报',
'4. 使敌方内部产生猜疑',
'5. 敌人自相残杀或决策失误'
]
for i, step in enumerate(steps):
ax.text(2, 0.5 - (i+1)*0.6, step, fontsize=12, color='#333333')
# 绘制历史案例
ax.text(12, 0.5, '历史案例:', fontsize=14, fontweight='bold', color='#8B0000')
cases = [
'三国赤壁之战',
'周瑜利用蒋干',
'传递假情报',
'使曹操误杀水军将领'
]
for i, case in enumerate(cases):
ax.text(12, 0.5 - (i+1)*0.6, case, fontsize=12, color='#333333')
# 绘制策略精髓
ax.text(7, 0.5, '策略精髓:', fontsize=14, fontweight='bold', color='#8B0000')
principles = [
'疑中之疑,比之自内',
'不自失也',
'利用敌人内部矛盾',
'以敌制敌'
]
for i, principle in enumerate(principles):
ax.text(7, 0.5 - (i+1)*0.6, principle, fontsize=12, color='#333333')
# 添加三十六计标志
ax.text(0.3, 10, '三十六计', fontsize=18, fontweight='bold', color='#8B0000')
ax.text(0.3, 9.5, '第三十三计', fontsize=16, color='#8B0000')
# 添加分隔线
ax.plot([7, 7], [1, 9], color='#888888', linewidth=1, linestyle='--')
# 显示图像
plt.tight_layout()
plt.savefig('反间计.png', dpi=120, bbox_inches='tight')
plt.show()
苦肉计
人不自害,受害必真;假真真假,间以得行。
自我伤害骗取敌人信任。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow
from matplotlib.text import TextPath
import matplotlib.patheffects as path_effects
from matplotlib.font_manager import FontProperties
import matplotlib.colors as mcolors
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Zen Hei']
plt.rcParams['axes.unicode_minus'] = False
# 创建画布
fig, ax = plt.subplots(figsize=(12, 8))
ax.set_xlim(0, 12)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off') # 隐藏坐标轴
# 设置背景色
fig.patch.set_facecolor('#f0f0f0')
ax.set_facecolor('#f0f0f0')
# 绘制标题
title_text = "苦肉计策略示意图"
subtitle_text = "人不自害,受害必真;假真真假,间以得行"
fig.suptitle(title_text, fontsize=24, fontweight='bold', color='#8B0000', y=0.98)
ax.set_title(subtitle_text, fontsize=16, pad=20, color='#8B0000')
# 绘制主策略图 - 分为三个部分:己方、苦肉计过程、敌方
# ========== 己方阵营 ==========
ax.add_patch(Rectangle((1, 1), 3, 6, fill=True, color='#E1F0FF', ec='#1E3F66', lw=2))
ax.text(2.5, 6.5, "己方阵营", fontsize=16, ha='center', va='center', color='#1E3F66', fontweight='bold')
# 将军
ax.add_patch(Circle((2.5, 4.5), 0.4, color='#FFD700'))
ax.text(2.5, 4.5, "将", fontsize=14, ha='center', va='center', color='black', fontweight='bold')
# 副将 (将被施以苦肉计)
ax.add_patch(Circle((2.5, 3.0), 0.4, color='#FF6347'))
ax.text(2.5, 3.0, "副", fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 苦肉计说明
ax.text(2.5, 2.0, "施以苦肉计\n(故意责罚副将)",
fontsize=12, ha='center', va='center',
color='#8B0000', bbox=dict(boxstyle="round,pad=0.3",
fc='#FFE4E1', ec='#8B0000', lw=1.5))
# ========== 中间过程 ==========
# 箭头从己方指向敌方
ax.annotate("", xy=(7.5, 3.0), xytext=(4.5, 3.0),
arrowprops=dict(arrowstyle="->", color='#8B0000', lw=2,
connectionstyle="arc3,rad=0",
shrinkA=15, shrinkB=15))
# 副将"投敌"
ax.add_patch(Polygon([(5.5, 3.5), (6.5, 3.0), (5.5, 2.5)],
closed=True, color='#FF6347'))
ax.text(6.0, 3.0, "副将投敌", fontsize=12, ha='center', va='center', color='#8B0000')
# ========== 敌方阵营 ==========
ax.add_patch(Rectangle((8, 1), 3, 6, fill=True, color='#FFE4E1', ec='#8B0000', lw=2))
ax.text(9.5, 6.5, "敌方阵营", fontsize=16, ha='center', va='center', color='#8B0000', fontweight='bold')
# 敌方主帅
ax.add_patch(Circle((9.5, 4.5), 0.4, color='#8B0000'))
ax.text(9.5, 4.5, "帅", fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 副将 (已投敌)
ax.add_patch(Circle((9.5, 3.0), 0.4, color='#FF6347'))
ax.text(9.5, 3.0, "副", fontsize=14, ha='center', va='center', color='white', fontweight='bold')
# 获取信任
ax.text(9.5, 2.0, "获取信任\n传递假情报",
fontsize=12, ha='center', va='center',
color='#1E3F66', bbox=dict(boxstyle="round,pad=0.3",
fc='#E1F0FF', ec='#1E3F66', lw=1.5))
# ========== 策略结果 ==========
# 胜利标志
ax.add_patch(Circle((5.5, 6.0), 0.8, color='#FFD700', alpha=0.8))
ax.text(5.5, 6.0, "胜", fontsize=22, ha='center', va='center', color='#8B0000', fontweight='bold')
# 添加策略说明
strategy_text = """
苦肉计解析:
1. 己方故意制造内部矛盾,责罚副将
2. 副将假装"叛逃"至敌方
3. 敌方因副将受伤而信任
4. 副将在敌方内部获取信任
5. 传递假情报或制造内乱
6. 己方趁机进攻取得胜利
"""
ax.text(1.0, 0.5, strategy_text, fontsize=12,
color='#333333', ha='left', va='top',
bbox=dict(boxstyle="round,pad=0.4", fc='white', ec='#999999', alpha=0.8))
# 添加历史案例
history_text = "历史案例:\n· 周瑜打黄盖(赤壁之战)\n· 王佐断臂(说降陆文龙)"
ax.text(10.0, 0.5, history_text, fontsize=12,
color='#333333', ha='right', va='top',
bbox=dict(boxstyle="round,pad=0.4", fc='#FFFFE0', ec='#DAA520', alpha=0.9))
# 添加装饰元素
# 火焰 (苦肉计象征)
flame_points = [(3.5, 1.8), (3.7, 1.5), (3.9, 1.9), (4.1, 1.4), (4.3, 1.7), (4.0, 2.0)]
ax.add_patch(Polygon(flame_points, closed=True, color='#FF4500', alpha=0.6))
# 剑 (象征计谋)
sword_points = [(2.0, 5.5), (2.1, 5.3), (2.8, 5.3), (2.9, 5.1), (2.7, 5.1), (2.6, 4.8),
(2.4, 4.8), (2.3, 5.1), (2.1, 5.1), (2.0, 5.3)]
ax.add_patch(Polygon(sword_points, closed=True, color='#A9A9A9'))
# 盾牌 (象征防御)
ax.add_patch(Rectangle((10.0, 5.0), 0.6, 0.8, color='#4682B4', alpha=0.7))
ax.add_patch(Circle((10.3, 5.4), 0.2, color='#4682B4', alpha=0.7))
# 添加边框装饰
border_rect = Rectangle((0.05, 0.05), 11.9, 7.9, fill=False,
ec='#8B0000', lw=2, linestyle='dashed', alpha=0.5)
ax.add_patch(border_rect)
# 添加水印
watermark = ax.text(6, 4, "苦肉计", fontsize=120,
color='lightgray', alpha=0.2, ha='center', va='center',
rotation=30, fontweight='bold')
# 添加来源说明
source_text = "来源: 《三十六计》· 第三十四计"
ax.text(11.9, 0.1, source_text, fontsize=10,
ha='right', va='bottom', color='gray', alpha=0.7)
plt.tight_layout()
plt.savefig('苦肉计.png', dpi=300, bbox_inches='tight')
plt.show()
连环计
将多兵众,不可以敌,使其自累,以杀其势。
多计并用,环环相扣。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, FancyArrowPatch
import matplotlib.patheffects as path_effects
from matplotlib import cm
import matplotlib as mpl
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
plt.figure(figsize=(14, 10), dpi=100)
ax = plt.gca()
ax.set_facecolor('#f5f5f5')
ax.set_xlim(0, 14)
ax.set_ylim(0, 10)
ax.set_aspect('equal')
ax.axis('off')
# 标题
title = plt.text(7, 9.5, "连环计策略示意图",
fontsize=28, ha='center', fontweight='bold', color='#8B0000')
title.set_path_effects([path_effects.withStroke(linewidth=4, foreground='#FFD700')])
# 副标题
plt.text(7, 8.7, "计计相连,环环相扣,使敌自累,而后图之",
fontsize=16, ha='center', color='#333333', style='italic')
# 中心敌人区域
enemy_center = Circle((7, 5), radius=1.2, color='#8B0000', alpha=0.8)
ax.add_patch(enemy_center)
plt.text(7, 5, "敌军主力", fontsize=16, ha='center', color='white', weight='bold')
# 创建连环计节点
tactics = ["诱敌深入", "分敌之势", "反间之计", "借刀杀人",
"釜底抽薪", "假痴不癫", "上屋抽梯", "关门捉贼"]
angles = np.linspace(0, 2 * np.pi, len(tactics), endpoint=False)
colors = cm.viridis(np.linspace(0, 1, len(tactics)))
# 绘制连环计节点和连接线
for i, (angle, tactic, color) in enumerate(zip(angles, tactics, colors)):
# 计算节点位置
x = 7 + 4 * np.cos(angle)
y = 5 + 4 * np.sin(angle)
# 绘制节点
node = Circle((x, y), radius=0.8, color=color, alpha=0.9)
ax.add_patch(node)
plt.text(x, y, tactic, fontsize=12, ha='center', va='center',
color='white', weight='bold')
# 绘制指向中心的箭头
arrow = FancyArrowPatch((x, y), (7 + 1.0 * np.cos(angle), 5 + 1.0 * np.sin(angle)),
arrowstyle='->', mutation_scale=20,
color=color, linewidth=2, alpha=0.8)
ax.add_patch(arrow)
# 绘制环环相扣的连接线
next_angle = angles[(i + 1) % len(tactics)]
next_x = 7 + 4 * np.cos(next_angle)
next_y = 5 + 4 * np.sin(next_angle)
mid_x1 = 7 + 3.5 * np.cos(angle + 0.15)
mid_y1 = 5 + 3.5 * np.sin(angle + 0.15)
mid_x2 = 7 + 3.5 * np.cos(next_angle - 0.15)
mid_y2 = 5 + 3.5 * np.sin(next_angle - 0.15)
# 绘制曲线连接线
path = mpl.path.Path(np.array([
[x, y],
[mid_x1, mid_y1],
[mid_x2, mid_y2],
[next_x, next_y]
]), codes=[1, 4, 4, 4])
patch = mpl.patches.PathPatch(
path,
facecolor='none',
edgecolor=color,
linewidth=2
)
ax.add_patch(patch)
# 添加连环计说明
explanation = "连环计:将多个计策组合使用,形成相互关联的计策链,使敌人陷入多重困境无法脱身。\n" \
"每个计策都削弱敌人的一部分力量或能力,最终使强大的敌人变得脆弱可击。"
plt.text(7, 1.5, explanation, fontsize=14, ha='center', color='#333333',
bbox=dict(boxstyle='round,pad=0.5', fc='#FFFFE0', ec='#8B7500', alpha=0.8))
# 添加历史案例
historical_example = "历史案例:三国时期,王允先献貂蝉(美人计),\n" \
"再挑拨吕布与董卓关系(反间计),最后借吕布之手除董卓(借刀杀人)"
plt.text(7, 0.7, historical_example, fontsize=12, ha='center', color='#8B0000', style='italic')
# 添加古代卷轴效果
scroll_top = Rectangle((0, 9.8), 14, 0.2, color='#D2B48C', alpha=0.9)
scroll_bottom = Rectangle((0, 0), 14, 0.2, color='#D2B48C', alpha=0.9)
ax.add_patch(scroll_top)
ax.add_patch(scroll_bottom)
scroll_left = Polygon(np.array([[0, 0], [0.5, 0.1], [0.5, 9.9], [0, 9.8]]), color='#8B4513', alpha=0.7)
scroll_right = Polygon(np.array([[14, 0], [13.5, 0.1], [13.5, 9.9], [14, 9.8]]), color='#8B4513', alpha=0.7)
ax.add_patch(scroll_left)
ax.add_patch(scroll_right)
# 添加印章
seal = plt.text(12.5, 1, "兵\n法", fontsize=14, ha='center', va='center',
color='#8B0000', fontproperties='SimHei',
bbox=dict(boxstyle='circle,pad=0.7', fc='none', ec='#8B0000', lw=2))
seal.set_path_effects([path_effects.withStroke(linewidth=1, foreground='#8B0000')])
# 添加三十六计标志
logo = plt.text(1.5, 1, "三十六计", fontsize=16, ha='center',
color='#8B0000', weight='bold', style='italic')
logo.set_path_effects([path_effects.withStroke(linewidth=2, foreground='#DAA520')])
# 添加装饰性箭头
deco_arrow1 = FancyArrowPatch((2, 8.5), (4, 7.5), arrowstyle='->',
mutation_scale=25, color='#8B0000', linewidth=1.5, alpha=0.6)
deco_arrow2 = FancyArrowPatch((12, 8.5), (10, 7.5), arrowstyle='->',
mutation_scale=25, color='#8B0000', linewidth=1.5, alpha=0.6)
ax.add_patch(deco_arrow1)
ax.add_patch(deco_arrow2)
plt.tight_layout()
plt.savefig('连环计.png', dpi=120, bbox_inches='tight')
plt.show()
走为上计
全师避敌。左次无咎,未失常也。
形势不利时主动撤退,保存实力。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow
from matplotlib.collections import PatchCollection
import matplotlib.patheffects as path_effects
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Zen Hei']
plt.rcParams['axes.unicode_minus'] = False
plt.figure(figsize=(12, 8), dpi=100)
ax = plt.gca()
ax.set_facecolor('#f0f0f0')
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.axis('off')
# 标题
title = plt.text(5, 7.5, "走为上计策略示意图",
fontsize=24, ha='center', fontweight='bold', color='#8B0000')
title.set_path_effects([path_effects.withStroke(linewidth=3, foreground='gold')])
# 副标题
plt.text(5, 6.8, "敌势全胜,我不能战,则:必降、必和、必走。降则全败,和则半败,走则未败。",
fontsize=14, ha='center', color='#333333', style='italic')
# 战场区域
battlefield = Rectangle((1, 1), 8, 4, linewidth=2, linestyle='-',
edgecolor='#8B0000', facecolor='#ffcccc', alpha=0.7)
ax.add_patch(battlefield)
plt.text(5, 5, "战场区域", fontsize=12, ha='center', color='#8B0000')
# 敌军
enemy_positions = [(3.5, 4.5), (4, 4), (4.5, 4.5), (5, 4), (5.5, 4.5), (6, 4), (6.5, 4.5)]
for pos in enemy_positions:
enemy = Circle(pos, radius=0.15, color='#8B0000')
ax.add_patch(enemy)
plt.text(5, 3.8, "敌军主力", fontsize=10, ha='center', color='#8B0000')
# 我军
our_army = Circle((4.5, 3), radius=0.2, color='#0066cc')
ax.add_patch(our_army)
plt.text(4.5, 2.7, "我军", fontsize=10, ha='center', color='#0066cc', weight='bold')
# 撤退路线 (走为上计)
retreat_path = plt.arrow(4.5, 2.8, 0, -1.5, width=0.05, head_width=0.3,
head_length=0.3, fc='#0066cc', ec='#0066cc', alpha=0.7)
plt.text(4.5, 1.5, "撤退路线", fontsize=10, ha='center', color='#0066cc')
# 安全区域
safe_zone = Rectangle((3, 0.5), 3, 1, linewidth=2, linestyle='--',
edgecolor='#006400', facecolor='#ccffcc', alpha=0.7)
ax.add_patch(safe_zone)
plt.text(4.5, 1, "安全区域", fontsize=12, ha='center', color='#006400')
# 策略说明
strategy_text = "策略解释:在敌强我弱的形势下,为保存实力,主动撤退,避开强敌。\n" \
"撤退不是失败,而是为了寻找更有利的战机,是为上策。"
plt.text(5, 0.2, strategy_text, fontsize=12, ha='center', color='#333333')
# 三十六计标志
logo_text = plt.text(9, 7.5, "三十六计", fontsize=16, ha='center',
color='#8B0000', weight='bold', style='italic')
logo_text.set_path_effects([path_effects.withStroke(linewidth=2, foreground='#DAA520')])
# 古代印章效果
seal = Rectangle((0.2, 0.2), 1.5, 1.5, linewidth=1.5, linestyle='-',
edgecolor='#8B0000', facecolor='none', alpha=0.8)
ax.add_patch(seal)
plt.text(0.95, 1, "兵\n法", fontsize=14, ha='center',
color='#8B0000', fontproperties='SimHei')
# 装饰元素:古代卷轴
scroll_top = Rectangle((0, 7.8), 10, 0.2, color='#D2B48C', alpha=0.9)
scroll_bottom = Rectangle((0, 0), 10, 0.2, color='#D2B48C', alpha=0.9)
ax.add_patch(scroll_top)
ax.add_patch(scroll_bottom)
scroll_left = Polygon(np.array([[0, 0], [0.5, 0.1], [0.5, 7.9], [0, 7.8]]), color='#A0522D', alpha=0.7)
scroll_right = Polygon(np.array([[10, 0], [9.5, 0.1], [9.5, 7.9], [10, 7.8]]), color='#A0522D', alpha=0.7)
ax.add_patch(scroll_left)
ax.add_patch(scroll_right)
plt.tight_layout()
plt.savefig('走为上计.png', dpi=120, bbox_inches='tight')
plt.show()
词云图
import jieba
from wordcloud import WordCloud
import matplotlib.pyplot as plt
from collections import Counter
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 三十六计数据
strategies = [
"瞒天过海", "围魏救赵", "借刀杀人", "以逸待劳", "趁火打劫", "声东击西",
"无中生有", "暗渡陈仓", "隔岸观火", "笑里藏刀", "李代桃僵", "顺手牵羊",
"打草惊蛇", "借尸还魂", "调虎离山", "欲擒故纵", "抛砖引玉", "擒贼擒王",
"釜底抽薪", "混水摸鱼", "金蝉脱壳", "关门捉贼", "远交近攻", "假道伐虢",
"偷梁换柱", "指桑骂槐", "假痴不癫", "上屋抽梯", "树上开花", "反客为主",
"美人计", "空城计", "反间计", "苦肉计", "连环计", "走为上计"
]
# 处理文本
text = " ".join(strategies)
words = jieba.lcut(text)
word_list = " ".join(words)
word_counts = Counter(words)
font_path = "C:/Windows/Fonts/simhei.ttf"
# 生成词云
wc = WordCloud(
font_path=font_path,
background_color="white",
max_words=200,
width=800,
height=600,
collocations=False
)
wc.generate_from_frequencies(word_counts)
# 显示结果
plt.figure(figsize=(10, 8))
plt.imshow(wc, interpolation="bilinear")
plt.axis("off")
plt.show()
# 保存图片
wc.to_file("三十六计词云.png")
网络关系图
import networkx as nx
import plotly.graph_objects as go
import pandas as pd
# 三十六计数据
strategies = [
# 胜战计 (6)
{"id": 1, "name": "瞒天过海", "category": "胜战计",
"description": "通过伪装和欺骗,使敌人放松警惕,从而达成目的"},
{"id": 2, "name": "围魏救赵", "category": "胜战计",
"description": "攻击敌人后方,迫使其撤退,从而解围"},
{"id": 3, "name": "借刀杀人", "category": "胜战计",
"description": "利用他人之力达到自己的目的"},
{"id": 4, "name": "以逸待劳", "category": "胜战计",
"description": "在敌人疲惫时出击,以最小的代价取得胜利"},
{"id": 5, "name": "趁火打劫", "category": "胜战计",
"description": "在敌人遭遇困境时加以攻击,扩大优势"},
{"id": 6, "name": "声东击西", "category": "胜战计",
"description": "佯攻一个方向,实际攻击另一个方向"},
# 敌战计 (6)
{"id": 7, "name": "无中生有", "category": "敌战计",
"description": "制造假象迷惑敌人,使其产生错觉"},
{"id": 8, "name": "暗渡陈仓", "category": "敌战计",
"description": "明修栈道,暗渡陈仓,暗中进行真实行动"},
{"id": 9, "name": "隔岸观火", "category": "敌战计",
"description": "等待敌人内部矛盾激化,坐收渔利"},
{"id": 10, "name": "笑里藏刀", "category": "敌战计",
"description": "表面友好,暗藏杀机"},
{"id": 11, "name": "李代桃僵", "category": "敌战计",
"description": "牺牲局部以保全整体"},
{"id": 12, "name": "顺手牵羊", "category": "敌战计",
"description": "利用机会获取小利,积小胜为大胜"},
# 攻战计 (6)
{"id": 13, "name": "打草惊蛇", "category": "攻战计",
"description": "通过试探性行动,了解敌人意图"},
{"id": 14, "name": "借尸还魂", "category": "攻战计",
"description": "利用已失去作用的事物来实现自己的目的"},
{"id": 15, "name": "调虎离山", "category": "攻战计",
"description": "引诱敌人离开有利位置,然后攻击"},
{"id": 16, "name": "欲擒故纵", "category": "攻战计",
"description": "为了更好控制,先放松一下"},
{"id": 17, "name": "抛砖引玉", "category": "攻战计",
"description": "用小利引诱敌人,然后实施打击"},
{"id": 18, "name": "擒贼擒王", "category": "攻战计",
"description": "打击敌人的要害部位或首领"},
# 混战计 (6)
{"id": 19, "name": "釜底抽薪", "category": "混战计",
"description": "从根本上解决问题"},
{"id": 20, "name": "浑水摸鱼", "category": "混战计",
"description": "在混乱中获取利益"},
{"id": 21, "name": "金蝉脱壳", "category": "混战计",
"description": "巧妙撤退,摆脱敌人"},
{"id": 22, "name": "关门捉贼", "category": "混战计",
"description": "切断敌人退路,一举歼灭"},
{"id": 23, "name": "远交近攻", "category": "混战计",
"description": "与远方的敌人结交,攻击近处的敌人"},
{"id": 24, "name": "假途伐虢", "category": "混战计",
"description": "借路之名,行占领之实"},
# 并战计 (6)
{"id": 25, "name": "偷梁换柱", "category": "并战计",
"description": "暗中改变事物的本质"},
{"id": 26, "name": "指桑骂槐", "category": "并战计",
"description": "间接批评或指责"},
{"id": 27, "name": "假痴不癫", "category": "并战计",
"description": "假装糊涂,实则清醒,等待时机"},
{"id": 28, "name": "上屋抽梯", "category": "并战计",
"description": "诱敌深入,断其后路"},
{"id": 29, "name": "树上开花", "category": "并战计",
"description": "制造假象,虚张声势"},
{"id": 30, "name": "反客为主", "category": "并战计",
"description": "变被动为主动,掌握主导权"},
# 败战计 (6)
{"id": 31, "name": "美人计", "category": "败战计",
"description": "利用美色诱惑敌人,使其丧失战斗力"},
{"id": 32, "name": "空城计", "category": "败战计",
"description": "在力量空虚时,故意显示不设防,使敌人疑有埋伏"},
{"id": 33, "name": "反间计", "category": "败战计",
"description": "利用敌人的间谍传递假情报"},
{"id": 34, "name": "苦肉计", "category": "败战计",
"description": "故意伤害自己,骗取敌人信任"},
{"id": 35, "name": "连环计", "category": "败战计",
"description": "多个计策环环相扣,形成连锁反应"},
{"id": 36, "name": "走为上计", "category": "败战计",
"description": "在不利形势下,撤退是最好的选择"}
]
# 创建类别颜色映射
category_colors = {
"胜战计": "#FF6B6B", # 红色
"敌战计": "#4ECDC4", # 青色
"攻战计": "#FFD166", # 黄色
"混战计": "#06D6A0", # 绿色
"并战计": "#118AB2", # 蓝色
"败战计": "#073B4C" # 深蓝
}
# 创建数据框
df = pd.DataFrame(strategies)
# 为每个计策分配颜色
df['color'] = df['category'].map(category_colors)
# 创建关系数据 - 基于相似性和互补性
# 这里我们手动创建一些关系,实际应用中可以使用更复杂的算法
relations = [
# 同类关系
(1, 2), (1, 3), (1, 6), (2, 4), (2, 5), (3, 4),
(7, 8), (7, 9), (8, 10), (9, 11), (10, 12),
(13, 14), (13, 15), (14, 16), (15, 17), (16, 18),
(19, 20), (19, 21), (20, 22), (21, 23), (22, 24),
(25, 26), (25, 27), (26, 28), (27, 29), (28, 30),
(31, 32), (31, 33), (32, 34), (33, 35), (34, 36),
# 跨类关系
(1, 7), (1, 14), (1, 21), # 瞒天过海与其他计策
(6, 15), (6, 29), # 声东击西
(10, 31), (10, 34), # 笑里藏刀
(18, 36), # 擒贼擒王与走为上
(22, 28), # 关门捉贼与上屋抽梯
(35, 1), (35, 6), (35, 15), # 连环计
(36, 21), (36, 30) # 走为上与其他
]
# 创建图对象
G = nx.Graph()
# 添加节点
for _, row in df.iterrows():
G.add_node(row['id'],
name=row['name'],
category=row['category'],
description=row['description'],
color=row['color'])
# 添加边
for relation in relations:
G.add_edge(relation[0], relation[1])
# 使用spring布局确定节点位置
pos = nx.spring_layout(G, k=0.3, seed=42)
# 提取节点位置
node_x = []
node_y = []
node_text = []
node_color = []
node_size = []
node_category = []
node_description = []
for node in G.nodes():
x, y = pos[node]
node_x.append(x)
node_y.append(y)
# 获取节点属性
node_data = G.nodes[node]
node_text.append(node_data['name'])
node_color.append(node_data['color'])
node_category.append(node_data['category'])
node_description.append(node_data['description'])
# 根据连接数确定节点大小
degree = G.degree[node]
node_size.append(10 + degree * 3)
# 提取边信息
edge_x = []
edge_y = []
for edge in G.edges():
x0, y0 = pos[edge[0]]
x1, y1 = pos[edge[1]]
edge_x.extend([x0, x1, None])
edge_y.extend([y0, y1, None])
# 创建边迹
edge_trace = go.Scatter(
x=edge_x, y=edge_y,
line=dict(width=0.8, color='#888'),
hoverinfo='none',
mode='lines')
# 创建节点迹
node_trace = go.Scatter(
x=node_x, y=node_y,
mode='markers+text',
text=node_text,
textposition="middle center",
textfont=dict(size=8, color='black'),
hoverinfo='text',
marker=dict(
color=node_color,
size=node_size,
line=dict(width=2, color='black'))
)
# 自定义悬停文本
hover_text = []
for i, node in enumerate(G.nodes()):
node_data = G.nodes[node]
hover_text.append(
f"<b>{node_data['name']}</b><br>"
f"类别: {node_data['category']}<br>"
f"描述: {node_data['description']}<br>"
f"连接数: {G.degree[node]}"
)
node_trace.text = hover_text
# 创建图
fig = go.Figure(data=[edge_trace, node_trace],
layout=go.Layout(
title='<b>三十六计关系网络图</b><br><sup>节点大小表示连接数 | 颜色表示类别 | 悬停查看详情</sup>',
titlefont_size=20,
titlefont_family="SimHei",
showlegend=False,
hovermode='closest',
margin=dict(b=20, l=5, r=5, t=80),
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
yaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
height=700,
width=1000,
plot_bgcolor='#f8f9fa',
paper_bgcolor='#f8f9fa'
))
# 添加类别图例
legend_y = 1.0
for category, color in category_colors.items():
fig.add_annotation(
x=1.05,
y=legend_y,
xref="paper",
yref="paper",
text=f"<span style='color:{color};'>●</span> {category}",
showarrow=False,
font=dict(size=12),
align="left"
)
legend_y -= 0.05
# 添加说明
fig.add_annotation(
x=0.5,
y=-0.1,
xref="paper",
yref="paper",
text="三十六计关系网络图展示了各计策之间的关联关系,连线表示策略上的相似性或互补性",
showarrow=False,
font=dict(size=12, color="#666")
)
# 添加交互按钮
fig.update_layout(
updatemenus=[
dict(
type="buttons",
direction="down",
x=0.01,
y=1.0,
buttons=[
dict(
label="全部",
method="update",
args=[{"visible": [True, True]}, {"title": "三十六计关系网络图 (全部)"}]
),
dict(
label="胜战计",
method="update",
args=[{"visible": [True] + [node_category[i] == "胜战计" for i in range(len(node_x))]},
{"title": "三十六计关系网络图 (胜战计)"}]
),
dict(
label="敌战计",
method="update",
args=[{"visible": [True] + [node_category[i] == "敌战计" for i in range(len(node_x))]},
{"title": "三十六计关系网络图 (敌战计)"}]
),
dict(
label="攻战计",
method="update",
args=[{"visible": [True] + [node_category[i] == "攻战计" for i in range(len(node_x))]},
{"title": "三十六计关系网络图 (攻战计)"}]
),
dict(
label="混战计",
method="update",
args=[{"visible": [True] + [node_category[i] == "混战计" for i in range(len(node_x))]},
{"title": "三十六计关系网络图 (混战计)"}]
),
dict(
label="并战计",
method="update",
args=[{"visible": [True] + [node_category[i] == "并战计" for i in range(len(node_x))]},
{"title": "三十六计关系网络图 (并战计)"}]
),
dict(
label="败战计",
method="update",
args=[{"visible": [True] + [node_category[i] == "败战计" for i in range(len(node_x))]},
{"title": "三十六计关系网络图 (败战计)"}]
)
]
)
]
)
# 保存为交互式HTML文件
fig.write_html("网络图.html", auto_open=False)
交互式图表
import plotly.graph_objects as go
import pandas as pd
from plotly.subplots import make_subplots
# 三十六计数据
strategies = [
# 胜战计 (6)
{"id": 1, "name": "瞒天过海", "category": "胜战计",
"description": "通过伪装和欺骗,使敌人放松警惕,从而达成目的"},
{"id": 2, "name": "围魏救赵", "category": "胜战计",
"description": "攻击敌人后方,迫使其撤退,从而解围"},
{"id": 3, "name": "借刀杀人", "category": "胜战计",
"description": "利用他人之力达到自己的目的"},
{"id": 4, "name": "以逸待劳", "category": "胜战计",
"description": "在敌人疲惫时出击,以最小的代价取得胜利"},
{"id": 5, "name": "趁火打劫", "category": "胜战计",
"description": "在敌人遭遇困境时加以攻击,扩大优势"},
{"id": 6, "name": "声东击西", "category": "胜战计",
"description": "佯攻一个方向,实际攻击另一个方向"},
# 敌战计 (6)
{"id": 7, "name": "无中生有", "category": "敌战计",
"description": "制造假象迷惑敌人,使其产生错觉"},
{"id": 8, "name": "暗渡陈仓", "category": "敌战计",
"description": "明修栈道,暗渡陈仓,暗中进行真实行动"},
{"id": 9, "name": "隔岸观火", "category": "敌战计",
"description": "等待敌人内部矛盾激化,坐收渔利"},
{"id": 10, "name": "笑里藏刀", "category": "敌战计",
"description": "表面友好,暗藏杀机"},
{"id": 11, "name": "李代桃僵", "category": "敌战计",
"description": "牺牲局部以保全整体"},
{"id": 12, "name": "顺手牵羊", "category": "敌战计",
"description": "利用机会获取小利,积小胜为大胜"},
# 攻战计 (6)
{"id": 13, "name": "打草惊蛇", "category": "攻战计",
"description": "通过试探性行动,了解敌人意图"},
{"id": 14, "name": "借尸还魂", "category": "攻战计",
"description": "利用已失去作用的事物来实现自己的目的"},
{"id": 15, "name": "调虎离山", "category": "攻战计",
"description": "引诱敌人离开有利位置,然后攻击"},
{"id": 16, "name": "欲擒故纵", "category": "攻战计",
"description": "为了更好控制,先放松一下"},
{"id": 17, "name": "抛砖引玉", "category": "攻战计",
"description": "用小利引诱敌人,然后实施打击"},
{"id": 18, "name": "擒贼擒王", "category": "攻战计",
"description": "打击敌人的要害部位或首领"},
# 混战计 (6)
{"id": 19, "name": "釜底抽薪", "category": "混战计",
"description": "从根本上解决问题"},
{"id": 20, "name": "浑水摸鱼", "category": "混战计",
"description": "在混乱中获取利益"},
{"id": 21, "name": "金蝉脱壳", "category": "混战计",
"description": "巧妙撤退,摆脱敌人"},
{"id": 22, "name": "关门捉贼", "category": "混战计",
"description": "切断敌人退路,一举歼灭"},
{"id": 23, "name": "远交近攻", "category": "混战计",
"description": "与远方的敌人结交,攻击近处的敌人"},
{"id": 24, "name": "假途伐虢", "category": "混战计",
"description": "借路之名,行占领之实"},
# 并战计 (6)
{"id": 25, "name": "偷梁换柱", "category": "并战计",
"description": "暗中改变事物的本质"},
{"id": 26, "name": "指桑骂槐", "category": "并战计",
"description": "间接批评或指责"},
{"id": 27, "name": "假痴不癫", "category": "并战计",
"description": "假装糊涂,实则清醒,等待时机"},
{"id": 28, "name": "上屋抽梯", "category": "并战计",
"description": "诱敌深入,断其后路"},
{"id": 29, "name": "树上开花", "category": "并战计",
"description": "制造假象,虚张声势"},
{"id": 30, "name": "反客为主", "category": "并战计",
"description": "变被动为主动,掌握主导权"},
# 败战计 (6)
{"id": 31, "name": "美人计", "category": "败战计",
"description": "利用美色诱惑敌人,使其丧失战斗力"},
{"id": 32, "name": "空城计", "category": "败战计",
"description": "在力量空虚时,故意显示不设防,使敌人疑有埋伏"},
{"id": 33, "name": "反间计", "category": "败战计",
"description": "利用敌人的间谍传递假情报"},
{"id": 34, "name": "苦肉计", "category": "败战计",
"description": "故意伤害自己,骗取敌人信任"},
{"id": 35, "name": "连环计", "category": "败战计",
"description": "多个计策环环相扣,形成连锁反应"},
{"id": 36, "name": "走为上计", "category": "败战计",
"description": "在不利形势下,撤退是最好的选择"}
]
# 创建数据框
df = pd.DataFrame(strategies)
# 创建类别颜色映射
category_colors = {
"胜战计": "#FF6B6B",
"敌战计": "#4ECDC4",
"攻战计": "#FFD166",
"混战计": "#06D6A0",
"并战计": "#118AB2",
"败战计": "#073B4C"
}
# 为每个计策分配颜色
df['color'] = df['category'].map(category_colors)
# 创建图表
fig = make_subplots(rows=1, cols=1, specs=[[{"type": "scatter"}]])
# 添加计策点
for i, strategy in enumerate(strategies):
# 计算位置(按类别分组)
category_idx = ["胜战计", "敌战计", "攻战计", "混战计", "并战计", "败战计"].index(strategy['category'])
x = category_idx + (i % 6) * 0.15 - 0.375
y = category_idx * 0.8
# 添加点
fig.add_trace(go.Scatter(
x=[x],
y=[y],
mode='markers+text',
marker=dict(
size=25,
color=category_colors[strategy['category']],
line=dict(width=2, color='white')
),
text=[strategy['name']],
textposition="middle center",
textfont=dict(color='white', size=10),
name=strategy['name'],
customdata=[[strategy['description']]],
hovertemplate=(
"<b>%{text}</b><br>" +
"类别: " + strategy['category'] + "<br>" +
"描述: %{customdata[0]}<br>" +
"<extra></extra>"
)
))
# 添加类别标签
for i, category in enumerate(["胜战计", "敌战计", "攻战计", "混战计", "并战计", "败战计"]):
fig.add_annotation(
x=i - 0.5,
y=i * 0.8 + 0.3,
text=category,
showarrow=False,
font=dict(size=14, color=category_colors[category]),
xanchor="center"
)
# 更新布局
fig.update_layout(
title=dict(
text="<b>三十六计交互式图表</b><br><sup>点击计策查看详情 | 鼠标悬停查看更多信息</sup>",
x=0.5,
font=dict(size=24, family="SimHei", color="#333")
),
showlegend=False,
height=650,
width=1000,
plot_bgcolor='#F5F7FA',
paper_bgcolor='#F5F7FA',
xaxis=dict(
showgrid=False,
zeroline=False,
showticklabels=False,
range=[-1, 6]
),
yaxis=dict(
showgrid=False,
zeroline=False,
showticklabels=False,
range=[-1, 5]
),
hoverlabel=dict(
bgcolor="white",
font_size=12,
font_family="SimHei"
),
margin=dict(l=50, r=50, t=100, b=50),
shapes=[
# 添加背景形状
dict(
type="rect",
xref="paper",
yref="paper",
x0=0,
y0=0,
x1=1,
y1=1,
fillcolor="#F5F7FA",
opacity=1,
layer="below",
line_width=0
)
]
)
# 添加说明
fig.add_annotation(
x=0.5,
y=-0.15,
text="三十六计是中国古代兵法策略的总结,分为六大类,每类六计",
showarrow=False,
font=dict(size=12, color="#666"),
xanchor="center"
)
# 添加图例说明
legend_y = 4.5
for category, color in category_colors.items():
fig.add_annotation(
x=0.5,
y=legend_y,
text=f"● {category}",
showarrow=False,
font=dict(size=12, color=color),
xanchor="center"
)
legend_y -= 0.4
# 添加交互功能
fig.update_layout(
updatemenus=[
dict(
type="dropdown",
direction="down",
x=0.02,
y=1.0,
buttons=[
dict(
label="全部计策",
method="update",
args=[{"visible": [True] * 36}]
),
dict(
label="胜战计",
method="update",
args=[{"visible": [s['category'] == '胜战计' for s in strategies]}]
),
dict(
label="敌战计",
method="update",
args=[{"visible": [s['category'] == '敌战计' for s in strategies]}]
),
dict(
label="攻战计",
method="update",
args=[{"visible": [s['category'] == '攻战计' for s in strategies]}]
),
dict(
label="混战计",
method="update",
args=[{"visible": [s['category'] == '混战计' for s in strategies]}]
),
dict(
label="并战计",
method="update",
args=[{"visible": [s['category'] == '并战计' for s in strategies]}]
),
dict(
label="败战计",
method="update",
args=[{"visible": [s['category'] == '败战计' for s in strategies]}]
)
]
)
]
)
# 保存为交互式HTML文件
fig.write_html("strategies_interactive_chart.html", auto_open=True)
思维导图
import matplotlib.pyplot as plt
import networkx as nx
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
# 创建图形
plt.figure(figsize=(16, 12))
G = nx.Graph()
# 三十六计结构
categories = {
"胜战计": ["瞒天过海", "围魏救赵", "借刀杀人", "以逸待劳", "趁火打劫", "声东击西"],
"敌战计": ["无中生有", "暗渡陈仓", "隔岸观火", "笑里藏刀", "李代桃僵", "顺手牵羊"],
"攻战计": ["打草惊蛇", "借尸还魂", "调虎离山", "欲擒故纵", "抛砖引玉", "擒贼擒王"],
"混战计": ["釜底抽薪", "混水摸鱼", "金蝉脱壳", "关门捉贼", "远交近攻", "假道伐虢"],
"并战计": ["偷梁换柱", "指桑骂槐", "假痴不癫", "上屋抽梯", "树上开花", "反客为主"],
"败战计": ["美人计", "空城计", "反间计", "苦肉计", "连环计", "走为上计"]
}
# 添加节点和边
# 中心节点
G.add_node("三十六计", size=3000, color='gold')
# 添加分类节点
for i, (category, strategies) in enumerate(categories.items()):
# 添加分类节点
G.add_node(category, size=1500, color=f'C{i}')
G.add_edge("三十六计", category)
# 添加具体计策节点
for strategy in strategies:
G.add_node(strategy, size=800, color=f'C{i}')
G.add_edge(category, strategy)
# 设置布局
pos = nx.spring_layout(G, k=0.3, seed=42) # k参数控制节点间距
# 绘制节点
node_sizes = [G.nodes[node]['size'] for node in G.nodes()]
node_colors = [G.nodes[node]['color'] for node in G.nodes()]
nx.draw_networkx_nodes(
G, pos,
node_size=node_sizes,
node_color=node_colors,
alpha=0.8
)
# 绘制标签
nx.draw_networkx_labels(
G, pos,
font_size=12,
font_weight='bold',
font_family='SimHei'
)
# 绘制边
nx.draw_networkx_edges(
G, pos,
width=1.5,
edge_color='gray',
alpha=0.6
)
# 添加标题和注释
plt.figtext(0.5, 0.01,
"《三十六计》是中国古代兵法策略的集大成者,分胜战、敌战、攻战、混战、并战、败战六套计策,每套六计",
ha="center", fontsize=14, style='italic')
# 添加图例
from matplotlib.patches import Patch
legend_elements = [
Patch(facecolor='gold', label='核心概念'),
Patch(facecolor='C0', label='胜战计'),
Patch(facecolor='C1', label='敌战计'),
Patch(facecolor='C2', label='攻战计'),
Patch(facecolor='C3', label='混战计'),
Patch(facecolor='C4', label='并战计'),
Patch(facecolor='C5', label='败战计'),
]
plt.legend(handles=legend_elements, loc='upper right', fontsize=12)
# 保存和显示
plt.tight_layout()
plt.savefig("三十六计思维导图.png", dpi=300, bbox_inches='tight')
plt.show()