Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Mario

hello, i am trying to create a simple ki.

my game flow is something like that:

if (currentPlayer == human) {
 var card = letHimPickACard();
 checkRules(card);
} else {
  for(var i=0; i< allPossibilities; i++) {
    saveEntities();
    var card = getCard[i];
    checkRules(card);
    if(points >= bestPoints) {
       bestPoints = points;
       bestChoice = i;
    }
    restoreEntities;
  }
  var card = getCard[bestChoice];
  checkRules(card);
}

iam stuck at save and restore ig.game.entities...

checkRules change some entities (if action cards activated) and after the first simulation the entities are at a wrong state for the next simulation

i tried $.extend(true, {}, ig.game.entities); from jquery and a self written recursive solution, because ig.Array.copy should not work with ig.Classes

has anyone a hint for me? i will write further explaination if necessary...

thx mario

1 decade ago by Joncom

Further explanation might be helpful. I'm not sure what "a simple ki" even is.

What do you mean when you say saving and restoring entities?

1 decade ago by Mario

sorry my misstake: ki is german for AI (artificial intelligence)

this picture shows a situation: http://imageshack.us/f/703/screene.gif/

AI test:
- state A
- points: Player1 = 2 -- AI = 0 --> [-2]
- AI set water at position (2 to 3) --> [1]
- [1] is better then [-2] --> bestChoice = water
- state B
- AI set fire at position (2 to 2) --> [0] *
- [0] isnt better then [1]
- state C
- AI test earth and air....

* could be a wrong result, because playfield isnt at state A(see picture)

so i have to memory state A and after simulation state B should be reset to state A

1 decade ago by Mario

thx for trying :)

i helped myself by reprogramming the checkRules function.

it works now with an own object and the ig.game.entities will be copied for read only purpose.
Page 1 of 1
« first « previous next › last »