goldenix Posted February 11, 2009 Share Posted February 11, 2009 (edited) The goal of this game is to concentrate & make the computer to randomly output total more 0 than 1 in a row. If computer outputs more 1 you fail & should start again.My score:0 - 9 times in a row1 - 6 times in a rowRun the code once = 1 attempt.Post your results please.expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.12.1 Author: Goldenix http://www.autoitscript.com/forum/index.php?showtopic=89453 Script Function: Tedsting you Psychic abilities #ce ---------------------------------------------------------------------------- #include <file.au3> FileDelete('0.txt') FileDelete('1.txt') FileDelete('result0.txt') FileDelete('result0.txt') $total0 = 0 $total1 = 0 For $u=1 to 10 For $t=1 to 10 For $x=1 to 100 $a = Random(0,1,1) If $a = 0 Then filewriteline('0.txt',$a & @CRLF) If $a = 1 Then filewriteline('1.txt',$a & @CRLF) Next $CountLines0 = _FileCountLines("0.txt") $CountLines1 = _FileCountLines("1.txt") If $CountLines0 > $CountLines1 Then filewriteline('result0.txt',0 & @CRLF) If $CountLines0 < $CountLines1 Then filewriteline('result1.txt',1 & @CRLF) FileDelete('0.txt') FileDelete('1.txt') Next $CountLines0_ = _FileCountLines("result0.txt") $CountLines1_ = _FileCountLines("result1.txt") If $CountLines0_ > $CountLines1_ Then ConsoleWrite (0 & ' ') $total0 = $total0 +1 EndIf If $CountLines0_ < $CountLines1_ Then ConsoleWrite (1 & ' ') $total1 = $total1 +1 EndIf FileDelete('result0.txt') FileDelete('result1.txt') Next ConsoleWrite (@CRLF & '--->$total 0 ' & $total0 & @CRLF & '--->$total 1 ' & $total1 & @CRLF)oÝ÷ Úȳz,¥©ì·)^ Edited February 11, 2009 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
James Posted February 11, 2009 Share Posted February 11, 2009 Why FileDelete('result0.txt') FileDelete('result0.txt') It's deleted once. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
weaponx Posted February 11, 2009 Share Posted February 11, 2009 Why are you even writing to a file? Just increment a counter for $zero or $one... Link to comment Share on other sites More sharing options...
goldenix Posted February 11, 2009 Author Share Posted February 11, 2009 Why FileDelete('result0.txt') FileDelete('result0.txt') It's deleted once.Just in case, if is not deleted first time. it is important, that none of the files exist after the main code starts. well you can remove those lines if you dont like them. Why are you even writing to a file? Just increment a counter for $zero or $one...Know what....I have no idea. When I wrote the code all was wery clear & all made sense to me. After looking at this now. I do not understand why I made it like this. I guess this makes more sense: $x=1 $y=1 For $i=1 to 100000 $a = Random(0,1,1) If $a = 0 Then $x = $x + 1 If $a = 1 Then $y = $y + 1 Next ConsoleWrite ('Zeros: ' & $x & @CRLF) ConsoleWrite ('One_s: ' & $y & @CRLF) My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
Xand3r Posted February 11, 2009 Share Posted February 11, 2009 look at the thread you made in the help forum and try to beat my example(i couldn't) Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
JRowe Posted February 12, 2009 Share Posted February 12, 2009 you can remove those lines if you dont like them. Best program comment ever. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] 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