Sign in to follow this  
Followers 0
goldenix

Mind Game

6 posts in this topic

#1 ·  Posted (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 row

1 - 6 times in a row

Run the code once = 1 attempt.

Post your results please.

#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 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]

Share this post


Link to post
Share on other sites



Why are you even writing to a file? Just increment a counter for $zero or $one...

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Share this post


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
Sign in to follow this  
Followers 0