def generate_payload(query):
    """Generate the payload for Gamepedia based on a query string."""
    payload = {}
    payload["action"] = "query"
    payload["titles"] = query.replace(" ", "_")
    payload["format"] = "json"
    payload["formatversion"] = "2"  # Cleaner json results
    payload["prop"] = "extracts"  # Include extract in returned results
    # Only return summary paragraph(s) before main content
    payload["exintro"] = "1"
    payload["redirects"] = "1"  # Follow redirects
    payload["explaintext"] = "1"  # Make sure it's plaintext (not HTML)
    return payload