Jump to content

Mind Game


goldenix
 Share

Recommended Posts

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]
Link to comment
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]
Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...