% !Mode:: "TeX:UTF-8"
% !TEX encoding = UTF-8 Unicode

\begin{center}
  \begin{tikzpicture}[remember picture]
    \tikzset {
      block/.style={draw,inner sep=0pt,fill=white, minimum width=5cm, minimum height=1.5cm, align=center},
      miniblock/.style={draw,inner sep=0pt,fill=white, minimum width=1.5cm, minimum height=.8cm, align=center, rounded corners=2pt, text width=1.4cm},
      trajblock/.style={draw,rounded corners,minimum height=1.5cm,text width=3.35cm,align=left,font=\tiny,inner sep=3pt},
      linetext/.style={fill=#1, minimum height=1.5pt, minimum width=.8cm, inner sep=0},
    }
    \def\sep{1cm}
    \def\ssep{1cm}
    \begin{scope}
      \node [block, anchor=north] (b1) at (0,0) {\footnotesize{Experience Collecting}};
      \node [block, anchor=north] (b2) at ([yshift=-\sep]b1.south) {\footnotesize{Skill Generation}};
      \node [block, anchor=north] (b3) at ([yshift=-\sep]b2.south) {\footnotesize{Skill Bank}};
      \node [block, anchor=north] (b4) at ([yshift=-\sep]b3.south) {\footnotesize{Skill-Augmented RL Training}};
      \node [block, anchor=north] (b5) at ([yshift=-\sep]b4.south) {\footnotesize{Recursive Skill Evolution}};

      % \node [anchor=south] (b6) at ([yshift=\sep]b5.north) {\LARGE{$\cdots$}};
      \draw [->] (b1.south) -- (b2.north);
      \draw [->] (b2.south) -- (b3.north);
      \draw [->] (b3.south) -- (b4.north);
      \draw [->] (b4.south) -- (b5.north);
      % \draw [->] (b5.north) -- (b6.south);

      \scriptsize
      \node [anchor=north west, text width=7.6cm] (n1) at ([xshift=\ssep]b1.north east) {Collect interaction trajectories from the environment.\\};
      \node [anchor=north west,trajblock] (n12) at ([yshift=-0.1cm]n1.south west) {
        \textbf{Successful trajectory}\\
        Task: solve $2x+3=11$.\\
        Thought: subtract $3$, then divide by $2$.\\
        $\cdots$ \\
        Answer: $x=4$.
      };
      \node [anchor=west,font=\small] (n1dots) at ([xshift=0.15cm]n12.east) {$\cdots$};
      \node [anchor=west,trajblock] (n13) at ([xshift=0.15cm]n1dots.east) {
        \textbf{Failed trajectory}\\
        Task: solve $2x+3=11$.\\
        Thought: divide by $2$, then subtract $3$.\\
        $\cdots$ \\
        Answer: $x=2.5$.
      };
      \node [anchor=south east,font=\large,text=green!55!black] at ([xshift=-0.05cm,yshift=0.02cm]n12.south east) {$\checkmark$};
      \node [anchor=south east,font=\large,text=red!65!black] at ([xshift=-0.05cm,yshift=0.02cm]n13.south east) {$\times$};

      \draw [dashed] ([xshift=0.8cm,yshift=0.1cm]b2.north east) -- ([xshift=9cm,yshift=0.1cm]b2.north east);
      \node [anchor=north west, text width=7.6cm] (n2) at ([xshift=\ssep]b2.north east) {Generate reusable skills from collected trajectories.\\};
      \node [anchor=north west, text width=] (n21) at (n2.south west) {Successful trajectories};
      \node [anchor=west, text width=] (n22) at ([xshift=.2cm]n21.east) {$\rightarrow$~~Skill Principles};
      \node [anchor=north west, text width=] (n23) at (n21.south west) {Failed trajectories};
      \node [anchor=north west, text width=] (n24) at (n22.south west) {$\rightarrow$~~Failed Lessons};

      \draw [dashed] ([xshift=0.8cm,yshift=0.1cm]b3.north east) -- ([xshift=9cm,yshift=0.1cm]b3.north east);
      \node [anchor=north west, text width=7.6cm] (n3) at ([xshift=\ssep]b3.north east) {Construct a hierarchical skill library.};
      \node [anchor=north west, text width=7.7cm,draw,rounded corners,minimum height=0.72cm,align=left] (n31) at (n3.south west) {};
      \node [anchor=west,text width=2.55cm,align=center] (n311) at ([xshift=0.15cm]n31.west) {\textbf{General Skills}};
      \node [anchor=west,text width=4.8cm,align=left,font=\tiny] (n312) at ([xshift=0.15cm]n311.east) {Use algebraic invariants to transform equations step by step.};
      \node [anchor=north west, text width=7.7cm,draw,rounded corners,minimum height=0.72cm,align=left] (n32) at ([yshift=-0.1cm]n31.south west) {};
      \node [anchor=west,text width=2.55cm,align=center] (n321) at ([xshift=0.15cm]n32.west) {\textbf{Task-specific Skills}};
      \node [anchor=west,text width=4.8cm,align=left,font=\tiny] (n322) at ([xshift=0.15cm]n321.east) {For linear equations, isolate the variable before computing its value.};

      \draw [dashed] ([xshift=0.8cm,yshift=0.1cm]b4.north east) -- ([xshift=9cm,yshift=0.1cm]b4.north east);
      \node [anchor=north west, text width=7.6cm,align=left] (n4) at ([xshift=\ssep]b4.north east) {Retrieve relevant skills then provide retrieved skills to the agent.
        Optimize the skill-augmented policy with RL.};
      \draw ([yshift=-0.1cm]n4.south west) node (n41) [anchor=north west, text width=1.3cm,draw,rounded corners,minimum height=0.8cm,align=center] {Task}
      ([xshift=0.60cm]n41.east) node (n42) [anchor=west, text width=1.3cm,draw,rounded corners,minimum height=0.8cm,align=center] {Retrieving \\ Skills}
      ([xshift=0.60cm]n42.east) node (n43) [anchor=west, text width=1.3cm,draw,rounded corners,minimum height=0.8cm,align=center] {Agent}
      ([xshift=0.60cm]n43.east) node (n44) [anchor=west, text width=1.45cm,draw,rounded corners,minimum height=0.8cm,align=center] {Computing Rewards};
      \draw[->] (n41.east) -- (n42.west);
      \draw[->] (n42.east) -- (n43.west);
      \draw[->] (n43.east) -- (n44.west);
      \draw[->,dashed]
        ([yshift=-0.08cm]n44.south) .. controls +(down:0.35cm) and +(down:0.35cm) ..
        ([yshift=-0.08cm]n43.south);

      \draw [dashed] ([xshift=0.8cm,yshift=0.1cm]b5.north east) -- ([xshift=9cm,yshift=0.1cm]b5.north east);
      \node [anchor=north west, text width=7.6cm,align=left] (n5) at ([xshift=\ssep]b5.north east) {Analyze failure trajectories during training.
        Generate new skills or refine existing skills.};
      \node [anchor=north west, text width=6.5cm,draw,dashed,rounded corners,minimum height=1cm,align=left] (n51) at (n5.south west) {};
      \node [anchor=west,text width=2cm,align=center] (n52) at ([xshift=0.2cm]n51.west) {\textbf{Outcome}};
      \path (n52.east) node(n53) [anchor=west, text width=1.5cm,draw,rounded corners,minimum height=0.6cm,align=center] {Adding New Skills}
      ([xshift=0.5cm]n53.east) node(n54) [anchor=west, text width=1.5cm,draw,rounded corners,minimum height=0.6cm,align=center] {Refining Old skills};
      \draw ([xshift=0.1cm]n53.south east) -- ([xshift=-0.1cm]n54.north west);
    \end{scope}
  \end{tikzpicture}
\end{center}
