Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28
  1. #11
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    The main point of the db challenge was to see if it woke people up and made them more interested, as for example, Im no games coder, so, while making flee and snakes and ladders, life and all the rest of it, is doable, its not something that Id probably put heart and soul in, or if I was a lurker entice me out of the shadows, but Ive tried various things to see if I can find something to wake them and well they are like stone statues.. They maybe there, but there is no life or movement. The sign at the bottom says "Whens the next vtm?"

    With the db challenge there was a lot people could have done within the scope - such as auto update the last visit date on launch, maybe even investigated tying it into IE, so it tested the URLs gone to and updated it if it were in the db, or have an "add to watch list" or something on the toolbar..

    Making it prettier was just an excuse so that there really wasnt a person alive who even with no delphi experience couldnt have tried..

    The view counts on posts show people are lurking, but if they all remain silent an cant be counted, and maybe "dont have the time" what inspires us to continue stand there trying to give ideas and advice when all we see is nothing?
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  2. #12
    Join Date
    Oct 2003
    Posts
    242
    Now you have Three entrys
    I am still working on my entry for the monthly challenge but still not getting very far. Just can't get my head round how to have one class for all objects in world( and as usual i am flitting from one thing to another, Damn this internet thing for having so much that catches my attention). Still this week challenge got done. I have worked on others too, but not got finished like the snakes and ladders one.
    I personaly think the reason why there are few participants is that the Vtm's by buzz are to good ! and people set there sights to high on what they can achive on their own then get dispondent when it doesn't go as easy as they do following along. I know I keep trying to run before i can walk in delphi and it all goes wrong
    Also I don't think there are to many people here that are that much into programing anyway as maybe a graphical orientated mind and a problem solving logical mind don't often seem to go together.
    Also I don't think 'prizes' would make any difference, look at the last logo contest amount of entry's and that i would have thought was more in the line for artist's of which there are a lot of good one's here.

  3. #13
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    yep now I have 3.
    Thank you!
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  4. #14
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    OK, times up (was a short while ago but I didnt have a chance to post). I shall be posting the results in a bit - I have to step out later this evening so depending on how much and how far I get.. it maybe a few hours time.

    Watch this space!
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  5. #15
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    We had 3 entries.

    Dragonclaw1988, flk and Oryde, all who made fun life apps to watch, and are attached.

    I do apologise to dragonclaw as I have found a bug in your app which I failed to notice previously, which is if you take a position on the top row anywhere and make a shape of

    xo
    xx
    xx

    eg, the o is a missing hole, this remains stable in your game, but should not.

    flk's game (has a nice option to change the colours of the alive/dead cells, and allows the changing of the sizes although the timer isnt implemented, Im sure he'll fix it shortly, the "draw" option didnt seem to work either, but, I didnt specify it had to.

    As a result, I lastly come to Oryde's offering.
    I love this one. Why? He has some nice sliders at the top you can even fiddle with while it runs, he has all the options I asked for, and even a large grid at max speed still runs very smoothly.

    Therefore Id say Oryde is the winner! Congratulations.

    If its any consolation I made a basic one in c# (which ive been learning in my spare time at work, which isnt as easy as it sounds when you have thought police and a job to do) earlier today, mine is fixed settings on startup, but you can change those by command line, so you send it 4 parameters of cell size, number wide, number high and speed of refresh.. I confess I didnt get round to an ability to "draw on" my own shapes but then, as it turned out, I only spent 11 minutes 52 seconds (I didnt race, I started it when I started a phone call.. hehe) so its not very good.

    You can run mine as is or from a command line, if you do it from a command line the 4 parameters in order are: SizeofCell width height frequency

    so there you have it. Thats "life"
    Attached Files Attached Files
    Last edited by LizKimber; 10-24-2007 at 11:43 AM.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  6. #16
    Join Date
    Jan 2007
    Posts
    216
    Gratz to Oryde! Your app looks really clean and nice, the speed is also very good.


    I would love to know how you did the hole calculation of the next gen. I'll just post my algo really quick, maybe someone has an idea how to make it faster:
    Code:
    procedure TForm2.Game_running;
    Var
      X,Y,temp: Integer;
      a, b, c: TLargeInteger;
    begin
     while Running do
       begin       //One possibility to measure the time it takes to calc next gen
         QueryPerformanceFrequency(a);
         QueryPerformanceCounter(b);  
         Inc(Generation);
    
         //the Array Buffer1 will be stet so it's the same af the StringGrid
         for X := 0 to StringGrid1.ColCount do
         for Y := 0 to StringGrid1.RowCount do
           if StringGrid1.Cells[X,Y] = '1' then
             Buffer1[X,Y] := True
           else Buffer1[X,Y] := False;
    
      for X := 0 to StringGrid1.ColCount do
        for Y := 0 to StringGrid1.RowCount do
          begin
            temp := Cells_surrounding(X,Y);// returns how many cells are alive
             //less the 2 more then 3 cells AND cell alive ===> Death
            if ((temp < 2) OR (temp > 3)) AND (Buffer1[X,Y])  then
              StringGrid1.Cells[X,Y] := '0';
            // 2 or 3 cells AND cell alive ===> Cell lifes on
            if ((temp = 2) OR (temp = 3)) AND (Buffer1[X,Y])  then
              StringGrid1.Cells[X,Y] := '1';
            //3 cells and NOT alive ===> new life
            if (temp = 3) AND not (Buffer1[X,Y]) then
              StringGrid1.Cells[X,Y] := '1';
          end;
          Label2.Caption := IntToStr(Generation);
    
          QueryPerformanceCounter(c);
         // Display the time it took to calc
          ListBox1.Items.Add(IntToStr((c - b) * 1000 div a));
          Application.ProcessMessages;
       end;
    end;
    an here is the Cells_surrounding function
    Code:
    function TForm2.Cells_surrounding(X, Y: Integer): Byte;
    var
    I,J: Integer;
    begin
      Result := 0;
      for I := X-1 to X+1 do
        for J := Y-1 to Y+1 do
          begin
            if ((I <> X) OR (J <> Y)) AND
               (I > 0) AND (I <= 100) AND
               (J > 0) AND (J <= 100) AND
               (Buffer[I,J]) then
             Inc(Result);
          end;
    end;

  7. #17
    Join Date
    Sep 2006
    Posts
    18
    Well, mine is similar. I don't know how you made Cells_surrounding(X,Y), but I think it's also similar. I could guess that StringGrid is slowing down, I used Canvas to draw grid and cells.
    Giggity

  8. #18
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    My way to do it was to define a type such as

    Code:
    Tcells = array of array of boolean;
    Then you can do

    Code:
    var cells : tcells;
    and have a dynamic array of a dynamic array of cells.

    Then when you make a temp one you do your working into a temp one and just assign the current cells to be the temp cells in one line with

    Code:
    cells:=tmpcells;
    quick and painless.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  9. #19
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    In fact here is a quick and dirty solution - you can tell how long it took me by the time between posts (and Id like to point out Im talking with Adam in the background !!!)

    Code:
    unit Unit1;
    
    interface
    
    uses
      graphics, Classes, ExtCtrls,forms;
    
    type
      TCells = array of array of boolean;
      TForm1 = class(TForm)
        Timer1: TTimer;
        procedure FormCreate(Sender: TObject);
        procedure FormPaint(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
        cells :tcells;
        function CountNeighbours(x,y:integer) : integer;
      public
        { Public declarations }
      end;
    
      const XWIDTH = 100;
            YWIDTH = 100;
            CELLWIDTH = 5;
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    function TForm1.CountNeighbours(x, y: integer): integer;
    var i,j:integer;
    begin
      result:=0;
      for i := -1  to 1 do
        for j := -1 to 1 do
          if ((not ((i=0) and (j=0))) and (x+i>=0) and (y+j>0) and (x+i<XWIDTH) and (y+j<
            YWIDTH) and cells[x+i,y+j]) then inc(result);
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    var i,j:integer;
    begin
      randomize;
      setlength(cells,XWIDTH,YWIDTH);
      for i := 0 to XWIDTH-1 do
        for j :=0 to YWIDTH-1  do
          cells[i,j]:=random(100)>49;
    end;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var i,j:integer;
    begin
    for i := 0 to XWIDTH-1 do
      for j :=0 to YWIDTH-1  do
      begin
        if cells[i,j] then
          canvas.Brush.Color:=clred
        else
          canvas.Brush.Color:=Color;
        canvas.FillRect(rect(i*(CELLWIDTH+1),j*(CELLWIDTH+1),(i*(CELLWIDTH+1))+
          CELLWIDTH,(j*(CELLWIDTH+1))+CELLWIDTH));
      end;
    end;
    
    procedure TForm1.Timer1Timer(Sender: TObject);
    
    var tmpcells :tcells;
        i,j:integer;
        n : integer;
    begin
      setlength(tmpcells,XWIDTH,YWIDTH);
      for i := 0 to XWIDTH-1 do
      for j :=0 to YWIDTH-1  do
      begin
        n:=CountNeighbours(i, j);
        if (((n=2) and cells[i,j]) or (n=3) ) then
          tmpcells[i,j]:=true
        else
          tmpcells[i,j]:=false;
      end;
      cells:=tmpcells;
      paint;
    end;
    
    end.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  10. #20
    Join Date
    Oct 2003
    Posts
    242
    Nice work Oryde and Dragonclaw1988 would anyone care to post a link to your source files, as i am very interested to see how you made drawing dispaly so fast especialy Oryde. As i to started with a stringGrid but found it far too slow on drawing larger display sizes. So I went for direct drawing to forms canvas, which was still very slow on larger grids. Maybe that's why it appears that timer settings not working, when it actuallly is try minimum grid.I just had to make it miss out drawing frames at faster speeds depending on grid size or it got very confused.
    Also drawing the starting grid is working too. Does use a non intuitive method so thats why i aded a lot of hints on controls to show use.same with up down buttons for control settings. Still here is a link to my code if anyone interested

    http://www.myfilebin.com/userfiles/fik/life2.zip

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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