Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Four-in-a-row (FlashPascal program)

  1. #11
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Hey nice work! I like the nice sleek clean look to your screenshots.

    Any interest in the current PGD Challenge?

    A lot of game developers from all skill levels really enjoy taking part and it doesn't even have to be overly complex either. Though many do try.

    Keep making games.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #12
    Quote Originally Posted by Dan View Post
    any way to increase the difficulty?=)
    On Delphi About there is an interesting article about adding Artifical Intelligence to games. Article shows how to make "self learning AI" in Nepali game named "GATTA TIPNE KHEL" (meaning pebble picking game).
    http://delphi.about.com/od/gameprogr...gamesample.htm
    It would be posiible to implement similar approach into "Four in a row" game which would make game harder and harder the more you play, making it almost unbetable at the end.

  3. #13
    Hello! I would like to present the new version of my FlashPascal Four-in-row. The interface has been remade. The engine is the one (with small adaptations) I used in my Lazarus project.

    You can play the game on line. It should detect the local language (limited to english, german and french) and display the appropriate messages.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Roland Chastain; 18-04-2014 at 03:51 PM.

  4. #14
    Is it just my opinion or you also did some work on AI making it smarter?

  5. #15
    Quote Originally Posted by SilverWarior View Post
    Is it just my opinion or you also did some work on AI making it smarter?
    Indeed, I remade the AI. I hope I made it better.

    The evaluation procedure is more precise. I use an array of all good sequences. Each sequence found increase the result.

    Code:
    const  motifs: array[0..13, 0..1]of string = (
        ('OOOO', 'XXXX'),
        ('OOO.', 'XXX.'),
        ('.OOO', '.XXX'),
        ('OO.O', 'XX.X'),
        ('O.OO', 'X.XX'),
        ('OO..', 'XX..'),
        ('O.O.', 'X.X.'),
        ('O..O', 'X..X'),
        ('.O.O', '.X.X'),
        ('..OO', '..XX'),
        ('O...', 'X...'),
        ('.O..', '.X..'),
        ('..O.', '..X.'),
        ('...O', '...X')
      );
    
    
    const
      demiDroites: array[0..24, 0..3] of integer = (
        (1, 1, +1,  0),
        (1, 2, +1,  0),
        (1, 3, +1,  0),
        (1, 4, +1,  0),
        (1, 5, +1,  0),
        (1, 6, +1,  0),
        (1, 1,  0, +1),
        (2, 1,  0, +1),
        (3, 1,  0, +1),
        (4, 1,  0, +1),
        (5, 1,  0, +1),
        (6, 1,  0, +1),
        (7, 1,  0, +1),
        (1, 1, +1, +1),
        (1, 2, +1, +1),
        (1, 3, +1, +1),
        (1, 4, +1, -1),
        (1, 5, +1, -1),
        (1, 6, +1, -1),
        (7, 1, -1, +1),
        (7, 2, -1, +1),
        (7, 3, -1, +1),
        (7, 4, -1, -1),
        (7, 5, -1, -1),
        (7, 6, -1, -1)
      );
    
    
    function tClasseGrille.Points(const aPion: char): integer;
    var
      i, j, k, l: integer;
      x, y: integer;
      segment: string;
    begin
      result := 0;
      l := Ord(aPion = BLANC);
      
      for i := Low(demiDroites) to High(demiDroites) do
      begin
        x := demiDroites[i, 0];
        y := demiDroites[i, 1];
        
        segment := '       ';
        
        j := 1;
        repeat
          segment[j] := grille[x, y];
          Inc(x, demiDroites[i, 2]);
          Inc(y, demiDroites[i, 3]);
          Inc(j);
        until (x < UN) or (x > SEPT) or (y < UN) or (y > SIX);
        
        for j := Low(motifs) to High(motifs) do
          if Pos(motifs[j, l], segment) > 0 then
          begin
            case j of
              0:
                k := 75000;
              1..4:
                k := 2500;
              5..9:
                k := 50;
              else
                k := 1;
            end;
            Inc(result, k);
          end;
      end;
    end;
    Last edited by Roland Chastain; 19-04-2014 at 07:14 AM.

  6. #16
    Quote Originally Posted by Roland Chastain View Post
    Indeed, I remade the AI. I hope I made it better.
    It made it much harder. So far after about a dozen plays I haven't won even once. Lost two times and the rest times resulted in draw.
    But now the AI moves seems ... artificial. When you are playing AI doesen't just prevent you from winning but on my opinion prevent you even from coming close to winning.
    In all my lays I havent managed to reach a point where I would have tre in a row and AI would be forced to block the fourth one. AI simply folows certain path were it even prevents you to prepare any posible winning situation. And this is a joy killer.

  7. #17
    Quote Originally Posted by SilverWarior View Post
    AI simply follows certain path were it even prevents you to prepare any posible winning situation.
    Yes, it's a very good observation.

    Code:
        if Max(a) >= 2500 then
          result := IndexOf(a, Min(a))
    The a variable is an array of the maximal opponent's score at next move. And 2500 means three stones aligned.

    Quote Originally Posted by SilverWarior View Post
    And this is a joy killer.
    Yes, I see what you mean. I will keep it in mind. Anyway thank you for trying my program and for your instructive report.
    Last edited by Roland Chastain; 19-04-2014 at 10:19 AM.

  8. #18
    All you have to do is add some randomization into your AI calculations which would alow it to make some unsafe move every now and then. This would make AI moves to feel omre human.

    If you need someone to playtest and analyze your game I'm usually up for it. You would be surprised how much I have learned this way.

  9. #19
    hasn't been able to beat me even once, so still needs more improvement

  10. #20
    Quote Originally Posted by SilverWarior View Post
    All you have to do is add some randomization into your AI calculations which would alow it to make some unsafe move every now and then. This would make AI moves to feel more human.

    If you need someone to playtest and analyze your game I'm usually up for it. You would be surprised how much I have learned this way.
    Thank you for your suggestion and for your willingness to help.

    Quote Originally Posted by Dan View Post
    hasn't been able to beat me even once, so still needs more improvement
    Thank you for testing. I hope I will improve it soon.

    Happy Easter!

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •