Search Unity

AI learning resources

Discussion in 'Scripting' started by padomu, May 2, 2014.

  1. padomu

    padomu

    Joined:
    Sep 8, 2013
    Posts:
    51
    Hi,

    I need to get infos about building AI fora game like chess which also has bonus elements which gives you bonus stats. Special moves etc. E.g. there are 40 extra bonus special cards but the enemy doesn't know what cards you got. So I'd have to predict, which blasts the precalculation like chess itself does anyway.

    So, I do have "full" information (or half-full, because I have to predict), does minimax and alpha beta work for this?

    Please give a few resources.

    Thanks!
     
  2. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Can you not perform all randomization ahead of time? That way the events will still seem random to the player, yet the information is all known ahead of time allowing for useful alpha-beta testing.
     
  3. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    For instance:
    Code (csharp):
    1.  
    2. public sealed class SpecialMoveDispenser {
    3.     private List<SpecialMove> _moves = new List<SpecialMove();
    4.  
    5.     public int NextMoveIndex { get; set; }
    6.  
    7.     public SpecialMove NextMove() {
    8.         if (_moves.Count < NextMoveIndex)
    9.             _moves.Add(PickRandomSpecialMove());
    10.         return _moves[NextMoveIndex++];
    11.     }
    12.  
    13.     public void AcceptState() {
    14.         _moves.RemoveRange(0, NextMoveIndex);
    15.         NextMoveIndex = 0;
    16.     }
    17. }
    18.  
    And then use this to 'randomly' dispense moves and revert to previous states as needed:
    Code (csharp):
    1.  
    2. // Fetch next move.
    3. int backupNextMove = dispenser.NextMoveIndex;
    4. SpecialMove move = dispenser.NextMove();
    5.  
    6. // Cancel and restore to state of another node in your tree.
    7. dispenser.NextMoveIndex = backupNextMove;
    8.  
    9. // Accept move!
    10. dispenser.AcceptState();
    11.  
    Not tested, but hopefully you will see the basic concept.