\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{parskip}
\usepackage{marvosym} %Lightning symbol
\usepackage[usenames,dvipsnames]{color}
\usepackage[hidelinks]{hyperref}
\renewcommand*{\familydefault}{\sfdefault}

\usepackage{bbm} %For \mathbbm{1}
%\usepackage{bbold}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw[step=1cm,gray,dotted] (-0.9,-0.9) grid (8.9,6.9);
    \foreach \x in {0,...,7} {
        \foreach \y in {0,...,5} {
            \draw[->] (\x,\y) -- (\x+0.9,\y);
            \draw[->] (\x,\y) -- (\x,\y+0.9);
        }
        \draw [->] (\x,6) -- (\x+0.9,6);
    }
    \foreach \y in {0,...,5}
        \draw [->] (8,\y) -- (8,\y+0.9);

    \draw (8,-0.2) node {$n_1$};
    \draw (-0.2,6) node {$n_2$};

    \draw (4,-0.5) node {step of path 1};
    \node[rotate=90,anchor=south,xshift=3cm,yshift=0.5cm] {step of path 2};

    \draw[fill,red] (0,0) circle (0.08);
    \draw[fill,red] (8,6) circle (0.08);

    \def\x{5};
    \def\y{3};
    \draw[fill,black] (\x,\y) circle (0.07);
    \draw[fill=white,draw=black] (\x+0.25,\y-0.26) rectangle +(0.5,0.5);
    \draw[fill=white,draw=black] (\x-0.50,\y+0.26) rectangle +(1.0,0.5);
    \draw (\x+0.5,\y) node {$p_j$};
    \draw (\x,\y+0.5) node {$1-p_j$};

    \def\x{2};
    \def\y{2};
    \draw[fill,black] (\x,\y) circle (0.07);
    \draw[fill=white,draw=black] (\x+0.25,\y-0.26) rectangle +(0.5,0.5);
    \draw[fill=white,draw=black] (\x-0.50,\y+0.26) rectangle +(1.0,0.5);
    \draw (\x+0.5,\y) node {$p_i$};
    \draw (\x,\y+0.5) node {$1-p_i$};

    \def\x{8};
    \def\y{1};
    \draw[fill,black] (\x,\y) circle (0.07);
    \draw[fill=white,draw=black] (\x-0.25,\y+0.26) rectangle +(0.5,0.5);
    \draw (\x,\y+0.5) node {$1$};

    \def\x{3};
    \def\y{6};
    \draw[fill,black] (\x,\y) circle (0.07);
    \draw[fill=white,draw=black] (\x+0.25,\y-0.25) rectangle +(0.5,0.5);
    \draw (\x+0.5,\y) node {$1$};
\end{tikzpicture}
\end{document}
