G is the centroid of the triangle and 2/3 of the distance from the vertex at B to the midpoint of CD at point B.
Since BG is 2/3 of the distance from B to D, so BG is 2/3 of BD.
BG = 2/3 * BD
x + 3 = 2/3 (4x - 18)
3x + 9 = 2 (4x - 18)
3x + 9 = 8x - 36
45 = 5x
x = 9