Add object works with logic brinks but cannot figure out the scripting I am making tic tac toe using cubes and spheres rather than Xs and Os. I have 9 empties corresponding to the spaces on the 3 x 3 grid. I can make it work using logic brick, but not with py script. The cubes and spheres only appear at the coordinates where the sample objects are on the inactive scene layer. I have tried everything I can think of.

import bge

def main():

    scene = bge.logic.getCurrentScene()
    cont = bge.logic.getCurrentController()
    player = cont.owner
    keyboard = bge.logic.keyboard

    key1 = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.ONEKEY]
    key2 = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.TWOKEY]

    pad3 = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.PAD3]
    pad4 = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.PAD4]

    # objects = bge.logic.getCurrentScene().objects
    # object_cube = objects["Cube"]
    # object_sphere = objects["Sphere"]   ### no error code but breaks the game

    if key1:
        player.scene.addObject('Cube')
        # position = mathutils.Vector([5, 5, 0]) ### all things I've tried
        # gameObject.worldPosition('Cube') = position
        # addObject.worldPosition = [5, 5, 0]     
        # Cube.worldPosition = [5, 5, 0]
        # player.scene.addObject.worldPosition = [5, 5, 0]

    elif key2:
        player.scene.addObject('Sphere')        

    elif pad3:
        player.scene.addObject('Cube')

    elif pad4:
        player.scene.addObject('Sphere') 


main()
Not sure about game engine but you can simply set the location of an object in a regular scene.

object.location = Vector([1,2,3])