swap-n-pop icon indicating copy to clipboard operation
swap-n-pop copied to clipboard

Write an AI

Open omenking opened this issue 7 years ago • 1 comments

  • [ ] #122 decouple stack from playfield to be able to run simulations in isolation
  • [ ] #123 scoring the cost to operate a move, swap etc...

Considerations

I had intended to place the AI logic here renderer/components/ai.js

For each playfield it will create this AI component

this.ai = new ComponentAi()

And when the playfield is being created it checks if it has_ai passing in the playfield and cursor. Allowing the AI to see its entire stack via playfield.stack(), and manipulate the playfield_cursor.

if (this.has_ai) { this.ai.create(this, this.cursor) }

All the AI has do to is trigger movement commands per frame on update after analyzing the stack.

this.cursor.mv_up();

Every frame inputs are pushed onto an array which is stored in renderer/core/inputs. Core Inputs are loaded in the stage so for vs its in states/mode_vs

mode_vs will update core/inputs which well them pack the inputs and send them via the server.

omenking avatar Nov 30 '17 19:11 omenking

I think possibly the stack needs to be decoupled from the playfield, so you could run simulations on the stack to look forward for chains and combos.

Writing an AI would just require brute-forcing and likely just scoring each move,

We have a Stack controller though this is for initializing the stack. This controller could be enriched to be where the stack related logic should go.

omenking avatar Nov 30 '17 21:11 omenking