A new wind blows…

Well I promised I’d have my personal blog up soon and it has been longer than I intended but tonight I get a functional website up. Please let me be the first to welcome you to…

http://www.pro-graham.com (Okay, it might redirect here. Go go gadget DNS Server redirect!)

From here I plan to post snippets of code and programming related articles hoping to help people who have found comfort in the same field I currently occupy. My first post should be up this week detailing my advanced AI Battleship application you can play. The application was an extension of an old project I took up with a friend years ago. I recently updated the AI in it for one of my more recent classes as an example of heuristic analysis of grids allowing for advanced play.

Please bare with me as I get my documentation up to snuff and clean the code so I don’t embarass myself too much.

Grinding the Present Moment

Just dropping some little bombs. I don’t have any bunker busters at the moment.

Mental noise: I keep noticing how much noise there is in my head. Whenever I notice it, it disappears. This is a type of meditation that anyone can practice throughout the day. It’s important to note that having silence in your head does not make you a zombie. It makes you relaxed but more alert. Carrying a head full of noise does the opposite: it makes you tense and distracted. Being tense and distracted puts limits on what you can accomplish.

Grinding the present: I find it useful to remind myself that the present moment is the only place where anything gets done.

Free will & spontaneity: Back in the day, I busted some philosophy speed-runs with Shuba and his kin. The conclusion was that free will does not exist. Our brain is a calculator that solves problems by choosing the best option according to what we value. For example, a person who values standing out in a crowd is more likely to dress in unusual clothes, but their decisions are still made according to an underlying process which they have no control over. If you ask them why they are wearing a sombrero in February, they might tell you they are a free spirit when it comes to fashion. If free will does not exist, then they are simply bound by differently-assigned variables, and the sombrero is the end result of these different values.

This might sound like a depressing perspective on life, one which paints humans as souls imprisoned within robotic shells. Each human pursues whatever comes naturally to them; what is natural for one person is different for the next. Committing crimes comes naturally to some people. After waking up in jail, their brain might re-assign certain values and a “new person” may emerge from a brain that previously valued drugs and money above all else.

This is what I really wanted to discuss: does a person actually emerge from their thoughts? Your thoughts are a reflection of your values, which are not consciously controlled, and so the self which emerges from our thoughts is also uncontrolled. This artificial self is sometimes called the ego. It exists as an interface between the brain and the outside world. It is a structure of repetitive thoughts. When a person’s values change, their thoughts change, and so the ego changes; a “new person” emerges with a new purpose in life.

“Free will doesn’t exist?! You can’t take my freedom!”
The point is that (1) not only does free will not exist, but (2) there was never a self to “possess” free will in the first place.

” … First you take my freedom, and now you’re saying I don’t even exist?!”
Your true identity is inseparable from you because it is you. It cannot be taken away. The ego, on the other hand, is just a thought which disappears every night when you go to bed. The ego’s structure appears rock solid because it is so repetitive. When we examine this repetitive structure, however, we see that it is just mental noise. How could mental noise ever hope to have free will?

When illusions like the ego and free will are washed away, what’s left is real freedom – the selfless and perfect way of the universe.

World-building 101: Yo, enough of this pansy-ass philosophical mumbo-jumbo. Let’s get back into the real world so we can start building fake worlds. This is a new branch of learning for me, so it’s not really World-building 101. It’s more like World-building for Pre-schoolers. I’ve already put this project on hold so I can finish some older stuff, but I thought it’d be fun to post some noobfoolery in action.

(1) First, I used everyone’s favorite artsy program to make a 400 x 400 pixel masterpiece. Within moments, my phone was ringing off the hook. Every major art institute in North America was trying to throw scholarships my way, and I hadn’t even uploaded the mother yet.

Actually, I didn’t have a phone while making this.

(2) Next, I used Torque 3D’s terrain builder to upload my image as a texture. I slapped that beast down on top of some sand.

When creating worlds, it is important to nod your head to sick beats.

(3) Torque 3D has a default player character that you can use to explore right away.

Dude, you said we were going on a magical adventure… and now this?

The grass is the only thing that I created in that screenshot. It was a fun first step, and I’m looking forward to more advanced stuff like programming in TorqueScript and rendering my own 3D models.

Back to the grindstone.

A new frontier…

I’ve been tasked through one of my classes with designing and implementing an application that relies on a P2P protocol. I’ve done work programming a server for BitTorrent in previous assignments but I’m looking for a little public insight on this as to what I should do.

  • Is there something that people are looking for that they need coded?
  • Is there features in an application that you want but haven’t been able to find yet?
  • Is there a server feature that you wish would just come out already?

Let me know folks. I’m looking for some great ideas for something that I’m really looking forward to doing. Remember, this isn’t limited to BitTorrent’s protocol as P2P encompasses a wide range of applications and features. Shoot and I’ll see what ideas I like most.

As promised…

Now on my introduction I promised I’d be posting code samples of my work through school to help out students and I’m here to deliver. I’ve done a few things but this one I’m actually sort of proud of. Hardcore coders can find little issues with it (such as error correction) but it works very well. The code posted below is a custom script that you can use (almost) to replace bash on a linux system. I’ve dubbed it GShell and it should be able to handle almost all commands save the “cd” command. It currently doesn’t have any form of memory but we’ll be adding that in a future release.

What I really want to highlight here is the use of the pipe() function which allows us to pipe output from child processes to the parent in/out streams. I fought this one for a good while before correcting my error to get a working release. Take a look and let me know what you think.


#include
#include
#include //strcmp(), strtok(), strlen()
#include //fork(), execvp(), pipe(), dup2()
#include //wait()
//
const int MAX_SIZE = 255; //Maximum Size of call string currently allowed
const int MAX_ARGS = 8; //We allow up to 8 arguements
//
void main(int argc, char* argv[])
{
//Loop infinitely
while(1)
{
//Variables
char input_buffer[MAX_SIZE]; //Buffer for user input to our command line
char *args[MAX_ARGS+1]; //The arguments we pass to the new program. Allow 1 array for NULL
char *command; //String pointing to input buffer section holding command to execute
char *user_input; //String to hold input
//
int arg_count = 0; //Number of args provided
int ampersand = 0; //Is there an ampersand?
int c_status,status; //Status values for forking
//
//Execution
printf("GShell$ "); //Basic output
fflush(stdout); //Flush out output
//
//Read from input
fgets(input_buffer,MAX_SIZE,stdin); //Get input from stdin up to MAX_SIZE bytes and place in input_buffer
//
if (feof(stdin)) {
printf("Quitting... Goodbye\n");
exit(0);
}
//
//fgets grabs \n as well. We need to remove it and place NULL in there
if (input_buffer[0] != '\n') { //Simply repeat if we receive a blank input
user_input = input_buffer;
user_input[strlen(user_input)-1] = '\0'; //Terminate with a null
//
//We need to tokenize the input now to retrieve multiple arguments
//First grab the command name
char* token;
token = strtok(user_input," ");
//
//Quit when command is received
if ((strcmp(token,"exit") == 0) || (strcmp(token,"quit") == 0) || (strcmp(token,"logout") == 0)) {
printf("\nQuitting... Goodbye\n");
exit(0);
}
else { //This creates a token
command = token;
args[arg_count] = token;
arg_count++;
}
//
while (arg_count < MAX_ARGS) { //Repeat until we have max arguments or until quit with "break" token = strtok(NULL," "); //Continues to tokenize // //If there isn't any further tokens if (token == NULL || arg_count == MAX_ARGS+1) { args[arg_count] = NULL; break; } else if (strcmp(token,"&") == 0) { ampersand = 1; //Advise that we've detected the ampersand } else { args[arg_count] = token; arg_count++; } } // // We're done tokenizing the input. Time to get to the interesting stuff //Create pipe to fetch our outputs from process int pipeval[2], err; // if (pipe(pipeval) == -1) { perror("pipe error"); exit(1); } char* val[1024]; //First attempt a fork c_status = fork(); // if (c_status > 0) {
if (ampersand == 0) {
wait(&status);
}
}
else if (c_status == 0) {
//Child process
close(pipeval[0]);
dup2(pipeval[1],STDIN_FILENO);
close(pipeval[1]);
//
execvp(command,args);
_exit(1);
}
else {
printf("Fork Error.\n");
exit(1);
}
}
}
return;
}