Skip to content

Commit

Permalink
Update: AI Runner Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbyte committed May 31, 2015
1 parent 7893336 commit ffb99b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ http://knsv.github.io/mermaid/live_editor/
-->


# AI Runner. Technical Spec.
# AI Runner. Spec.

## Problem.
The AI runner should execute all the functions that the players provided, with the current user state, all user states, and game enrivonment as arguments.

## Constraints.
* Prevent the user functions to modify anything except itself.
* Catch executions errors, and simply return `null` as response to the Game Core.
* Detect if any functions gets stuck in an infinite loop, and return `null` as response.

## Hypothesis.
We can run the functions as WebWorkers because:
Expand All @@ -131,6 +132,9 @@ We can run the functions as WebWorkers because:

The game is designed to make irrelevant the order of execution of the AIs. So we are safe running all this asynchronous.

## Solution.
To prevent the functions to take so much time thinking (probably because an infinite loop), we will create an array of `null`s, where we will put the responses of the workers as they arrive. If `X` seconds passes (enough time to think for almost everything, except infinite loops, of couse) then we will pass the `null`ified response of that worker, and the Game Core will kill that player.

![](assets/airunner-blackbox.png)
<!---
sequenceDiagram
Expand All @@ -146,4 +150,4 @@ Note left of AI Runner: When all the workers<br/>responds, or the<br/>countdown
AI Runner->> Game Core: Results
http://knsv.github.io/mermaid/live_editor/
-->
-->

0 comments on commit ffb99b2

Please sign in to comment.