# rubiks_color_change.py
# 运行: python rubiks_color_change.py
# 会生成 rubiks_color_change.html
import json
import model.Cube as Cube
def generate_rubiks_html(initial_state, indince, moves, output_file="rubiks_move.html"):
"""
initial_state: dict, {face_name: [9个颜色字符串]}
face_name: U, D, F, B, L, R
颜色字符串可用 "white","yellow","red","orange","blue","green"
moves: list, 每步是一个新的状态 (即9个颜色变化后的完整魔方)
"""
html_template = f"""
Rubik's Cube Color Change Animation
"""
with open(output_file, "w", encoding="utf-8") as f:
f.write(html_template)
print(f"已生成 {output_file} ,用浏览器打开即可。")
# ===== 测试示例 =====
if __name__ == "__main__":
initial_state = {
"U": ["white"] * 9,
"D": ["yellow"] * 9,
"F": ["red"] * 9,
"B": ["orange"] * 9,
"L": ["blue"] * 9,
"R": ["green"] * 9
}
# 生成几个动作后的状态(这里只是演示,实际可根据魔方动作计算)
move1 = initial_state.copy()
move1 = {f: c[:] for f, c in move1.items()}
move1["F"][0] = "blue"
move2 = {f: c[:] for f, c in move1.items()}
move2["R"][4] = "white"
moves = [move1, move2]
generate_rubiks_html(initial_state, moves)