stevegrossi / sengoku

An online Risk-like game built with Elixir and Phoenix LiveView
https://www.playsengoku.com/
57 stars 3 forks source link

Make AI less procedural #15

Open stevegrossi opened 6 years ago

stevegrossi commented 6 years ago

Currently, the AI is very procedural: if X is true, then do Y, etc. It does an okay job at optimizing for itself, but doesn't attempt to play against other players. This lets other players run away with the game.

What I think would be more interesting/effective is to

This was an interesting paper on more-or-less this approach: http://ai.cs.unibas.ch/papers/theses/luetolf-bachelor-13.pdf

yakryder commented 6 years ago

I like it

yakryder commented 6 years ago

If we only look at the moves available in the current turn, I don't think there will be too many. Going deeper into the future would make the AI smarter, but could also be computationally infeasible.

So just as a creatively stimulating pipe dream -- I'm not proposing we feasibly do this -- to make calculating a ton of moves ahead more feasible, you could branch supervisors into timelines.

Let's say next move, the computer might attack territory 5 or territory 6. You start a supervising process to create the possible outcomes of the attack for territory 5 and another for the attack on territory 6. Each one of those is in turn spinning up child processes representing the possible outcomes of those decisions. Each child outcome process or group of child outcome processes has a sibling or parent evaluation process it reports to. Those evaluation processes pass only the best outcomes up the chain, and at the top level we have some criteria for evaluating picking the timeline with ideally the highest probability of the best state outcomes.

Anyway that might already be what you're thinking and I've only laid it out in broad strokes, but Elixir seems in principle extremely well suited for building AIs.

yakryder commented 6 years ago

Also, if the paper already says what I just said but better, I didn't read it yet. On the list :)

stevegrossi commented 6 years ago

So just as a creatively stimulating pipe dream

No, I was thinking the same thing! I think you're right that this is the kind of thing OTP would be perfect for. With the Task and Task.Supervisor modules we could pretty easily fan out potential-move-evaluation across multiple processes (taking advantage of concurrency) and have them report back and—who knows—maybe looking a couple moves ahead won't take eons and we'd have a pretty smart AI on our hands. I can't say I think more than a move or two ahead myself 😁

stevegrossi commented 6 years ago

I think the paper only looked at one level of the currently possible moves, but then again the author wasn't using Elixir 🎉

stevegrossi commented 6 years ago

For reference, these are the "features" (things the AI optimizes for/against) from the paper:

Additional notes: