Skip to content

Commit

Permalink
Small changes to documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoVal committed Feb 14, 2016
1 parent 74d595e commit c091be1
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 44 deletions.
21 changes: 8 additions & 13 deletions build/ludorum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/ludorum.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/ludorum.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/ludorum.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/tutorial-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Pig.prototype.moves = function moves() {
};
```
The most complicated part would be to calculate the next state given a game state and a move. This is not because the game logic is complex in itself, but because it involves a die, which is a random variable. Simply put, if the player decides to roll the game state's `next` method must return a `Contingent` state. By default, this instances hold references to the state and moves that originated them. They also have a set of `Aleatory` variables. The values of these random variables (called `haps`) resolved the indetermination in the flow of the game. Once determined the actual value of these haps, the `next` method is called again on the original state with the same moves and the values for the haps. The `next` method will then calculate the actual next state.
The most complicated part would be to calculate the next state given a game state and a move. This is not because the game logic is complex in itself, but because it involves a die, which is a random variable. Simply put, if the player decides to roll the game state's `next` method must return a `Contingent` state. By default, this instances hold references to the state and moves that originated them. They also have a set of `Aleatory` variables. The values of these random variables (called `haps`) resolve the indetermination in the flow of the game. Once determined the actual value of these haps, the `next` method is called again on the original state with the same moves and the values for the haps. The `next` method will then calculate the actual next state.
In this case, the only random variable involved is a six-sided die, which is already defined in `ludorum.aleatories.dice.D6`. If `haps` are provided, the `next` method calculates a game state; else it builds a contingent state.
Expand Down
16 changes: 6 additions & 10 deletions src/Contingent.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ var Contingent = exports.Contingent = declare({
the `next` method for further details.
*/
constructor: function Contingent(haps, state, moves) {
if (haps) {
this.__haps__ = haps;
}
if (state) {
this.__state__ = state;
}
if (moves) {
this.__moves__ = moves;
}
this.__haps__ = haps || null;
this.__state__ = state || null;
this.__moves__ = moves || null;
},

/** A contingent state's `haps` are the equivalent of `moves` in normal game states. The method
Expand Down Expand Up @@ -86,10 +80,12 @@ var Contingent = exports.Contingent = declare({

// ## Utilities ################################################################################

/** Serialization and materialization using Sermat.
*/
'static __SERMAT__': {
identifier: 'Contingent',
serializer: function serialize_Contingent(obj) {
return [obj.__haps__ || null, obj.__state__ || null, obj.__moves__ || null];
return [obj.__haps__, obj.__state__, obj.__moves__];
}
}
});
3 changes: 1 addition & 2 deletions src/aleatories/Aleatory.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/** # Aleatory
Aleatories are different means of non determinism that games can use, like: dice, card decks,
roulettes, etc. They are used by `Aleatoric` game states.
roulettes, etc. They are used by `Contingent` game states.
*/
var Aleatory = exports.aleatories.Aleatory = declare({
/** The base class implements an integer uniform random variable between a minimum and maximum
value (inclusively).
+
*/
constructor: function Aleatory(min, max) {
switch (arguments.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/aleatories/Dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ var dice = aleatories.dice = {
}).sum();
}
}
}; //// declare Dice.
}; // dice.
21 changes: 8 additions & 13 deletions tests/lib/ludorum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/lib/ludorum.js.map

Large diffs are not rendered by default.

0 comments on commit c091be1

Please sign in to comment.