Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Sunday, 19 July 2015

simulating connectionist networking using cell like balls

I'm interested in new ways of computing, particularly connectionist networks. One such way is not to emulate connectionist networks through computeres, but to physically make one.

My new idea is to make the building blocks (nodes) of connectionist networks; small, simply and cheap enabling mass production. Each node requires power for processing and communication transmission, and a way of communicating. These nodes can then be put in a volume and the network is made.

The difficulty of powering a network like this is that this power distribution would get in the way of the communication and would have to be built into each node, so that they can pass the power over to adjacent nodes.

One idea is to cover the node in a conductor, and when the surface touches both a positive and negative ..... it can be powered. This way you can fill a volume with these nodes and only provide provide electrical power to the outer nodes. The outer nodes touching their neighbours and so on, passing the charge.

Communication has to be done through another medium so as not to complicate or interfere with power distribution. The medium which seems best suited is light. With the advances in optics and commincation through optics this method seems the best answer. At its' very simplist, there are LED lights in a sepherical distribution around the node, and also light recieving devices surrounding each node.

Each node is powered by being next to a powered node. It can send and recieve signals from it's neighbours through light.

One drawback in using light is that it will have to be converted at the beginning and end nodes, to electrical signals.

Thursday, 11 June 2015

C++ Programming compression - Step 1 - reading and writing to a file

After installing Netbeans for windows (previous post) the first stage of making my compression program is to read and write text files. Ultimately, to read a file, compress it (0% to start with -  might actually be larger) and then uncompress it to the original contents. Really want to make a self extracting compressed file. Not sure at what point to implement this. The earlier in the project the better I thinks.

First things first - read and write to files. Found this tutorial using Visual Studio, but can't be too different.

ifstream
ofstream

Found this tutorial on it as well, but you can copy and paste this one. Here's the program I wrote to read a file, and write to a file (although couldn't get it to create a file):

/* 
 * File:   main.cpp
 * Author: Supermonkey
 *
 * Created on 27 May 2015, 07:16
 */

#include 
#include 
#include 
#include 
using namespace std;


void readFile(string filename);
void writeFile(string filename);
/*
 * 
 */
int main(int argc, char** argv) {

    string readFilename = "newhtml.html";
    string newFilename = "newtxt.txt";
    
    readFile(readFilename);
    writeFile(newFilename);
    
    return 0;
}

void readFile(string filename) {
    
    string line;
    ifstream myfile ("newhtml.html");

    if (myfile.is_open()){
      while ( getline (myfile,line) ){
        cout << line << '\n';
      }
      myfile.close();
    }
    else cout << "Unable to open file"; 
  
  

  //return 0;
    
}

void writeFile(string filename) {
  ofstream myfile ("newhtml1.html");
  if (myfile.is_open())
  {
    myfile << "This is a line.\n";
    myfile << "This is another line.\n";
    myfile.close();
  }
  else cout << "Unable to open file";
  //return 0;
}




Managed to find this forum on why I couldn't pass a string into the ifstream and ofstream perameters. To get it to work you have to convert the C++ string to std:string :

ifstream myfile (filename.c_str()); 

I've now created a couple of functions which read a line from one file, and write it to another. I found this explination of how to append to a file, as with the above code it would only wipe the file and replace contents with the last line.

void readWriteFile (string readFile, string writeFile) {
    string line;
    ifstream myfile (readFile.c_str());

    if (myfile.is_open()){
      while ( getline (myfile,line) ){
        cout << line << '\n';
        writeLineToFile (line, writeFile);
      }
      myfile.close();
    }
    else cout << "Unable to open file"; 
}

void writeLineToFile (string line, string writeFile) {
  ofstream myNewfile;
  myNewfile.open (writeFile.c_str(), std::ofstream::out | std::ofstream::app);
  if (myNewfile.is_open())
  {
    myNewfile << line << "\n";
    myNewfile.close();
  }
  else cout << "Unable to open file";
  //return 0;
}