# Stupid funny game

## Recommended Posts

Hello everyone!! While solving some maths problems I thought of something and came up with this so-called 'tricky' game. Read instructions and Enjoy playing!!!

```#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>\$Form1 = GUICreate("MKISH's Magic Window", 564, 668, 393, 83)
GuiSetBkColor(0xffffff)
Global \$Button[104]
Global Const \$ANS = Chr(Random(1,100,1))
\$Label3 = GUICtrlCreateLabel("     1-20           21-40          41-60          61-80        81-100", 24, 16, 515, 25)
GUICtrlSetFont(-1, 11, 800, 0, "Comic Sans MS")
\$Button[1] = GUICtrlCreateButton("", 24, 48, 51, 49, \$WS_GROUP)
\$Button[2] = GUICtrlCreateButton("", 74, 48, 51, 49, \$WS_GROUP)
\$Button[3] = GUICtrlCreateButton("", 24, 96, 51, 49, \$WS_GROUP)
\$Button[4] = GUICtrlCreateButton("", 74, 96, 51, 49, \$WS_GROUP)
\$Button[5] = GUICtrlCreateButton("", 24, 144, 51, 49, \$WS_GROUP)
\$Button[6] = GUICtrlCreateButton("", 74, 144, 51, 49, \$WS_GROUP)
\$Button[7] = GUICtrlCreateButton("", 24, 192, 51, 49, \$WS_GROUP)
\$Button[8] = GUICtrlCreateButton("", 74, 192, 51, 49, \$WS_GROUP)
\$Button[9] = GUICtrlCreateButton("", 24, 240, 51, 49, \$WS_GROUP)
\$Button[10] = GUICtrlCreateButton("", 74, 240, 51, 49, \$WS_GROUP)
\$Button[11] = GUICtrlCreateButton("", 24, 288, 51, 49, \$WS_GROUP)
\$Button[12] = GUICtrlCreateButton("", 74, 288, 51, 49, \$WS_GROUP)
\$Button[13] = GUICtrlCreateButton("", 24, 336, 51, 49, \$WS_GROUP)
\$Button[14] = GUICtrlCreateButton("", 74, 336, 51, 49, \$WS_GROUP)
\$Button[15] = GUICtrlCreateButton("", 24, 384, 51, 49, \$WS_GROUP)
\$Button[16] = GUICtrlCreateButton("", 74, 384, 51, 49, \$WS_GROUP)
\$Button[17] = GUICtrlCreateButton("", 24, 432, 51, 49, \$WS_GROUP)
\$Button[18] = GUICtrlCreateButton("", 74, 432, 51, 49, \$WS_GROUP)
\$Button[19] = GUICtrlCreateButton("", 24, 480, 51, 49, \$WS_GROUP)
\$Button[20] = GUICtrlCreateButton("", 74, 480, 51, 49, \$WS_GROUP)
\$Button[21] = GUICtrlCreateButton("", 128, 48, 51, 49, \$WS_GROUP)
\$Button[22] = GUICtrlCreateButton("", 178, 48, 51, 49, \$WS_GROUP)
\$Button[23] = GUICtrlCreateButton("", 128, 96, 51, 49, \$WS_GROUP)
\$Button[24] = GUICtrlCreateButton("", 178, 96, 51, 49, \$WS_GROUP)
\$Button[25] = GUICtrlCreateButton("", 128, 144, 51, 49, \$WS_GROUP)
\$Button[26] = GUICtrlCreateButton("", 178, 144, 51, 49, \$WS_GROUP)
\$Button[27] = GUICtrlCreateButton("", 128, 192, 51, 49, \$WS_GROUP)
\$Button[28] = GUICtrlCreateButton("", 178, 192, 51, 49, \$WS_GROUP)
\$Button[29] = GUICtrlCreateButton("", 128, 240, 51, 49, \$WS_GROUP)
\$Button[30] = GUICtrlCreateButton("", 178, 240, 51, 49, \$WS_GROUP)
\$Button[31] = GUICtrlCreateButton("", 128, 288, 51, 49, \$WS_GROUP)
\$Button[32] = GUICtrlCreateButton("", 178, 288, 51, 49, \$WS_GROUP)
\$Button[33] = GUICtrlCreateButton("", 128, 336, 51, 49, \$WS_GROUP)
\$Button[34] = GUICtrlCreateButton("", 178, 336, 51, 49, \$WS_GROUP)
\$Button[35] = GUICtrlCreateButton("", 128, 384, 51, 49, \$WS_GROUP)
\$Button[36] = GUICtrlCreateButton("", 178, 384, 51, 49, \$WS_GROUP)
\$Button[37] = GUICtrlCreateButton("", 128, 432, 51, 49, \$WS_GROUP)
\$Button[38] = GUICtrlCreateButton("", 178, 432, 51, 49, \$WS_GROUP)
\$Button[39] = GUICtrlCreateButton("", 128, 480, 51, 49, \$WS_GROUP)
\$Button[40] = GUICtrlCreateButton("", 178, 480, 51, 49, \$WS_GROUP)
\$Button[41] = GUICtrlCreateButton("", 232, 48, 51, 49, \$WS_GROUP)
\$Button[42] = GUICtrlCreateButton("", 282, 48, 51, 49, \$WS_GROUP)
\$Button[43] = GUICtrlCreateButton("", 232, 96, 51, 49, \$WS_GROUP)
\$Button[44] = GUICtrlCreateButton("", 282, 96, 51, 49, \$WS_GROUP)
\$Button[45] = GUICtrlCreateButton("", 232, 144, 51, 49, \$WS_GROUP)
\$Button[46] = GUICtrlCreateButton("", 282, 144, 51, 49, \$WS_GROUP)
\$Button[47] = GUICtrlCreateButton("", 232, 192, 51, 49, \$WS_GROUP)
\$Button[48] = GUICtrlCreateButton("", 282, 192, 51, 49, \$WS_GROUP)
\$Button[49] = GUICtrlCreateButton("", 232, 240, 51, 49, \$WS_GROUP)
\$Button[50] = GUICtrlCreateButton("", 282, 240, 51, 49, \$WS_GROUP)
\$Button[51] = GUICtrlCreateButton("", 232, 288, 51, 49, \$WS_GROUP)
\$Button[52] = GUICtrlCreateButton("", 282, 288, 51, 49, \$WS_GROUP)
\$Button[53] = GUICtrlCreateButton("", 232, 336, 51, 49, \$WS_GROUP)
\$Button[54] = GUICtrlCreateButton("", 282, 336, 51, 49, \$WS_GROUP)
\$Button[55] = GUICtrlCreateButton("", 232, 384, 51, 49, \$WS_GROUP)
\$Button[56] = GUICtrlCreateButton("", 282, 384, 51, 49, \$WS_GROUP)
\$Button[57] = GUICtrlCreateButton("", 232, 432, 51, 49, \$WS_GROUP)
\$Button[58] = GUICtrlCreateButton("", 282, 432, 51, 49, \$WS_GROUP)
\$Button[59] = GUICtrlCreateButton("", 232, 480, 51, 49, \$WS_GROUP)
\$Button[60] = GUICtrlCreateButton("", 282, 480, 51, 49, \$WS_GROUP)
\$Button[61] = GUICtrlCreateButton("", 336, 48, 51, 49, \$WS_GROUP)
\$Button[62] = GUICtrlCreateButton("", 386, 48, 51, 49, \$WS_GROUP)
\$Button[63] = GUICtrlCreateButton("", 336, 96, 51, 49, \$WS_GROUP)
\$Button[64] = GUICtrlCreateButton("", 386, 96, 51, 49, \$WS_GROUP)
\$Button[65] = GUICtrlCreateButton("", 336, 144, 51, 49, \$WS_GROUP)
\$Button[66] = GUICtrlCreateButton("", 386, 144, 51, 49, \$WS_GROUP)
\$Button[67] = GUICtrlCreateButton("", 336, 192, 51, 49, \$WS_GROUP)
\$Button[68] = GUICtrlCreateButton("", 386, 192, 51, 49, \$WS_GROUP)
\$Button[69] = GUICtrlCreateButton("", 336, 240, 51, 49, \$WS_GROUP)
\$Button[70] = GUICtrlCreateButton("", 386, 240, 51, 49, \$WS_GROUP)
\$Button[71] = GUICtrlCreateButton("", 336, 288, 51, 49, \$WS_GROUP)
\$Button[72] = GUICtrlCreateButton("", 386, 288, 51, 49, \$WS_GROUP)
\$Button[73] = GUICtrlCreateButton("", 336, 336, 51, 49, \$WS_GROUP)
\$Button[74] = GUICtrlCreateButton("", 386, 336, 51, 49, \$WS_GROUP)
\$Button[75] = GUICtrlCreateButton("", 336, 384, 51, 49, \$WS_GROUP)
\$Button[76] = GUICtrlCreateButton("", 386, 384, 51, 49, \$WS_GROUP)
\$Button[77] = GUICtrlCreateButton("", 336, 432, 51, 49, \$WS_GROUP)
\$Button[78] = GUICtrlCreateButton("", 386, 432, 51, 49, \$WS_GROUP)
\$Button[79] = GUICtrlCreateButton("", 336, 480, 51, 49, \$WS_GROUP)
\$Button[80] = GUICtrlCreateButton("", 386, 480, 51, 49, \$WS_GROUP)
\$Button[81] = GUICtrlCreateButton("", 440, 48, 51, 49, \$WS_GROUP)
\$Button[82] = GUICtrlCreateButton("", 490, 48, 51, 49, \$WS_GROUP)
\$Button[83] = GUICtrlCreateButton("", 440, 96, 51, 49, \$WS_GROUP)
\$Button[84] = GUICtrlCreateButton("", 490, 96, 51, 49, \$WS_GROUP)
\$Button[85] = GUICtrlCreateButton("", 440, 144, 51, 49, \$WS_GROUP)
\$Button[86] = GUICtrlCreateButton("", 490, 144, 51, 49, \$WS_GROUP)
\$Button[87] = GUICtrlCreateButton("", 440, 192, 51, 49, \$WS_GROUP)
\$Button[88] = GUICtrlCreateButton("", 490, 192, 51, 49, \$WS_GROUP)
\$Button[89] = GUICtrlCreateButton("", 440, 240, 51, 49, \$WS_GROUP)
\$Button[90] = GUICtrlCreateButton("", 490, 240, 51, 49, \$WS_GROUP)
\$Button[91] = GUICtrlCreateButton("", 440, 288, 51, 49, \$WS_GROUP)
\$Button[92] = GUICtrlCreateButton("", 490, 288, 51, 49, \$WS_GROUP)
\$Button[93] = GUICtrlCreateButton("", 440, 336, 51, 49, \$WS_GROUP)
\$Button[94] = GUICtrlCreateButton("", 490, 336, 51, 49, \$WS_GROUP)
\$Button[95] = GUICtrlCreateButton("", 440, 384, 51, 49, \$WS_GROUP)
\$Button[96] = GUICtrlCreateButton("", 490, 384, 51, 49, \$WS_GROUP)
\$Button[97] = GUICtrlCreateButton("", 440, 432, 51, 49, \$WS_GROUP)
\$Button[98] = GUICtrlCreateButton("", 490, 432, 51, 49, \$WS_GROUP)
\$Button[99] = GUICtrlCreateButton("", 440, 480, 51, 49, \$WS_GROUP)
\$Button[100] = GUICtrlCreateButton("", 490, 480, 51, 49, \$WS_GROUP)
\$Button[101] = GUICtrlCreateButton("I am Done !!", 80, 576, 123, 57, \$WS_GROUP)
\$Button[102] = GUICtrlCreateButton("Instructions", 208, 576, 123, 57, \$WS_GROUP)
\$Button[103] = GUICtrlCreateButton("Go Home!!", 336, 576, 123, 57, \$WS_GROUP)

For \$i = 1 to 100
GUICtrlSetFont(\$Button[\$i], 16, 400, 4, "Wingdings")
GuiCtrlSetData(\$Button[\$i], Chr(Random(101, \$i+150, 1)))
GUICtrlSetTip(\$Button[\$i], "" & \$i)
Next
For \$i = 0 to 100 step 9
GuiCtrlSetData(\$Button[\$i], \$ANS)
Next

\$Label1 = GUICtrlCreateLabel("", 8, 544, 548, 4, \$SS_SUNKEN)

GUISetState(@SW_SHOW)

While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE, \$Button[103]
Exit
Case \$Button[101]
GuiSetstate(@SW_DISABLE, \$Form1)
GuiSetBkColor(0xffffff)
\$GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 129)
\$Labelx1 = GUICtrlCreateLabel("The symbol is:", 80, 24, 153, 34)
GUICtrlSetFont(-1, 16, 800, 0, "Comic Sans MS")
\$Labelx22 = GUICtrlCreateLabel("", 96, 90, 139, 30)
GUICtrlSetFont(-1, 18, 800, 0, "Wingdings")
GuiCtrlSetData(-1, \$ANS)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

Case \$Button[102]
msgbox(64, "Instructions", "> Think of a number b/w 10 and 100" & @crlf & "> Subtract from it the sum of its digits" & @crlf & "> Look for the symbol corresponding to answer on the list" & @CRLF & "> Click 'I am Done !!' button and Bingo", Default, \$Form1)
EndSwitch
WEnd```

muttley Easy, isn't it?

EDIT: Now looks fine..

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

##### Share on other sites

Nice script, it's not rocket science, but it's fun if you don't know what it's doing.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Well yes, i saw a similar app called 'magic paper' that does the same thing as my script, on nokia ovi store.

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

##### Share on other sites

Just because...

You could be generating all of those buttons in two loops, X & Y direction at the same time you can set the text of the button too, you'd cut the script down a lot...

##### Share on other sites

Thnx for the appreciation logmein.

@James, feel free to modify this example as you wish. (I am currently working on a chess game, I'll definitely follow your advice)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

## Create an account

Register a new account

• ### Similar Content

• An advanced mathematics UDF written in AutoIt.
Features:
Extending the default mathematical library with functions like Sec, ACsc... Advanced mathematical functions like Riemann's zeta, etc. Differentiating functions Calculating the probability of an event Working with natural numbers (GCD, LCM, primes, ...) Number sequences Working with points in 2D-space Finding paths in a graph And more!
• By RTFC
Simulated Annealing (SA) is a simple technique for finding an acceptable solution (but not necessarily always the absolute best one that exists!) to very hard combinatorial problems, that is, ones for which a brute-force approach of cycling through all possible alternatives to find the global optimum just takes too darn long. Typically, one would be seeking some specific sequence or permutation of a (sub)set, and the number of possibilities is astronomically large. In addition, for SA to be applicable, you'll need to be able to quantify in some way how good any particular trial solution is, or how far distant from the ideal result. The real power of SA lies in these so-called cost functions; you can define as many as you like, with different weights if you like, and these conditions are even allowed to be conflicting. User-defined settings define how tenaciously it should be exploring solution space before homing in on a region with desirable properties, and finding its minimum. You can think of it as a learning algorithm that is allowed to make lots of mistakes in the beginning, before gradually avoiding ever more potentially bad decisions.
A simple Analogy:
You're standing in the middle of an extensive, rough terrain with hills, ridges, bumps, valleys, and tiny, deep depressions. You've got a GPS altimeter to tell you how high above sea-level you currently are, but this area is perpetually shrouded in thick fog. Now find the lowest point. And quickly please. Now what? There's no time to systematically grid and traverse the entire area, and you cannot see more than a few feet ahead. Following the local gradient down-slope will likely get you stuck at a very local minimum, whereas a much lower point may be just beyond the hext hill.
Luckily, you brought your magic boots (the red ones with the twinkling silver stars). These allow you to make huge leaps through the fog, landing safely somewhere else. And although you don't know in advance where you'll end up, the boots magically remember their last-previous departure point, so if you don't like your new surroundings, you can go back one jump (but never more than that). Now to find the lowest point in the landscape, you keep tracking your altimeter changes with every jump. Some jumps will get you to higher ground, others might land you in a deep valley. The trick is not to settle for ever-lower heights immediately, but to allow going back up ever so often, so you can get beyond some high ridge behind which you might find a much lower depression than your best-previous result. Crucially, to decide whether or not to gain height in the misty terrain, you roll some dice you've got in your pocket, and the more jumps you've made, the lower you make the upper bound below which you would still go back uphill. So in the beginning you'll be jumping all over the place (allowing you to sample the terrain extensively), but eventually you'll be limiting yourself to some deep valley you've found, which might be the deepest one all round, but even if not, it will still be a pretty good guess. And you will have found this deep valley in a tiny fraction of the time it would take to do a full land survey.
Simulated annealing needs to be defined in terms of the specific problem you're trying to solve. So it's not possible to provide you with a generic UDF that'll figure out in advance what your ideal solution would look like (for example, in the analogy above, we might be looking for the highest point instead of the lowest one). You need to define that ideal in terms of one or more cost functions that SA will then attempt to minimise. What can be done is to provide you with specific examples.
Example 1.
From a list of user-defined pre-supplied values, select the fewest terms that sum to (or approximate) a predefined target total. This solution was written in response to this thread. Current cost updates are periodically written to console. This example attempts to satisfy two conditions simultaneously: getting a sum that matches the target, and using the smallest number of terms.
Example 2. The Travelling Salesman problem (TSP)
This is a classic combinatorial minimisation problem, and relevant to real-world logistics: to find the shortest route for visiting all cities exactly once, before returning to the original starting point. As it is quite entertaining to see how the algorithm gradually solves this brain teaser,  I've added a simple GUI that visualises the cities (red circles) and the changing routes between them (blue). The problem becomes exponentially harder to solve when the number of cities is increased. This example (adapted from Press et al., Numerical recipes, 2nd ed., pp. 438-443) employs a single cost function of the total route distance.
TSP.au3
It's important to stress that simulated annealing cannot guarantee that the global optimum will always be found, only that it will likely come up with a fairly good solution, and much faster than brute force ever could. If that's good enough for you, then those red, silver-starred boots might fit you too.

• I've written a short program that calculates all values of a mathematical function in a user-defined interval. The data is written to an user-defined file during that process. Unfortunately, there is no file. I don't have a clue what's wrong with my program, and I've been trying to solve that for nearly 2 hours now. Obviously without success.
The calculation is done properly (added a ConsoleWrite() to check that), so it must be the FileWrite() that doesn't work.
Thanks for the help!
Values.au3
• By MattX
Can someone please let me know if I have this is correct - I've sort of tested it and it seems to work but I need a second opinion.
I'm hoping someone will agree that it will only call the RUN line if the size is over 20 gig ?

\$mail_que = FileGetSize('C:\Program Files\Microsoft\Exchange Server\TransportRoles\data\Queue\mail.que') \$mail_que = \$mail_que / 1024 If \$mail_que > 20000000 Then Run('c:\matt\mail_que_email_alert.exe', 'c:\matt') EndIf Exit

• I use Fractions Always In My Script
But I never Found a UDF for That
I made a UDF for Using
So here I want to Share it
I Named it MathsEx UDF but I Guess Fraction UDF would be Better

It Requires Three Funtions Of Array.au3

Currently Supported Functions

; #INDEX# ======================================================================================================================= ; Title .........: MathsEx ; AutoIt Version : 3.2.10++ ; Language ......: English ; Description ...: Functions for Carrying Out More Advanced Mathematical Calculations. ; Author(s) .....: Phoenix XL ; Included.......: Three Functions of Array.au3 i.e. _ArraySort and _ArrayReverse and __ArrayQuickSort1D Requires Array.au3 ; =============================================================================================================================== ; 0xDead=57005...............I just Like The Number :) ; #CURRENT# ===================================================================================================================== ; _Find_GCF ; _Find_LCM ; _Subtract_Fraction ; _Add_Fraction ; _Multiply_Fraction ; _Divide_Fraction ; _Reciprocal ; _Compare_Fraction ; _Quotient ; _Simplify ; _IntegerisNegative ; _IntegerisPositive ; _Get_Denominator ; _Get_Numerator ; _To_Fraction ; _To_Mixed_Fraction ; _Is_Fraction_Improper ; _Is_Fraction_Proper ; _Is_Fraction ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; _CheckArray ; _Greatest_Common_Factor ; _Operate_Fraction ; _Set_Sequence ; ===============================================================================================================================
I havent Included Any Examples Yet
The Documentation is Enough and Is Very Easy To Implement the Funtions
Though If any Bug or Problem With The UDF Please Share It

The UDF is Attached in the Post
V1.1 = Fixed A Bug

Regards
Phoenix XL
MathsEx V1.1.au3
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...