awiggs / chip-gr8

Chip-Gr8
http://chipgr8.io
MIT License
4 stars 1 forks source link

Mixing Human/AI Interaction #35

Closed ejrbuss closed 5 years ago

ejrbuss commented 5 years ago

Currently there is no good method for mixing human and AI interactions. Mixed interaction may be desirable in the case of a competitive game, such as two player pong. A proposed solution is to have the go function in Chip8VM (chipgr8/vm.py) take a function that is called every loop iteration to allow for AI interaction. Usage of the API would look like:

def aiFunc(vm):
    ...

vm = init(ROM=pong.ROM, display=Trrue)
vm.go(aiFunc)

This solution has two unsolved problems. First, there is no easy way to reconcile human and AI input. Every call to vm.input will clear prior inputs (ie. the AI does not know what buttons the player is holding down, and vice versa). So there needs to be some means of combining the input from both agents.

The second problem is that having an AI act every step may not be ideal. An AI of any complexity is likely to cripple the game performance whilst also reacting to nearly identical VM states each step (as a single step changes the VM state very little). In the AI-only API there is already a proposal for sampleRate, which indicates how many steps occur between AI interactions, ideally this API would allow for a similar parameter.

@jbarlo as input master, if you could look into this issue, that would be appreciated.

jbarlo commented 5 years ago

Commit added. As mentioned in the commit, some added parameters could/should be moved to the init function.