Results 1 to 10 of 22

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Hello gentlemen !

    I have rewritten my Four-in-a-row. The internal functions are new. The interface is almost the same, except that there are checkboxes to select the game mode.

    If ever you wish to compile the source code, you have to dowload separately the small library I used for checkboxes.

    Best regards.

    Roland
    Attached Images Attached Images
    Last edited by Roland Chastain; 22-08-2013 at 08:15 PM.

  2. #2
    any way to increase the difficulty?=)

  3. #3
    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





  4. #4
    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.

  5. #5
    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.

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

  7. #7
    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.

  8. #8
    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.

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
  •