Make the computer randomely talk...

  • 4 Replies
  • 2472 Views
*

Mr.Fox

  • Bumblebee
  • **
  • 35
    • Dreamwalker Software
Make the computer randomely talk...
« on: July 31, 2016, 11:45:45 am »
OK, the title was a little misleading as I didn't know what to put, but basically the other day slightly tipsy and have A.I ideas floating around in my head, I decided, what if I run a program through random code to come up with legitimate words in English, then laughing to myself imagining scary results like "You will die in october" or something of that ilk, so I got to it. As a way for the program to understand what it a legitimate English word I downloaded a local text file and created the code.

It does this:

Loads the dictionary into memory
uses alphabetical characters a - z
runs a constant loop creating a random feed
generates a word size between 1 and 35 characters long
then, word size dependant, creates a random alphabetical character for each letter in the word
then, it compares the generated word to the dictionary, if it's valid, a log will be made (with time/date stamp) and continue, if not it'll just continue


Now, I am sure there are better ways to make this but I was tipsy when I coded it, I ran it through about 70,000,000 attempts and nothing! but, while statistically you may have more chance winning the lottery, it's still possibly to come up with a word, or several for that matter and I think it would be interested what the program/computer could say from completely randomly generated code.

I've zipped up the executable with dict http://www.filedropper.com/wordgenbycraigfox, please run it and give it a shot, could be interested results.

Let me know what you think, feel free to also make suggestions/improvements.

Code below:

Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Media;

namespace AI_word_gen
{
    class Program
    {
        static void Main(string[] args)
        {

            //---------------Load dict into mem------------------------------------
                 string dictionary = File.ReadAllText("wordsEn.txt");

           
            //---------------------generate random words---------------------------
            char[] alphabet = { 'a', 'b', 'c', 'd', 'e', 'f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
            int attempts = 0;

            while (true)
            {
                string sWord = " ";
               
                //random feed
                Random rnd = new Random();

                //generate a word size between 1 - 35
                int iwordSize = rnd.Next(1, 35);
               
                //perform a loop from word size generating a random alphabetical charater each iteration
                for (int i = 0; i < iwordSize; i++)
                {
                    int irandLetter = rnd.Next(1, 26);
                    sWord += alphabet[irandLetter];
                } sWord += " ";



                //--------------------compare words-------------------------------------
                if (dictionary.Contains(sWord))
                {
                    Console.WriteLine("Found: " + sWord + "on: " + DateTime.Now.ToString("dd-MM-yyyy @ HH:mm"));

                    System.IO.StreamWriter file = new System.IO.StreamWriter("results.txt");
                    file.WriteLine("Found: " + sWord + "on: " + DateTime.Now.ToString("dd-MM-yyyy @ HH:mm"));

                    file.Close();
                }

                Console.Title = "Attempts = " + attempts++ + " word = " + sWord;
            }



            Console.WriteLine("\nFINISHED");
            Console.ReadLine();
        }
       
    }
   
}


*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
Re: Make the computer randomely talk...
« Reply #1 on: July 31, 2016, 11:07:00 pm »
Kind of like the room full of monkeys typing Shakespeare.  8)

I'm not great at maths but 26 (English) letters in the alphabet means a huge variety of combinations or permutations.

Say a 10 letter word, from 26 letters is 19,275,223,968,000 permutations.

I used this page to work that out : http://stattrek.com/online-calculator/combinations-permutations.aspx

For your test you did 70000000/19,275,223,968,000 = 0.0000036316 % which is clearly the very tip of the iceberg.

What you did not reveal is how long your test ran for 70 million attempts. If it took all day then we might need to wait a few years  :D

You could cheat a bit and do each letter from left to right, then use the odds of one letter following the previous one to weed out letters that rarely appear together perhaps. Hmm. Or again (thinking of efficiency) go left to right one letter at a time. And after each letter check whether that pattern actually exists in English - ie is it leading to a word or not. If it's not, just start again.

Cool idea though, I like it. :)




*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1307
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: Make the computer randomely talk...
« Reply #2 on: August 01, 2016, 09:06:04 pm »
Perhaps just randomly pick words from a dictionary.

Dictionary:

0.  Apple
1.  Banana
2.  Cherry
3.  Date Plum

random_pick = from 0 to 3.

print Dictionary[random_pick]


Or else, for (perhaps) more fun (than brute forcing millions), I think...

Make two lists for:

vowels: a,e,i,o,u,
consonants: b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,v,w,x,y,z

And then do consonant-vowel-consonant, or vice-versa, etc.

There may be a greater probability of generating words from letters this way. 

What do you think?



« Last Edit: August 02, 2016, 03:27:32 am by 8pla.net »
My Very Enormous Monster Just Stopped Using Nine

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: Make the computer randomely talk...
« Reply #3 on: August 02, 2016, 01:58:02 am »
Could help it but this banter reminds me of one of my favorite episodes...



In the world of AI, it's the thought that counts!

*

Don Patrick

  • Trusty Member
  • ********
  • Replicant
  • *
  • 633
    • AI / robot merchandise
Re: Make the computer randomely talk...
« Reply #4 on: August 02, 2016, 08:59:46 am »
In poetry generation, people usually go with semi-random words, rather than letters. And use N-grams to line up words with some plausibility. But still fail to say something sensible.
CO2 retains heat. More CO2 in the air = hotter climate.

 


Will LLMs ever learn what is ... is?
by HS (Future of AI)
November 10, 2024, 06:28:10 pm
Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
Attempting Hydraulics
by MagnusWootton (Home Made Robots)
August 19, 2024, 04:03:23 am
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

412 Guests, 0 Users

Most Online Today: 507. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles