Jump to content

IX v1.04: a Strategy Game like Chess


Recommended Posts

Yes, another game. This one is a board game.

Only three piece types, only nine rules. This is very easy to learn. Very hard to master.

Illustration of Game in progress:

Posted Image

If you like Chess you will like this.

Enjoy

Version 1.03

The 'Set' option has been removed, making a play only two clicks.

In-game player prodding has been added.

Some bitmaps have been corrected.

Version 1.04

Resignation option added.

Movement Hints added.

GUI to set game options added.

Sound off option added.

Bitmaps have changed. Reinstall Images\ or things won't quite look correct.

IX v1.04 files

Edited by Topher

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

Quite professionally made. Code looks good on the insides too.

Also a nice example of when AutoIt array copy mechanism is actually useful:

$Board = $holdBoard
$Color = $holdColor

One tip, if you set up your constants like this:

Global Const $Tribe = 2^0
Global Const $Clan   = 2^1
Global Const $Hunter   = 2^2  ; used only for comparisions
Global Const $HunterN  = 2^3
Global Const $HunterS  = 2^4
Global Const $HunterE  = 2^5
Global Const $HunterW  = 2^6
Global Const $HunterNE = 2^7
Global Const $HunterNW = 2^8
Global Const $HunterSE = 2^9
Global Const $HunterSW = 2^10
Global Const $Red     = 2^11
Global Const $Green = 2^12

And then repair Func PieceName() to not think that $Red is always 0.

Then for each piece, you are able to check more easily what that piece is with BitAND. For example your Func CheckPiece($piece) becomes:

Func CheckPiece($piece)
    Return BitAND($piece, $AdjustSide)
EndFunc

You can use the same check for other pieces.

Attached a copy of the script for your convenience. So you can see that it works, without going through the painful process of updating all the code. I must say that I really like your solution as well, but I am a little surprised it worked. Usually a system like that is too rigid when your project grows, but you managed to be smart with it and it works. So, kudos! For using a solution most programmers don't use and managing to make it work.

IX.au3

Edited by Manadar
Link to post
Share on other sites

Thanks for the praise.

It took me a little bit to see the advantage to your changes but now I have incorporated the changes.

Started work on the player against the computer version today. That is going to take a long while but I think I have an approach.

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

I found an error introduced on your change.

During the clan split the hunteradjust routine no longer properly removed the color and so errored out.

I have fixed this as well as fixed a few other minor problems.

Edited by Topher

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

I suppose it could be coded to simply have the undo option until the other player moves.

It would streamline things.

Thank you. I will try to code that.

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

That reminds me. I think it would be a good idea to add labels which users turn it is and what they have to do to play that turn. Right now it relies mostly on audible cues and not everyone wants to hear the beep the whole time. Something like:

Red, it's your turn

Click on one of the red pieces on the board to select them, then select an action: Move by clicking on the board, turn or split by clicking the buttons on the side.

I also wanted to show the total number of turns played somewhere too. Right now it shows them at game over (but I haven't debugged that yet so it may crash or be incorrect).

Link to post
Share on other sites

@czardas That really streamlined play. Thank you

@Manadar I wanted to code that myself (so I did).

The suggestion of in game instructions is a good one. I'll have it ready and uploaded by tomorrow evening.

Edited by Topher

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

Sorry for the delay, life got in the way.

Version 1.03

The 'Set' option has been removed, making a play only two clicks.

In-game player prodding has been added.

Some bitmaps have been corrected.

The update is in the original post.

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

I have to agree, it's much better now. I haven't had a lot of time to study the game, but thanks for sharing it. I do like chess and there are a few free chess programs around. I generally use a chess program called winboard. Perhaps you could add some similar features like highlighting the last move, or available moves. Not that it needs more features. I'm just thinking out loud. Very nice! ;)

Edited by czardas
Link to post
Share on other sites

Perhaps you could add some similar features like highlighting the last move, or available moves.

Replaying the last move seems like a coding mess.

The other I have put into the next version, thank you.

Posted Image

I have to write a small GUI to control the optional variables that I have been dragging my feet on.

If you (or anyone) have some constructive ideas for additions please let me know.

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

Version 1.04

Resignation option added.

Movement Hints added.

GUI to set game options added.

Sound off option added.

Bitmaps have changed. Reinstall Images or things won't quite look correct.

Minor bugs corrected.

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

Really nice work on this.. the images and functionality are well done.

Some thoughts for improving it:

-Integrate the starting GUI into a menu, this would let the user start right at the main GUI (better flow imo) and allow them to make changes during game. The menu could have a help and about section and whatever other fun stuff menus have.

-This kind of goes with above: give the user new game option.. I didn't look at your code so I don't know how easy that would be to do.

-It sort of looks like you redraw the board after every move, that could probably be avoided.. or I'm just seeing things.

-I sort of think there should be a easier way to rotate the smallest pieces rather than all the buttons, but I can't think of one right now.. if those buttons could be removed you could put the count and resign button below the board to shrink up the amount of empty space on the left and right sides.. it feels a bit desolate.

-AI would be fun, and a lot of work..

I enjoyed playing around with this.

Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to post
Share on other sites

-Integrate the starting GUI into a menu, this would let the user start right at the main GUI (better flow imo) and allow them to make changes during game. The menu could have a help and about section and whatever other fun stuff menus have.

I'm not very good with menus so I have been dragging my feet. But you are correct and I will work on it.

-It sort of looks like you redraw the board after every move, that could probably be avoided.. or I'm just seeing things.

Worse I have to draw both the backing square and then the piece, guaranteeing flicker. But this would require so much extra coding to lower it to just the pieces in involved that I am content to live with the flicker.

-I sort of think there should be a easier way to rotate the smallest pieces rather than all the buttons, but I can't think of one right now.. if those buttons could be removed you could put the count and resign button below the board to shrink up the amount of empty space on the left and right sides.. it feels a bit desolate.

I thought long and hard on that when designing the original setup and never did come up with another way. I am open to suggestions.

-AI would be fun, and a lot of work..

This has been one of my goals but I am stumped at how to go about it. I had a few ideas but after a lot of code it was just a mess.

I would also like to make it playable against another player on a different computer. I at least can learn (I hope) how to do that. This is what I am currently working towards. Currently lost in the jargon alone.

I enjoyed playing around with this.

This is my biggest goal, so glad I achieved it for you. ;)

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
Share on other sites

This has been one of my goals but I am stumped at how to go about it. I had a few ideas but after a lot of code it was just a mess.

I would also like to make it playable against another player on a different computer. I at least can learn (I hope) how to do that. This is what I am currently working towards. Currently lost in the jargon alone.

Do AI as a separate project. Make your program write via console the current board, that looks something like this:

.....
T...Y
.....
T...Y
.....

Make a legend:

. = Empty square

T = blue tribe

Y = red tribe

Then the AI spits out something like "B1->B2" or "B1->Split".

There are some caveats. Do you want me to prototype something?

Link to post
Share on other sites

Do AI as a separate project. Make your program write via console the current board, that looks something like this:

I am more stumped by the logic than the format.

[left][hr]

$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gianni
      ... Surfing the net my eye fell on a device called "Divoom".
      It reminded me of a little toy I liked to play when I went to kindergarten (more than 55 years ago... ), it was called "Chiodini colorati".
      So I made this little script to emulate it, ...maybe some kids will have fun playing with it.

      The attached zip file contains the script and also some "pixel art" files ready to be loaded.
      P.S.
      Thanks to @KaFu for it's _WinSetClientSize() function and to @InunoTaishou for it's CaptureWindow() function (references are in the script)
      #include <WinAPISysWin.au3> #include <File.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #cs ----------------------------------------- "Chiodini colorati" (colored thumb tacks) a little toy for the kids 16x16 pixel art sheet Programmed by Gianni Addiego - Italy December 2021 #ce ----------------------------------------- _Chiodini() Func _Chiodini() Local $aColors[16] = [0xffffff, 0xFF0000, 0xFF00FF, 0xFFC0CB, 0x964B00, 0xCD853F, 0xFF6600, 0xFFCC00, _ 0xFFFF00, 0xCCFF00, 0x00FF00, 0x228B22, 0x0000FF, 0x00FFFF, 0x7F7F7F, 0x000000] Local $iColor = $aColors[0], $sFileName, $aAzioni, $bOkToSave Local $aColori, $aChiodini, $GUIGetMsg, $hShowActiveColor Local $hGui = GUICreate("Chiodini colorati") $aColori = _GuiControlPanel("Button", 1, 16, 50, 20, 0, 0, 5, 0, 0, 1, True, "Colors") For $i = 1 To UBound($aColori) - 1 GUICtrlSetBkColor($aColori[$i], $aColors[$i - 1]) Next $aChiodini = _GuiControlPanel("Label", 16, 16, 20, 20, ($aColori[0])[11], 0, 3, 3, 1, 1, True, "") ; Local $aBackColors[UBound($aChiodini)] For $i = 1 To UBound($aChiodini) - 1 GUICtrlSetBkColor($aChiodini[$i], $iColor) $aBackColors[$i] = $iColor Next $iColor = $aColors[1] $aAzioni = _GuiControlPanel("Button", 4, 1, 80, 50, ($aColori[0])[11] + 0, ($aChiodini[0])[12], 0, 0, 5, 1, True, "") GUICtrlSetData($aAzioni[1], "Clear with color") GUICtrlSetData($aAzioni[2], "Load txt File") GUICtrlSetData($aAzioni[3], "Save txt File") GUICtrlSetData($aAzioni[4], "Save JPG") $hShowActiveColor = _GuiControlPanel('Label', 1, 1, 45, 30, 8, ($aColori[0])[12], 0, 0, 0, 0, True, "Active") GUICtrlSetBkColor($hShowActiveColor[1], $iColor) _WinSetClientSize($hGui, ($aChiodini[0])[11] + ($aColori[0])[11], ($aChiodini[0])[12] + ($aAzioni[0])[12]) ; GUISetState() ; --------- ; Main loop ; --------- While True $GUIGetMsg = GUIGetMsg() ; -------------------------------------------- ; scan all buttons to check if one was pressed ; -------------------------------------------- For $i = 1 To UBound($aColori) - 1 If $GUIGetMsg = $aColori[$i] Then $iColor = $aColors[$i - 1] GUICtrlSetBkColor($hShowActiveColor[1], $iColor) ContinueLoop 2 EndIf Next For $i = 1 To UBound($aChiodini) - 1 If $GUIGetMsg = $aChiodini[$i] Then GUICtrlSetBkColor($aChiodini[$i], $iColor) $aBackColors[$i] = $iColor ContinueLoop 2 EndIf Next Switch $GUIGetMsg Case $aAzioni[1] ; ----- Clear with color For $i = 1 To UBound($aChiodini) - 1 GUICtrlSetBkColor($aChiodini[$i], $iColor) $aBackColors[$i] = $iColor Next Case $aAzioni[2] ; ----- File Load $sFileName = FileOpenDialog("File to load", @ScriptDir, "Text files (*.txt)") If FileExists($sFileName) Then _FileReadToArray($sFileName, $aBackColors, $FRTA_NOCOUNT) For $i = 1 To UBound($aBackColors) - 1 GUICtrlSetBkColor($aChiodini[$i], $aBackColors[$i]) Next Else MsgBox(64, "Info", "File not found") EndIf Case $aAzioni[3] ; ----- File Save $sFileName = FileSaveDialog("File to save", @ScriptDir, "Text files (*.txt)") $bOkToSave = True If FileExists($sFileName) Then $bOkToSave = 6 = MsgBox(4 + 48, "warning", "File already exists, do you want overwrite it?") EndIf If $bOkToSave Then _FileWriteFromArray($sFileName, $aBackColors) EndIf Case $aAzioni[4] ; ----- Save image $sFileName = FileSaveDialog("Image name to save", @ScriptDir, "Image jpg (*.jpg)") $bOkToSave = True If FileExists($sFileName) Then $bOkToSave = 6 = MsgBox(4 + 48, "warning", "File already exists, do you want overwrite it?") EndIf If $bOkToSave Then CaptureWindow($sFileName, ($aChiodini[0])[13], ($aChiodini[0])[14], ($aChiodini[0])[15], ($aChiodini[0])[16], $hGui) EndIf EndSwitch If $GUIGetMsg = -3 Then Exit ; If 6 = MsgBox(4 + 32, "?", "Do you really want to quit?") Then Exit EndIf WEnd EndFunc ;==>_Chiodini ; #FUNCTION# ==================================================================================================================== ; Name...........: _GuiControlPanel v1.1 2021/12 ; Description ...: Creates a rectangular panel with adequate size to contain the required amount of controls ; and then fills it with the same controls by placing them according to the parameters ; Syntax.........: _GuiControlPanel( $ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, $xPos = 0, $yPos = 0, $xBorder, $yBorder, $xSpace = 1, $ySpace = 1) ; Parameters ....: $ControlType - Type of controls to be generated ("Button"; "Text"; ..... ; $nrPerLine - Nr. of controls per line in the matrix ; $nrOfLines - Nr. of lines in the matrix ; $ctrlWidth - Width of each control ; $ctrlHeight - Height of each control ; $xPanelPos - x Position of panel in GUI ; $yPanelPos - y Position of panel in GUI ; $xBorder - distance from lateral panel's borders to the matrix (width of left and right margin) default = 0 ; $yBorder - distance from upper and lower panel's borders to the matrix (width of upper and lower margin) default = 0 ; $xSpace - horizontal distance between the controls ; $ySpace - vertical distance between the controls ; $Group - if you want to group the controls (true or false) ; $sGrpTitle - title of the group (ignored if above is false) ; Return values .: an 1 based 1d array containing references to each control ; element [0] contains an 1d array containing various parameters about the panel ; Author ........: Gianni Addiego (Chimp) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GuiControlPanel($ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, $xPanelPos = 0, $yPanelPos = 0, $xBorder = 0, $yBorder = 0, $xSpace = 1, $ySpace = 1, $Group = False, $sGrpTitle = "") Local Static $sAllowedControls = "|Label|Input|Edit|Button|CheckBox|Radio|List|Combo|Pic|Icon|Graphic|" If Not StringInStr($sAllowedControls, '|' & $ControlType & '|') Then Return SetError(1, 0, "Unkown control") Local $col, $row, $left, $top, $text Local $PanelWidth = (($ctrlWidth + $xSpace) * $nrPerLine) - $xSpace + ($xBorder * 2) Local $PanelHeight = (($ctrlHeight + $ySpace) * $nrOfLines) - $ySpace + ($yBorder * 2) Local $InnerXPos = $xPanelPos, $InnerYPos = $yPanelPos, $InnerWidth = $PanelWidth, $InnerHeight = $PanelHeight If $Group Then $PanelWidth += 2 $InnerXPos += 1 If $sGrpTitle = "" Then $InnerYPos += 7 $PanelHeight += 8 GUICtrlCreateGroup("", $xPanelPos, $yPanelPos, $PanelWidth, $PanelHeight) Else $InnerYPos += 15 $PanelHeight += 18 GUICtrlCreateGroup($sGrpTitle, $xPanelPos, $yPanelPos, $PanelWidth + 2, $PanelHeight) ; + 18) EndIf EndIf ; create the controls Local $aGuiGridCtrls[$nrPerLine * $nrOfLines + 1] Local $aPanelParams[17] = [ _ $ControlType, $nrPerLine, $nrOfLines, $ctrlWidth, $ctrlHeight, _ $xPanelPos, $yPanelPos, $xBorder, $yBorder, $xSpace, $ySpace, $PanelWidth, $PanelHeight, $InnerXPos, $InnerYPos, $InnerWidth, $InnerHeight] For $i = 0 To $nrPerLine * $nrOfLines - 1 ; coordinates 1 based $col = Mod($i, $nrPerLine) + 1 ; Vertical position within the grid (row) $iVtab $row = Int($i / $nrPerLine) + 1 ; Horizontal position within the grid (column) $iHtab $left = $InnerXPos + ((($ctrlWidth + $xSpace) * $col) - $xSpace) - $ctrlWidth + $xBorder $top = $InnerYPos + ((($ctrlHeight + $ySpace) * $row) - $ySpace) - $ctrlHeight + $yBorder $text = '' ; $i + 1 ; "*" ; "." ; "(*)" $aGuiGridCtrls[$i + 1] = Execute("GUICtrlCreate" & $ControlType & "($text, $left, $top, $ctrlWidth, $ctrlHeight)") Next If $Group Then GUICtrlCreateGroup("", -99, -99, 1, 1) ; close group $aGuiGridCtrls[0] = $aPanelParams Return $aGuiGridCtrls EndFunc ;==>_GuiControlPanel ; By kafu ; https://www.autoitscript.com/forum/topic/201524-guicreate-and-wingetclientsize-mismatch/?do=findComment&comment=1446141 Func _WinSetClientSize($hWnd, $iW, $iH) Local $aWinPos = WinGetPos($hWnd) Local $sRect = DllStructCreate("int;int;int;int;") DllStructSetData($sRect, 3, $iW) DllStructSetData($sRect, 4, $iH) _WinAPI_AdjustWindowRectEx($sRect, _WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)) WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], _ $aWinPos[2] + (DllStructGetData($sRect, 3) - $aWinPos[2]) - DllStructGetData($sRect, 1), _ $aWinPos[3] + (DllStructGetData($sRect, 4) - $aWinPos[3]) - DllStructGetData($sRect, 2)) EndFunc ;==>_WinSetClientSize ; By InunoTaishou ; https://www.autoitscript.com/forum/topic/181655-redraw-your-desktop-with-gdi/?tab=comments#comment-1304386 Func CaptureWindow($sFileName = "", $iLeft = -1, $iTop = -1, $iWidth = -1, $iHeight = -1, $hWnd = WinGetHandle("[Active]"), $bClientArea = True) If (Not IsHWnd($hWnd)) Then $hWnd = WinGetHandle($hWnd) If (@error) Then Return SetError(1, 0, False) If (BitAND(WinGetState($hWnd), 16) = 16) Then Return SetError(2, 0, False) Local $iSrcWidth = 0 Local $iSrcHeight = 0 Local $tRectWindow = _WinAPI_GetWindowRect($hWnd) ; Get the absolute width, using Abs on all of the memembers because the [1] index of the struct may be negative, supports multiple monitors Local $iAbsWidth = Abs(Abs(DllStructGetData($tRectWindow, 3)) - Abs(DllStructGetData($tRectWindow, 1))) ; Get the absolute height, using Abs on all of the memembers because the [1] index of the struct may be negative, supports multiple monitors ; Subtracts the caption bar if $bClientArea only Local $iAbsHeight = Abs(Abs(DllStructGetData($tRectWindow, 4)) - Abs(DllStructGetData($tRectWindow, 2))) - ($bClientArea ? _WinAPI_GetSystemMetrics($SM_CYCAPTION) : 0) If ($iWidth = -1 Or $iWidth = 0 Or $iWidth = Default Or $iWidth > $iAbsWidth) Then $iWidth = $iAbsWidth If ($iHeight = -1 Or $iHeight = 0 Or $iHeight = Default Or $iHeight > $iAbsHeight) Then $iHeight = $iAbsHeight $iSrcWidth = $iAbsWidth $iSrcHeight = $iAbsHeight If ($iLeft = -1 Or $iLeft = Default) Then $iLeft = 0 If ($iTop = -1 Or $iTop = Default) Then $iTop = 0 Local $hDC = _WinAPI_GetWindowDC($hWnd) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hDestBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hDestBitmap) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iSrcWidth, $iSrcHeight) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) _WinAPI_PrintWindow($hWnd, $hSrcDC, True) _WinAPI_BitBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, $iLeft, $iTop, $MERGECOPY) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) $tPoint = 0 $tRectWindow = 0 $tDesktop = 0 If ($sFileName) Then _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hDestBitmap) _GDIPlus_ImageSaveToFile($hBitmap, $sFileName) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndIf ; Return $hDestBitmap EndFunc ;==>CaptureWindow  
      Chiodini.zip
    • By Gianni
      After watching this movie (https://www.youtube.com/watch?v=cPiDHXtM0VA) I wanted to try the test to see how much i could compete with that chimpanzee so i created this script.
      well, actually passing that test is a lot harder than it sounds. With the difficulty set to seven numbers and a display time of one second, I can only remember 2 or 3 numbers ... (what a disappointment)
      I can only do better if I reduce the slider to 5 numbers and increase the storage time to 2 seconds (the easyest level), a very poor performance. That chimpanzee is great.
      The script offers you a sequence of 10 random quizzes. At the end it gives you the percentage of your "level". The chimpanzee resolves on average 8 out of 10 (80%), so you can compare your performance to that of the chimpanzee.
      How to play:
      Run the script. At the beginning there are 2 sliders at the bottom of the screen where you can set the difficulty level by varying the memorization time and the amount of numbers to memorize as you like. After setting the difficulty, click the circle on the bottom left to get started. after the first move the sliders are no longer displayed until the next game, (the game lasts 10 attempts, there is a progress bar at the bottom of the screen to see where you are) between one test and the other of the ten, click on the circle to move on to the next test have fun.
      (here a related interesting video: https://www.youtube.com/watch?v=ktkjUjcZid0 )
      #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <WinAPIMisc.au3> ; HotKeySet("{ESC}", "_EndOfGame") Global $iNumbersToGuess = 7, $iExpositionTime = 1000, $iMatches = 10, $iMatchesWon Global $aNumbers[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Global $aButtons[10], $aControls[5] Global $iWinWidth = @DesktopWidth / 2, $iWinHeight = @DesktopHeight / 2, $iButtonXSide = Int($iWinWidth / UBound($aNumbers)), $iButtonYSide = Int($iWinHeight / UBound($aNumbers)), $sWinTitle = "Beat the Chimp" Global $aX[Int($iWinWidth / $iButtonXSide)], $aY[Int($iWinHeight / $iButtonYSide)], $iNdx = 0, $aPoints[3], $score, $GUIGetMsg, $iDockHeight = 50, $iProgrssHeight = 5 For $i = 0 To (Int($iWinWidth / $iButtonXSide) - 1) * $iButtonXSide Step $iButtonXSide $aX[$iNdx] = $i $iNdx += 1 Next $iNdx = 0 For $i = 0 To (Int($iWinHeight / $iButtonYSide) - 1) * $iButtonYSide Step $iButtonYSide $aY[$iNdx] = $i $iNdx += 1 Next Global Const $iDockLeftBorder = 200, $iForeColor = 0xFFFFFF, $iBackColor = 0x000000 Global $hGUI = GUICreate($sWinTitle, $iWinWidth, $iWinHeight + $iDockHeight + $iProgrssHeight, @DesktopWidth / 4, @DesktopHeight / 5) GUISetBkColor($iBackColor, $hGUI) ; the circle to continue playing $aControls[0] = GUICtrlCreateLabel(ChrW(0x25EF), 0, $iWinHeight + 1, 100, $iDockHeight, 0x01) ; GUICtrlSetTip(-1, "Click the circle," & @CRLF & "then click the squares" & @CRLF & "in numeric order.") GUICtrlSetFont(-1, 24, 900) GUICtrlSetColor(-1, $iForeColor) GUICtrlSetBkColor(-1, $iBackColor) ; slider for the amount of numbers to guess $aControls[2] = GUICtrlCreateSlider($iDockLeftBorder, $iWinHeight, $iWinWidth - $iDockLeftBorder, Int($iDockHeight / 2)) GUICtrlSetLimit(-1, 10, 5) ; 5 steps 5 (easy) to 10 (hard) GUICtrlSetData(-1, $iNumbersToGuess) ; label for the amount of quizzes $aControls[1] = GUICtrlCreateLabel("Numbers : " & GUICtrlRead($aControls[2]), 100, $iWinHeight + 1, 100) GUICtrlSetColor(-1, $iForeColor) ; slider for the exposition time $aControls[4] = GUICtrlCreateSlider($iDockLeftBorder, $iWinHeight + (Int($iDockHeight / 2)), $iWinWidth - $iDockLeftBorder, $iDockHeight / 2) GUICtrlSetLimit(-1, 8, 1) ; 8 steps (0f 250ms each) GUICtrlSetData(-1, $iExpositionTime / 250) ; label for the exposition time $aControls[3] = GUICtrlCreateLabel("ms to show : " & GUICtrlRead($aControls[4]) * 250, 100, $iWinHeight + 1 + (Int($iDockHeight / 2)), 100) GUICtrlSetColor(-1, $iForeColor) ; progress bar of the match Global $idProgressbar = GUICtrlCreateProgress(0, $iWinHeight + $iDockHeight, $iWinWidth, $iProgrssHeight) ; Create buttons For $i = 0 To 9 $aButtons[$i] = GUICtrlCreateLabel($i + 1, $iWinWidth + 5, $iWinHeight + $iDockHeight + $iProgrssHeight + 5, $iButtonXSide, $iButtonYSide, 0x01) GUICtrlSetFont($aButtons[$i], 24) GUICtrlSetColor($aButtons[$i], $iForeColor) GUICtrlSetBkColor($aButtons[$i], $iBackColor) Next GUISetState(@SW_SHOW) ; --- Main loop --- Do ; New game $iMatchesWon = 0 GUICtrlSetData($idProgressbar, 0) For $iRound = 1 To $iMatches ; the game lasts $iMatches rounds $iNdx = 0 ; reset pointer (index to the next correct answer) _HideControls(__get_IDs_by_indexes($aButtons, $aNumbers)) ; remove the numbers from the screen ; show the dock and wait (only in the first round are also shown the sliders) _ShowControls($iRound = 1 ? $aControls : $aControls[0]) ; display the dock's control(s) While 1 Switch GUIGetMsg() Case $aControls[0] ; The circle (play a new quiz) ExitLoop Case $aControls[2] ; slider to choose how many numbers to guess $iNumbersToGuess = GUICtrlRead($aControls[2]) GUICtrlSetData($aControls[1], "Numbers : " & $iNumbersToGuess) Case $aControls[4] ; slider to choose how long (milliseconds) to show the numbers $iExpositionTime = GUICtrlRead($aControls[4]) * 250 ; 8 steps of 250 milliseconds each GUICtrlSetData($aControls[3], "ms to show : " & $iExpositionTime) Case $GUI_EVENT_CLOSE _EndOfGame() EndSwitch WEnd _HideControls($aControls) ; hide the dock Sleep(750) ; wait a bit $aQuiz = _GenerateQuiz($iNumbersToGuess) ; generate random elements to guess _SpreadControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; scatter the numbers on the GUI _ShowControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; display the numbers Sleep($iExpositionTime) ; leave numbers visible for a short time _MaskControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; mask the numbers GUICtrlSetData($idProgressbar, Round($iRound / $iMatches * 100)) ; _ShowControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; <------------- keep numbers visible FOR DEBUG PURPOSE ONLY! While 1 ; wait for a move $GUIGetMsg = GUIGetMsg() If $GUIGetMsg = $GUI_EVENT_CLOSE Then _EndOfGame() ; scan all quiz buttons to check if one was pressed For $i = 0 To UBound($aQuiz) - 1 ; $aButtons) - 1 If $GUIGetMsg = $aButtons[$aQuiz[$i] - 1] Then If $i = $iNdx Then ; -------------------------- ; actions for a right move ; -------------------------- ; hide the guessed number _HideControls($aButtons[$aQuiz[$i] - 1]) ; --------------------------------- ; check if this round is complete ; --------------------------------- If $iNdx = (UBound($aQuiz) - 1) Then _WinAPI_PlaySound("SystemExclamation", Null, BitOR($SND_ALIAS, $SND_ASYNC)) $iMatchesWon += 1 ExitLoop 2 EndIf ; play a short ok sound ; _WinAPI_PlaySound("FaxBeep", Null, BitOR($SND_ALIAS, $SND_ASYNC)) ; "SystemAsterisk" $iNdx += 1 ; set index to next correct answer Else ; -------------------------- ; actions for a wrong move ; -------------------------- ; show all the right sequence _ShowControls(__get_IDs_by_indexes($aButtons, $aQuiz)) _WinAPI_PlaySound("DeviceFail", Null, BitOR($SND_ALIAS, $SND_ASYNC)) ; give a little time to the user to control it Sleep(1500) ; go to next step ExitLoop 2 EndIf EndIf Next WEnd ; loop till end of match $score = Round($iMatchesWon / $iMatches * 100, 2) ; percentage Select Case $score < 80 $sResult = "The chimp beat you!" Case $score > 80 $sResult = "You beat the chimp!" Case $score = 80 $sResult = "You tied the chimp." EndSelect Next ; next round ; game over? Until MsgBox($MB_YESNO + $MB_ICONINFORMATION + $MB_TASKMODAL + $MB_SETFOREGROUND, _ "Game over", _ "You got " & $score & "% correct." & @CRLF & _ "Ayumu averages 80% correct." & @CRLF & $sResult & @CRLF & @CRLF & _ "do you want to try again?") <> 6 Func _SpreadControls($aTemp) ; place the required numbers scattered on the GUI SRandom(@YEAR + @MON + @MDAY + @HOUR + @MIN + @SEC) _ArrayShuffle($aX) _ArrayShuffle($aY) ; first, place all buttons out of GUI For $i = 0 To UBound($aButtons) - 1 GUICtrlSetPos($aButtons[$i], $iWinWidth + 5, $iWinHeight + $iDockHeight + $iProgrssHeight + 5) GUICtrlSetState($aButtons[$i], $GUI_DISABLE) Next ; Then place only the numbers of this quiz in visible area For $i = 0 To UBound($aTemp) - 1 GUICtrlSetPos($aTemp[$i], $aX[$i], $aY[$i]) GUICtrlSetState($aTemp[$i], $GUI_ENABLE) Next EndFunc ;==>_SpreadControls Func _GenerateQuiz($iNumElements) ; generate an array of required random numbers SRandom(@YEAR + @MON + @MDAY + @HOUR + @MIN + @SEC) Local $aTemp[$iNumElements] _ArrayShuffle($aNumbers) For $i = 0 To $iNumElements - 1 $aTemp[$i] = $aNumbers[$i] Next _ArraySort($aTemp) Return $aTemp EndFunc ;==>_GenerateQuiz Func _ShowControls($aTemp) ; render controls visible (and enabled) $aTemp = _EnforceArray($aTemp) For $i = 0 To UBound($aTemp) - 1 GUICtrlSetState($aTemp[$i], $GUI_SHOW) GUICtrlSetColor($aTemp[$i], $iForeColor) GUICtrlSetBkColor($aTemp[$i], $iBackColor) Next EndFunc ;==>_ShowControls Func _MaskControls($aTemp) ; mask the controls $aTemp = _EnforceArray($aTemp) For $i = 0 To UBound($aTemp) - 1 GUICtrlSetColor($aTemp[$i], $iForeColor) GUICtrlSetBkColor($aTemp[$i], $iForeColor) Next EndFunc ;==>_MaskControls Func _HideControls($aTemp) ; hide the controls (implies disable) $aTemp = _EnforceArray($aTemp) For $i = 0 To UBound($aTemp) - 1 GUICtrlSetState($aTemp[$i], $GUI_HIDE) ; $GUI_DISABLE) ; GUICtrlSetColor($aButtons[$aTemp[$i] - 1], $iBackColor) ; GUICtrlSetBkColor($aButtons[$aTemp[$i] - 1], $iBackColor) Next EndFunc ;==>_HideControls Func _EnforceArray($vParam) ; if only one value is passed, turn it into an array of only 1 element If Not IsArray($vParam) Then Local $aTemp[1] = [$vParam] Return $aTemp EndIf Return $vParam EndFunc ;==>_EnforceArray Func __get_IDs_by_indexes(ByRef $aCtrls, ByRef $aNdxs) ; returns the handles of the controls pointed to by the indexes Local $aTemp[UBound($aNdxs)] For $i = 0 To UBound($aNdxs) - 1 $aTemp[$i] = $aCtrls[$aNdxs[$i] - 1] Next Return $aTemp EndFunc ;==>__get_IDs_by_indexes Func _EndOfGame() ; _WinAPI_PlaySound ("SystemExit" , Null, $SND_ALIAS) GUIDelete() Exit EndFunc ;==>_EndOfGame P.S. At this link (https://web.archive.org/web/20131006161544/http://games.lumosity.com/chimp.html) there is a Flash version of this game.
    • By TheSaint
      An adaption of an adaption.
      A good while back, I created a program, KindEbook Wishlist, that I use most days and is still available here at the forum. It works well, keeping tabs on price changes for Kindle ebooks at Amazon ... at least for my modest wants.
      About a year or so later, I struck upon the idea of adapting that program for CDs, DVDs, Blu-rays etc from the JB Hifi store, where there was a limit of about 50 items on the in-store wishlist. JB Wishlist is kind of a niche program, really only suitable for those from AUS, at the AutoIt Forum, who would want such a thing ... so not many I imagine, so it has never been available here. However, if you meet that criteria etc, and are willing to register at the AutoIt4Life Clubrooms, then it is available in the Project Chat section there ... though not the more recent updates (you need to ask me about them). That too, works quite well for my modest needs, and even includes an additional Preview & Summary window, which KindEbook Wishlist doesn't have ... though both programs do have access to a Details window per item, that is like the Preview window ... just doesn't constantly display alongside the Main program window (see later for an example with IonGoG Wishlist).
      So, now we come to IonGoG Wishlist, which is an adaption of the JB Wishlist program, and used for keeping tabs on GOG Games ... prices, history of changes, bought list, etc.
      IonGoG Wishlist is an incomplete adaption, so still in beta ... though all the really important elements work well enough. I have been working on it in dribs and drabs, and I now think it has come to a reasonable enough stage to share it ... just be advised, that some of the features accessed via the right-click menu etc, may not work or give strange results. Any of the options that I have given an Accelerator key facility to, should be working fine ... and most of the others are too ... and I am not even sure at this point, of what remains to be adapted ... not much I imagine.
      The name by the way, in case you were wondering, is a phonetic mangling on the words - keep an Eye On your GOG Wishlist.
      Here is a screenshot, with the Preview window on left. The Preview window can be placed at right instead or even turned off.

      Download, includes source files.
      IonGoG Wishlist v0.0_b28.zip  (see detail at Post#23)
      Enjoy!
      OLDER DOWNLOADS
      SUPPLEMENTARY
      I have another program that GOG users may be interested in, that can assist with getting game images that IonGoG Wishlist gets and doesn't get ... larger versions taken from modified thumbnail links in their GOG Library.
      Downloads Dropbox  (see the GOG example in Post #7)
      ADDENDUM
      In reality, compared to most stores I have come across, the GOG store is great, well setup and laid out. and for most things, including their Wishlist, is more than adequate. So I rarely do a full list Price Query ... so much quicker and easier to just check the two pages of my in-store wishlist. When I first started work on IonGoG Wishlist, the in-store wishlist wasn't as good as it is now.
      All that said, I still find it handy to use IonGoG Wishlist, for a variety of things - Offline browsing, Cover images to use with my bought & downloaded game folders, price changes history (and patterns of GOG behavior for sales etc), a bought list (with price I paid and date etc), Game Notes & Warnings, etc. And while not as quick as just checking the pages of your in-store wishlist, you can just set the full, favorites or non-favorites Query going, while you go away and do something else, and then later come back and look at the highlighted changes that may have occurred.
    • By Barney
      From MiniMax to Machine Learning ... Tic Tac Toe is a good game for studying AI algorithm because it's simple!
      I use Tabular Q Learning to implement this game, Every time a game finished, it will use the Q function to update
      the score of each steps it played.
      Q(S,A) = Q(S,A) + α ∗ (γ ∗ maxaQ(S′,a) − Q(S,A))
      S being the current state, A the current action, S′ the state after doing A, α being the learning rate, γ being the
      discount factor,  and maxaQ(S′,a) the highest Q value of any move in the next state S′, i.e. the Q value of the best
      move in the following state.
      It's funny to see that it plays better and better. That's why people were charmed by Machine Learning!
      Thank you!
      Download: tic_tac_toe.zip

    • By Dan_555
      Hi, this is a Nonogram Game.
      It is compiled for windows in 32bit (64bit does not work as intended!), sourcecode in v3.3.14.5, icon and the required ini file with more than 100 puzzles.
      The Game has an built-in Editor, and can generate random playfields. 
×
×
  • Create New...