Jump to content

Grid of black/white squares (Game of Life)


Recommended Posts

I've been wanting to have a go at writing the game of life for a while now, and after some rough planning and psuedocode, I'd like to give it a go in autoit. The main problem I have is I'm not sure how to create the squares. The only experience I have with creating GUIs is just the bog-standard Windows controls. Any suggestions on this?

Also, has anyone on here tried this before? I did a quick search but nothing relevant came up. Just curious.

Edited by rabbitkillrun2
Link to comment
Share on other sites

Hi,

You could use Labels to make a grid and set the color of the labels as needed.

#include <StaticConstants.au3>

HotKeySet("{ESC}", "_Exit")

Global $x, $y, $iSqare[442]

GUICreate("test", 420, 420)
For $i = 1 To 441
    $iSqare[$i] = GUICtrlCreateLabel("", $x, $y, 20, 20)
    If Not Mod($i, 2) Then
        GUICtrlSetBkColor($iSqare[$i], 0x000000)
    Else
        GUICtrlSetBkColor($iSqare[$i], 0xffffff)
    EndIf
    If Not Mod($i, 21) Then
        $x = 0
        $y += 20
    Else
        $x += 20
    EndIf
Next
GUISetState()

While 1
    Sleep(1000)
    For $i = 1 To 441
        GUICtrlSetStyle($iSqare[$i], $SS_GRAYFRAME)
    Next
    Sleep(1000)
    For $i = 1 To 441
        GUICtrlSetStyle($iSqare[$i], $GUI_SS_DEFAULT_LABEL)
    Next
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Sorry I haven't any clue about the game your wanting to replicate, sounds like a lot of math.

My math skill is minimal so it's not something I could approach myself :blink:

Cheers

Link to comment
Share on other sites

Oh, boy. You have a hell of a job at your hands! While ago I was involved in Game Of Life development in C and we kept running into serious performance troubles every now and then with grids larger than 100x100 (and this is where GOL starts being interesting). A powerful CA will be difficult enough in AutoIt as it lacks native hashing routines and then comes GUI... well, GUI with a static grid isn't actually that complicated but let me give you this advice: don't use any controls for cells - you would produce a huge drain of system resources, take something like GraphGDIPlus or OpenGL to draw the grid directly.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

Link to comment
Share on other sites

Thanks for the replies guys. No, I won't be using controls for cells, but that's the only experience I have, so I wasn't sure of the alternatives. I'll look into GraphGDIPlus and OpenGL.

And thanks for the link to someone else's attempt.

A side question, in case anyone here has experience: Does anyone know of any good online tutorials or other help to begin learning C?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...