Rex Posted September 17, 2006 Share Posted September 17, 2006 Hi Long time ago i did this script, to generate a dinner menu for 4 weeks, and by a little help from a forum user i got i to work so i did't got the same meal 2 days in a row... expandcollapse popup#include <GUIConstants.au3>; Includes Gui Constants #include <file.au3> #include <string.au3> #include <Date.au3> Global $Uge, $Sektioner $Y = 0 $Uge = _WeekNumberISO() Do $Uge = $Uge + 2 $Y = $Y+1 If $y = 1 Then FileWrite("Menu.txt",">>>> Menu uge " & $Uge & " <<<<" & @CRLF) Else FileWrite("Menu.txt","" & @CRLF & ">>>> Menu uge " & $Uge & " <<<<" & @CRLF) EndIf _Retter() Until $Y = 3 Exit ;Funktion choose meeals Func _Retter() $i = 0 $NumberOfLines = _FileCountLines(@ScriptDir & "\Retter.txt") Dim $Retter $prev_meal = "" Do $i = $i+1 ;this loop will prevent 2 of the same meals in a row Do $Retter = Random(1,$NumberOfLines,1) $Read = IniRead("Retter.txt", $Retter, "key", "Valgfri ret") Until $Read <> $prev_meal IniDelete("Retter.txt", $Retter) ; If meeal fits a 2 day meeal then we cuts of a day of the week If $Read = "Johnnys chilisuppe" or $Read = "Johnnys tomatsuppe" Or $Read = "Pizza" Then $i = $i +1 EndIf FileWrite("Menu.txt", $Read & @CRLF) ;record the meal to check for same meal in next loop iteration $prev_meal = $Read Until $i = 7 EndFunc Now after having used thi meal generator for some time, we (my wife and i) have fount that the meals ar't that random, the same meal some times comes 2-3 times a week or month. So now i hope that i can get some help here, to make i work in arrayers sow i can be sure that the same meal only comes ones per month.... My prob is i can get into my head how thoes arrayers work, some on told me that i schould see it like a exel map, but i still don't get it. Please if some on can help me make this meeal generator work /Rex Link to comment Share on other sites More sharing options...
Rex Posted September 18, 2006 Author Share Posted September 18, 2006 No one ??? Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 18, 2006 Share Posted September 18, 2006 (edited) Hi Long time ago i did this script, to generate a dinner menu for 4 weeks, and by a little help from a forum user i got i to work so i did't got the same meal 2 days in a row... expandcollapse popup#include <GUIConstants.au3>; Includes Gui Constants #include <file.au3> #include <string.au3> #include <Date.au3> Global $Uge, $Sektioner $Y = 0 $Uge = _WeekNumberISO() Do $Uge = $Uge + 2 $Y = $Y+1 If $y = 1 Then FileWrite("Menu.txt",">>>> Menu uge " & $Uge & " <<<<" & @CRLF) Else FileWrite("Menu.txt","" & @CRLF & ">>>> Menu uge " & $Uge & " <<<<" & @CRLF) EndIf _Retter() Until $Y = 3 Exit ;Funktion choose meeals Func _Retter() $i = 0 $NumberOfLines = _FileCountLines(@ScriptDir & "\Retter.txt") Dim $Retter $prev_meal = "" Do $i = $i+1 ;this loop will prevent 2 of the same meals in a row Do $Retter = Random(1,$NumberOfLines,1) $Read = IniRead("Retter.txt", $Retter, "key", "Valgfri ret") Until $Read <> $prev_meal IniDelete("Retter.txt", $Retter) ; If meeal fits a 2 day meeal then we cuts of a day of the week If $Read = "Johnnys chilisuppe" or $Read = "Johnnys tomatsuppe" Or $Read = "Pizza" Then $i = $i +1 EndIf FileWrite("Menu.txt", $Read & @CRLF) ;record the meal to check for same meal in next loop iteration $prev_meal = $Read Until $i = 7 EndFuncoÝ÷ ØÚ0iû^®¯x.±çm)jXêڶߢ»(ëbì,"}æ§v(Z½çèº{m«méj[¯m¶©Ý¢kazƦzgÊ&zئzÇ(ë6ÞئzÆ°yé(®j'¶¨"^¶Æ§ël¢g¡zZaz·¢f¤z,(®H§jºÚÉêì²"q©ÛzË«zØZ¶Ø^±©æ¥¢yrr²Þ²«íÌ©®â²'{h(^iØhÂØhzÆ«¬®Ì(®K(ê'¶]ëajجr.Ûz+eG{¥ª[ºØ¬¶)ev÷öض+Oæ¬z'ì¢g¨Æ§éiéëaÉy©`zw«jÚ+Âäº{.ïÑ{êº^ȧWg§²*'j]CjºÚÊ+#ºËZéz·+-jëh×6#include <array.au3> Dim $aVeg[4] = [Peas, Carrots, Zuccini, Corn] _ArrayDisplay("Veggies", $aVeg)oÝ÷ ØÚ-Ç«mç+y«^vX¬¶øצ²+'ºfÞçt¶îÜéÜ{*.¦ëm)à²)Úªëk,¨¹Æ§ué^µëazf®¶sb6æ6ÇVFRfÇC¶'&æS2fwC° ¤FÒb33c¶fVu³EÒÒµV2Â6'&÷G2§V66æÂ6÷&åÐ¥ô'&FVÆWFRb33c¶fVrÂ"¥ô'&F7ÆgV÷CµfVvvW2gV÷C²Âb33c¶fVr That should allow you to make a list and then remove things from the list to prevent repeating them. Edited September 18, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Rex Posted September 19, 2006 Author Share Posted September 19, 2006 A single dimensional (1D) array is just a numbered list: #include <array.au3> Dim $aVeg[4] = [Peas, Carrots, Zuccini, Corn] _ArrayDisplay("Veggies", $aVeg)oÝ÷ ØÚ-Ç«mç+y«^vX¬¶øצ²+'ºfÞçt¶îÜéÜ{*.¦ëm)à²)Úªëk,¨¹Æ§ué^µëazf®¶sb6æ6ÇVFRfÇC¶'&æS2fwC° ¤FÒb33c¶fVu³EÒÒµV2Â6'&÷G2§V66æÂ6÷&åÐ¥ô'&FVÆWFRb33c¶fVrÂ"¥ô'&F7ÆgV÷CµfVvvW2gV÷C²Âb33c¶fVr That should allow you to make a list and then remove things from the list to prevent repeating them. But i'm reading random from a txt file, how do i know what to del and ehat not to del, when i don't know whats in the array'er And i still don't get the array'er thing, i do belive that i must finde som one who can teach me it in my own lang. first But thx for trying to teach me it /Rex Link to comment Share on other sites More sharing options...
JaySquared Posted September 19, 2006 Share Posted September 19, 2006 Computers can't create random numbers. Even the helpfile states this is function "Returns a pseudo-random number between Min and Max." Since this is based off an equation, it will do it's best to create a "random" number, however the equation will keep hitting the same numbers. Why not try doing something like taking the random number multiplied by the minute or second so that it has constantly changing information to help increase it's "randomness". Aha.. I have unlocked it's secrets.. world domination is within my grasp... Link to comment Share on other sites More sharing options...
Don N Posted September 19, 2006 Share Posted September 19, 2006 Hey rex, im pretty sure i helped you on this thing last time. What exectly are you trying to change this script to do? Do you want unique meals for every day of the month. By this I mean to you only want to eat the same meal once a month? or can it happen as often as once a week? Let me know exactly what you need and I'd be more than willing to help out again. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
Bert Posted September 19, 2006 Share Posted September 19, 2006 If you wouldn't mind, I would like to see the final working code. My wife can be "particular" on what she wants for dinner. This looks like it would really help. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Rex Posted September 19, 2006 Author Share Posted September 19, 2006 If you wouldn't mind, I would like to see the final working code. My wife can be "particular" on what she wants for dinner. This looks like it would really help.NP, when the final code is final ill post it here/Rex Link to comment Share on other sites More sharing options...
Rex Posted September 19, 2006 Author Share Posted September 19, 2006 Hey rex, im pretty sure i helped you on this thing last time. What exectly are you trying to change this script to do? Do you want unique meals for every day of the month. By this I mean to you only want to eat the same meal once a month? or can it happen as often as once a week? Let me know exactly what you need and I'd be more than willing to help out again.HI Don That Sounds right, but coulden rember who helped me, normaly i adds Credits in my code to thoes who haved helped me, but this time i'd forgot...What we (my whife and i) wants, is to get a random menu created for 4 weeks, problem with this generator is that we might get tha same mealt 2 - 3 times a month some times ig generates the same meal Sunday and monday or monday and sunday so the same meals comes 2 times a week.../Rex Link to comment Share on other sites More sharing options...
Rex Posted September 20, 2006 Author Share Posted September 20, 2006 Computers can't create random numbers. Even the helpfile states this is function "Returns a pseudo-random number between Min and Max." Since this is based off an equation, it will do it's best to create a "random" number, however the equation will keep hitting the same numbers. Why not try doing something like taking the random number multiplied by the minute or second so that it has constantly changing information to help increase it's "randomness".That could might work, but i get my max from the readlines so if i multiply the "random" with the time(sec) im quite sure that i will end far away from my max Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now