Hydrodynamical simulations of cluster formation with central AGN heating