Sunday, July 31, 2011

Encryption, Decryption and Artificial Intelligence

The word encryption brings back to me the memory of Dan Brown's book Digital Fortress, NSA, Enigma Machine, not to mention the special lecture I attended by my quantum professor, Dr. Paul Kwait on quantum encryption. But arent we missing out something? Yes the human brain, which has extra ordinary capability to encrypt and decipher data. When filling out short questionnaire for my study abroad program, I wrote about vividness of Chinese language. It amazes me that it have thousands of character and it takes fraction of milli-second for human brain to 'decipher' that data and convert it to a physical, or emotional object. Tell me about any computer that can do that. You might give me example of Watson, but you know that we are still years from coming across a computer that is as powerful as human brain.



This brings me to my new born excitement of natural language processing. I am excited to take CS221 from Stanford online. They are offering their pretty famous artificial intelligence class online for FREE. Its amazing how colleges are increasing their tuition on one side and on the other end there are lots of free classes that are being offered via Khan Academy, MIT OpenCourseWare, Stanford iTunes University, and many others. Even though I dont have intensive knowledge of Liner Algebra I am trying to crunch in quick lectures about them from Khan Academy before the class starts so that I can successfully complete the class. Any one can take the class, I highly recommend that you do if you have time. Here is the link: ai-class.com

Thursday, November 11, 2010

Emotional Intelligence

According to me emotional intelligence is the mastery of self control. We have to learn to control our emotions at times and at times we have to let them flow freely. The act of controlling the valve of emotions is emotional intelligence. The better control we have the more intelligent we are emotionally.

In todays world emotional intelligence is key to living a happy life. A boss cannot act the way he wants with everyone, he should have control on his emotions and treat everyone as he wants to be treated himself. There is great saying in Bhagvad Gita that we should treat everyone equally, even animals if we want ourselves to be treated fairly. There is lot of advice that one can find in ancient scriptures about emotional intelligence. It seems that even in ancient times they understood the importance of emotional intelligence.

Comparing emotional intelligence with normal intelligence, emotional intelligence out weights the later one by far heavier weight difference. Having only intelligence is not enough to live a happy life. One can be very smart, but be living a unhappy life if he or she doesn't have emotional intelligence.

Saturday, October 23, 2010

Engineering Object: Computers

How would had been our life if there were no laptops or computers? Would I have been writing this blog post? Would you be reading it? Would you be sitting on the chair/couch you are sitting on (Probably, if it were handmade)

The point I am making is that mostly all the things that we use today have indirect connection to computers in some of the other way. Like the chair you are sitting on, if its not a handmade one then there is a pretty good chance that it was carved out by machine which was programmed using a computer. May be the chair was designed using a computer software. With computer our communication has become so easy. I have heard stories of my grandmother waiting for hours to get in contact with my grandfather who used to live across seven oceans for quite a while, but now we have Skype to chat within seconds.

We never think of a life without computers, because with the dependence that we have on them today it would simply be impossible to live. We take them for granted. Engineers have made it so cheap that almost everyone has it now. About couple years ago they were luxury only for the rich, but now everyone has it. Even if there is someone who doesnt has it can go to library and use it.

Laptops and computers are highly complicated on the inside, but we dont have to care about it because engineers have been successful in hiding the complex part by masking it with easy softwares so that even a two year old can use it.

Friday, October 22, 2010

Integrating ENG198 Lecture class with Lab class

The best wat I think can mdel almost all the missing basic is by adding certain component in the lab class it self.

For the steam car project we should be given all the materials, without the instruction guide. Then we should be told to design a steam car and in that we should be told to use the missing basics to design the car. We should be told to use labeling to label our plan. We should be told to use the presentation missing basics to make a presentation to make a presentation for our project. We should also be told to use the minimum number of parts, and thereby build a sellable design.

For the arduino project we should be encouraged to ask questions a lot of them about the working of the project and how it works.

Other ways we can integrate missing basics is by having workshops that can be helpful not only in teaching the missing basics, but also in practicing missing basics. Like in some workshops we should be told to design projects and then to label or present the projects.

Saturday, September 25, 2010

Time travel = REAL

Did I mention to you that I was at a boarding school from 8th to 10th grade? So at that boarding school I met this amazing Physics teacher who encouraged me to appreciate physics, he used to call me 'Archimedes' since I was the only kid in the class who was able to successfully understand Archimedes principle in eight grade.

Not only was he my physics teacher, but also our lunch head who used to seat at our lunch table to monitor our behavior and making sure that everything was going smoothly. I used to seat right next to him, and we used to talk a lot about physics. I used to ask him question and he used to shoot out answers as if he had engulfed the physics encyclopedia along with Google's algorithm to search answer for him instantly. Sometimes the question used to be about fighter jets, sometimes about oil floating on water.

Until I asked my teacher the ultimate question, I didn't knew why Einstein was so famous. All I knew was that Einstein was probably a really smart guy because his name was used a synonym for genius. Oh, one other thing I knew about Einstein was E=MC^2, though I didn't understand what the formula was trying to convey.

One fine afternoon at lunch, I asked my physics teacher about Einstein. I demanded to be read all the articles about Einstein from his 'encyclopedia.' To answer my question it took him almost rest of the year. Everyday he used to come up with new stories about Einstein. The most interesting thing that we talked about was Relativity. I was awestruck by the fact that if we traveled fast enough, in this case close to speed of light then we can time travel into the future.

That question about Einstein made me interested in Physics and thats the reason I am a Physics major. Though now I might be thinking of changing to Electrical Engineering, the inspiration from the Einstein question was enough to help appreciate physics, and get 5s on my AP exams

Thursday, September 16, 2010

Trivial initiatives do matter

This past week we were given a group project in the writing class. The project was to form a research question to answer which we would have to do observation of a public activity. To complete the project we had to dedicate significant amount of time outside the class as a group.

No one in the group was ready to bring up the discussion about the time to meet up, so I took the initiative to bring that up. Since we are in college unlike high school our schedule might not coincide, so I started by asking for the best day of the week when they were free. Finally we decided to meet on a Saturday afternoon. It might seem that taking initiative to decide the time to meet is trivial, it really isnt. If I had not taken the initiative to decide the time of meeting during the class, then at the end we would had to decide the time hastily. And in hastiness many of us would had agreed to a random time only to realize later that we had something else planned for that time.

Another initiative that I took while working on the same project was to introduce the group to google docs. Google docs is a useful tool that can be used to create documents with great collaboration without taking distance into consideration. I took the initiative to explain them that while everyone can work on the same document from their laptops. It came out to be very useful, because instead of each of us writing our own version and then later on collaborating in to one version we were able to work on a single version from start to end. We were able to save precious man hours and at the time we were able to produce better output.

Someone else in my place would had ignored to take the initiative to introduce the group to google docs, because of the explanation that was involved. But I was courageous enough to take the initiative.

Saturday, September 4, 2010

My iEngineering Ambition

I was really excited when I got accepted to University of Illinois after being rejected to some of the other best engineering school. I had assumed that I was going to get rejected even from University of Illinois, but it didnt happen. After I got accepted to U of I, I was invited to apply for iEFX. I was really excited about that too.

Even though right now its been just two weeks since the iEFX started, I am sure that it is going to have big impact on my college career. I have pinned down three main 'abilities' that I want to learn through out the course and the way I would like to achieve them.

Firstly I would like to learn how to weld. When I was in 8th grade I wanted to motorize my bike, but due to inability to weld I wasnt able to accomplish my goal. Now I want to learn how to weld and rework on the old project. I would love to take a class on metal workshop, but I dont that we have any, so another way that I can learn this is through iTeam. I can convince my team members and we can set up a workshop for learning to weld.

Another thing I want to learn is to learn Matlab. Its the one of the most important software that is required for data analysis and research. Again this can be achieved in the same way as the one before. In this I can actually go to other seminars that they have in the college of engineering, and I can also take CS 101 to learn about it.

Finally the third thing I want to do is to socialize with people from different background. This is really important to gain more knowledge because there is always something to learn from everyone. I can achieve this by taking classes in different colleges and I can also attend social events.

When I look at the things that I want to learn this semester I think that they will make me more capable. It will contribute to make me a more capable engineer who has the missing basics.

Sunday, February 7, 2010

West Point Bridge Design Competition

I have taken part in West Point Bridge Design Competition, it is an open competition for all the legal American Students. I am a participant from the mid-west zone. I am a individual participant and my currently my team standing is 185/279. It has taken me just one day to jump from 206 to 189. This is the first time I am designing a bridge and I am learning new concepts like Stress, tension, tear force, etc.

Friday, November 20, 2009

Tech Day, Illinois State University.





Category: Innovation and Invention
Task: To make a device that releases the ball to a minimum of 12inch and the ball should return to the initial position. Repeat the process as many times as possible under 30 seconds.

Plan:


Forgive for the bad handwriting we had only 1.5 hour to complete the whole design our mouse trap broke in midst of the construction. * Colors are inverted to make it more clearer
_______________________________________________________________________________________
Design parts:
1. Cone to catch the ball: We made an enormous cone of about  6inch in diameter. It wasnt exactly in a conical shape, but it was able to catch the ball efficiently.
2.Mouse Trap shooter: We used the mouse trap to shoot the ball at the cone. We figured out that the mouse trap was shooting with more force than we need it to so we used couple of rubber bands on the opposite side to reduce the force.
3. Feeder pipe: This was probably the hardest thing to design because it was very time consuming task to make the pipe turn and also to make.

Difficulties faced:
1. Mouse Trap Broken: Our mouse trap broke just an half an hour before the due time.  We did not waste time getting a new one but instead we glued it and instead of using force from spring we solely used to force from the rubberbands.
2. Feeder pipe: It was taking us a lot of time to make the feeder pipe turn therefore, instead of making the whole pipe turn we made a curved wall to guide the ball back to its position.

Results:
First Trial: 8shoots in 30 seconds ~ 0.27 shoots/sec
Second trial: 15 shoots in 30 seconds ~ 0.5 shoots/sec

Competition highest: 22 shoots in 30 seconds ~ 0.73 shoots/sec

Lessons learned:
We had an efficient design but unlike the best design out ball took a longer route i.e. swirling through the cone  to the pipe to the starting place. The best design had ball going up and down the same slope! I appreciate the best design and I am happy that they were from my school!

More Pictures:


 
 
In all the pictures the mouse trap is unloaded.

Friday, October 30, 2009

My Presentation at UIC for Chicago Android Group




This was the first presentation I ever gave in my life. And it was in front of experts. Most of them had PhD and I was the only high school student there. I joined this Chicago android group because I really want to promote “open sourceness”. I like android over other mobile os(OSX, Symbian, Palm OS, Blackberry) because it is open source use the firmware without violating any rules that other closed source OS have. My topic for the presentation was rooting Android phones(G1 and MyTouch). Rooting basically means that the software on the phone gets access to certain core data structures and is allowed to manipulate them. Rooting is NOT equal to hacking, and android is open source firmware so any one can tweak according to his needs .

Wednesday, September 30, 2009

Home made speaker casing made with lego....





These are the pictures of the speaker case that I made for speaker my uncle was throwing away. I was going to make a dock for 3.5mm jack but ran out of blocks.
PROCEDURE that I FOLLOWED
1.Try to unscrew the speakers and safely conserve the circuit.
2.To closely remodel the plastic I used heated knife.
3. Try to make a strong case for the speakers using lego in preferable shape you want.
4. While making case keep in mind the dimensions of the speaker so that they fit in.
5.I made base broader then the top so that the speakers stay intact.
6. I implanted 2 speakers in 1

rpg_char.java

public class rpg_char
{
private String name = "Default";
private int money = 0;
private int health = 10;
private int maxhealth = 10;
private int exp = 0;
private int nextlevel = 10;
private int level = 1;
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
private int defence = 0;
private int attack = 0;

public rpg_char(String name2, int money2, int exp2, int nextlevel2, int level, int health2, int maxhealth2, int defence2, int attack2)
{
name = name2;
money = money2;
exp = exp2;
nextlevel = nextlevel2;
health = health2;
maxhealth = maxhealth2;
defence = defence2;
attack = attack2;
}
public void set_name(String newname) { name = newname; }
public void set_health(int s_health) { health = s_health; }
public void set_maxhealth(int s_maxhealth) { maxhealth = s_maxhealth; }
public void set_exp(int s_exp) { exp = s_exp; }
public void set_nextlevel(int s_nxtlvl) { nextlevel = s_nxtlvl; }
public void set_money(int s_money) { money = s_money; }
public void set_att(int s_att) { attack = s_att; }
public void set_def(int s_def) { defence = s_def; }
public void update_H(int newMax, int regen_percent)
{
int regen_amount = maxhealth*(regen_percent/100);
maxhealth = newMax;
if( (health + regen_amount) < maxhealth)
{
health += regen_amount;
}
else
{
health = maxhealth;
}
}
public void update_E(int addExp)
{
if( (exp + addExp) < nextlevel)
{
exp += addExp;
}
else
{
addExp = (exp+addExp) - nextlevel;
levelup(addExp);
}
}
public void update_M(int addMoney)
{
money += addMoney;
}
public void update_A(int addAtt)
{
attack += addAtt;
}
public void update_D(int addDef)
{
defence += addDef;
}
public void levelup(int expleft)
{
int statsup1 = (int)(Math.random()*3);
int statsup2 = (int)(Math.random()*3);
if(statsup1 == 3)statsup1 = (int)(Math.random()*3);
if(statsup2 == 3)statsup2 = (int)(Math.random()*3);
attack += statsup1;
defence += statsup2;
update_H( (maxhealth + statsup1), (int)(Math.random()*maxhealth) );
nextlevel += (int)(Math.random()*nextlevel);
update_E(expleft);
}
public String get_name() {return name;}
public int getMoney() {return money;}
public int getHealth() {return health;}
public int getMaxHealth() {return maxhealth;}
public int getExp() {return exp;}
public int getNextLevel() {return nextlevel;}
public int getDef() {return defence;}
public int getAtt() {return attack;}
}

Room.java

import java.util.ArrayList;
public class Room
{
public String name;
public String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public ArrayList items = new ArrayList();
public ArrayList exits = new ArrayList();
public ArrayList monsters = new ArrayList();
public Room(String n, String d)
{
name = n;
description = d;
}
public int calc_numExits()
{
int out = 0;
for(int i = 0; i < exits.size(); i++)
{
if(exits.get(i)!=null)
{
out++;
}
}
return out;
}
}

Main_char.java

class Main_char extends rpg_char
{
public Main_char(String name2, int money2, int exp2, int nextlevel2, int level, int health2, int maxhealth2, int defence2, int attack2, Room start)
{
super(name2, money2, exp2, nextlevel2, level, health2, maxhealth2, defence2, attack2);
current[0] = start;
}
public Inventory bag = new Inventory(10);
public Hand Right;
public Hand Left;
public Room[] current = new Room[1];
}

Item.java

import java.util.ArrayList;
enum type {KEY, ARMOR, WEAPON, POTION}
enum armor_type {RING, NECKLACE, MEDDALION, AMULET, GLOVES, LEGGINGS, BODYARMOR}
enum armor_str {NULL, WEAK, OK, DECENT, MEDIUM, GOOD, STRONG}
enum wep_type {DAGGER, CLUB, SWORD, AXE, WARHAMMER, BATTLEAXE}
enum wep_str {NULL, WEAK, OK, DECENT, MEDIUM, GOOD, STRONG}
enum potion_type {NULL, ACID, POISON, HEALTH}
enum potion_str {NULL, WEAK, MEDIUM, STRONG}
enum key_doors {}
public class Item
{

public Item(String n, String d)
{
types.add("key");
types.add("armor");
types.add("weapon");
types.add("potion");
armor_types.add("ring");
armor_types.add("necklace");
armor_types.add("maddalion");
armor_types.add("amulet");
armor_types.add("leggings");
armor_types.add("body armor");
armor_strs.add("zero");
armor_strs.add("weak");
armor_strs.add("ok");
armor_strs.add("decent");
armor_strs.add("medium");
armor_strs.add("good");
armor_strs.add("strong");
weapon_types.add("dagger");
weapon_types.add("club");
weapon_types.add("sword");
weapon_types.add("axe");
weapon_types.add("war hammer");
weapon_types.add("battle axe");
weapon_strs.add("zero");
weapon_strs.add("weak");
weapon_strs.add("ok");
weapon_strs.add("decent");
weapon_strs.add("medium");
weapon_strs.add("good");
weapon_strs.add("strong");
potion_types.add("empty");
potion_types.add("acid");
potion_types.add("poison");
potion_types.add("health");
potion_strs.add("zero");
potion_strs.add("weak");
potion_strs.add("medium");
potion_strs.add("strong");
name = n;
description = d;
}


public type getItemType() {
return itemType;
}


public void setItemType(type itemType) {
this.itemType = itemType;
}


public armor_type getArmorType() {
return armorType;
}


public void setArmorType(armor_type armorType) {
this.armorType = armorType;
}


public armor_str getArmorStr() {
return armorStr;
}


public void setArmorStr(armor_str armorStr) {
this.armorStr = armorStr;
}


public wep_type getWepType() {
return wepType;
}


public void setWepType(wep_type wepType) {
this.wepType = wepType;
}


public wep_str getWepStr() {
return wepStr;
}


public void setWepStr(wep_str wepStr) {
this.wepStr = wepStr;
}


public String getName() {
return name;
}


public String name = "";
public String description = "There is nothing special about this item.";
private type itemType;
private armor_type armorType;
private armor_str armorStr;
private wep_type wepType;
private potion_type potionType;
private potion_str potionStr;
private key_doors location;
private wep_str wepStr;
private int wepDam;
private int armorProtec;
private int potionPow;
public ArrayList types = new ArrayList();
public ArrayList armor_types = new ArrayList();
public ArrayList armor_strs = new ArrayList();
public ArrayList weapon_types = new ArrayList();
public ArrayList weapon_strs = new ArrayList();
public ArrayList potion_types = new ArrayList();
public ArrayList potion_strs = new ArrayList();
public ArrayList doors = new ArrayList();
public boolean canPickup = true;
public ArrayList get_type()
{
ArrayList outTypeInfo = new ArrayList();
outTypeInfo.add(itemType);
switch(itemType)
{
case KEY:
{
outTypeInfo.add(location);
}
case ARMOR:
{
outTypeInfo.add(armorType);
}
case WEAPON:
{
outTypeInfo.add(wepType);
}
case POTION:
{
outTypeInfo.add(potionType);
}
}
return outTypeInfo;
}
public void calc_wepInfo()
{
switch(wepType)
{
case DAGGER:
{
int start = 1;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(wepStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
wepDam = start - variation;
}
case CLUB:
{
int start = 2;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(wepStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
wepDam = start - variation;
}
case SWORD:
{
int start = 4;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(wepStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
wepDam = start - variation;
}
case AXE:
{
int start = 3;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(wepStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
wepDam = start - variation;
}
case WARHAMMER:
{
int start = 5;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(wepStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
wepDam = start - variation;
}
case BATTLEAXE:
{
int start = 5;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(wepStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
wepDam = start - variation;
}
}
if(wepDam < 0)
{
wepDam = 0;
}
}
public void calc_armorInfo()
{
switch(armorType)
{
case RING:
{
int start = 1;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
case NECKLACE:
{
int start = 2;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
case MEDDALION:
{
int start = 2;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
case AMULET:
{
int start = 2;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
case GLOVES:
{
int start = 3;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
case LEGGINGS:
{
int start = 4;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
case BODYARMOR:
{
int start = 5;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*7)) + (Math.random()*(start*7)) )/2) - (int)(Math.random()*3) );
switch(armorStr)
{
case NULL:
{
start *= 0;
}
case WEAK:
{
start *= 1;
}
case OK:
{
start *= 2;
}
case DECENT:
{
start *= 3;
}
case MEDIUM:
{
start *= 4;
}
case GOOD:
{
start *= 5;
}
case STRONG:
{
start *= 6;
}
}
armorProtec = start - variation;
}
}
if(armorProtec < 0)
{
armorProtec = 0;
}
}
public void calc_potionInfo()
{
switch(potionType)
{
case NULL:
{
potionPow = 0;
}
case ACID:
{
int start = 3;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*5)) + (Math.random()*(start*5)) )/2) - (int)(Math.random()*3) );
switch(potionStr)
{
case NULL:
{
potionPow = 0;
}
case WEAK:
{
start*=2;
}
case MEDIUM:
{
start*=5;
}
case STRONG:
{
start*=10;
}
}
potionPow = start - variation;
}
case POISON:
{
int start = 3;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*5)) + (Math.random()*(start*5)) )/2) - (int)(Math.random()*3) );
switch(potionStr)
{
case NULL:
{
potionPow = 0;
}
case WEAK:
{
start*=2;
}
case MEDIUM:
{
start*=5;
}
case STRONG:
{
start*=10;
}
}
potionPow = start - variation;
}
case HEALTH:
{
int start = 1;
int variation = 0;
variation = (int) ( (( (Math.random()*(start*5)) + (Math.random()*(start*5)) )/2) - (int)(Math.random()*3) );
switch(potionStr)
{
case NULL:
{
potionPow = 0;
}
case WEAK:
{
start*=2;
}
case MEDIUM:
{
start*=5;
}
case STRONG:
{
start*=10;
}
}
potionPow = start - variation;
}
}
}
}

Inventory.java

import java.util.ArrayList;
public class Inventory
{
private int size = 10;
private boolean full = false;
private boolean empty = true;
public ArrayList item = new ArrayList();

public Inventory(int s) {size = s;}
public boolean isfull() {space_left(); return full;}
public boolean isEmpty() {space_left(); return empty;}
public int num_held() {return item.size();}
public int max_held() {return size;}
public int space_left()
{
int room = size - item.size();
if(room==0){full = true;}else if(room==size){empty = true;}
return room;
}
public boolean add_item(Item a)
{
if(full){return false;}
//else if(item.size()==size){return false;}
else
{
item.add(a);
space_left();
return true;
}
}
public boolean remove_item(Item a)
{
if(item.size()==0){return false;}
item.remove(a);
space_left();
return true;
}
}

hand.java

public class Hand {
public Item Thumb;
public Item Index;
public Item Middle;
public Item Ring;
public Item Little;
public Item Whole;
boolean both;
}

My main class of Adventure game

import java.util.ArrayList;
import java.util.Scanner;
public class Main
{
/**
* This the main class of my game. I didnt have time to comment the whole program because I had to make this in 5days
*/
//terms
final static int NORTH = 0;
final static int SOUTH = 1;
final static int WEST = 2;
final static int EAST = 3;
//end terms
public static Main_char player = new Main_char("Player", 0, 0, 10, 0, 15, 15, 1, 1, null);
public static rpg_char Monster_1 = new rpg_char("Beast", 10, 10, 100, 1, 10, 10, 1, 1);
public static Room cave_entry = new Room("Cave Entance","You are at the entrance to a cave.");
public static Room cave_tunnel_1 = new Room("Cave Tunnel","You are in an underground tunnel.");
public static Room cave_tunnel_2 = new Room("Cave Tunnel","You are in an underground tunnel.");
public static Room cave_tunnel_3 = new Room("Cave Tunnel","You are in an underground tunnel.");
public static Room cave_tunnel_4 = new Room("Cave Tunnel","You are in an underground tunnel.");
public static Room cave_deadend_1 = new Room("A Dead End","You are at a dead end in an underground tunnel.");
public static Room cave_deadend_2 = new Room("A Dead End","You are at a dead end in an underground tunnel.");
public static Item knife_1 = new Item("knife","It's a very rusty knife.");
public static void main(String[] args)
{
System.out.print("Enter Your Name: ");
String n = new Scanner(System.in).nextLine();
player.set_name(n);
knife_1.canPickup = true;
knife_1.setWepType(wep_type.DAGGER);
knife_1.setWepStr(wep_str.WEAK);
knife_1.calc_wepInfo();
cave_entry.exits.add(NORTH, cave_tunnel_1);
cave_entry.exits.add(SOUTH, null);
cave_entry.exits.add(WEST, null);
cave_entry.exits.add(EAST, null);
cave_entry.items.add(knife_1);
player.current[0] = cave_entry;
cave_tunnel_1.exits.add(NORTH, cave_tunnel_2);
cave_tunnel_1.exits.add(SOUTH, cave_entry);
cave_tunnel_1.exits.add(WEST, null);
cave_tunnel_1.exits.add(EAST, null);
cave_tunnel_2.exits.add(NORTH, null);
cave_tunnel_2.exits.add(SOUTH, cave_tunnel_1);
cave_tunnel_2.exits.add(WEST, cave_tunnel_3);
cave_tunnel_2.exits.add(EAST, cave_tunnel_4);
cave_tunnel_3.exits.add(NORTH, null);
cave_tunnel_3.exits.add(SOUTH, null);
cave_tunnel_3.exits.add(WEST, cave_deadend_1);
cave_tunnel_3.exits.add(EAST, cave_tunnel_2);
cave_tunnel_4.exits.add(NORTH, null);
cave_tunnel_4.exits.add(SOUTH, null);
cave_tunnel_4.exits.add(WEST, cave_tunnel_2);
cave_tunnel_4.exits.add(EAST, cave_deadend_2);
cave_deadend_1.exits.add(NORTH, null);
cave_deadend_1.exits.add(SOUTH, null);
cave_deadend_1.exits.add(WEST, null);
cave_deadend_1.exits.add(EAST, cave_tunnel_3);
cave_deadend_2.exits.add(NORTH, null);
cave_deadend_2.exits.add(SOUTH, null);
cave_deadend_2.exits.add(WEST, cave_tunnel_4);
cave_deadend_2.exits.add(EAST, null);
cave_deadend_2.monsters.add(Monster_1);
look();
while(true)
{
String input = new Scanner(System.in).nextLine();
parseIn(input);
}
}
public static ArrayList str_div(String input, char divide)
{
ArrayList Words = new ArrayList();
String temp = "";
int tmp = 0;
for(int i = 0; i < input.length(); i++)
{
if(input.charAt(i)!=divide)
{
temp += input.charAt(i);
}
else
{
tmp=i;
Words.add(temp);
temp = "";
}
}
if(tmp!=0)
{
Words.add(input.substring(tmp + 1, input.length()));
}
else
{
Words.add(input.substring(tmp, input.length()));
}
return Words;
}
public static boolean move(int direction)
{
switch(direction)
{
case NORTH:
{
if(player.current[0].exits.get(NORTH) != null)
{
player.current[0] = player.current[0].exits.get(NORTH);
look();
return true;
}
else
{
return false;
}
}
case SOUTH:
{
if(player.current[0].exits.get(SOUTH) != null)
{
player.current[0] = player.current[0].exits.get(SOUTH);
look();
return true;
}
else
{
return false;
}
}
case WEST:
{
if(player.current[0].exits.get(WEST) != null)
{
player.current[0] = player.current[0].exits.get(WEST);
look();
return true;
}
else
{
return false;
}
}
case EAST:
{
if(player.current[0].exits.get(EAST) != null)
{
player.current[0] = player.current[0].exits.get(EAST);
look();
return true;
}
else
{
return false;
}
}
default:
{
return false;
}
}

}
public static void look()
{
System.out.println(player.current[0].name);
System.out.println(player.current[0].description);
String exits = "";
switch(player.current[0].calc_numExits())
{
case 1:
{
exits = "You can go to the ";
if( player.current[0].exits.get(NORTH) != null)
{
exits+="north.";
}
else if( player.current[0].exits.get(SOUTH) != null)
{
exits+="south.";
}
else if( player.current[0].exits.get(EAST) != null)
{
exits+="east.";
}
else if( player.current[0].exits.get(WEST) != null)
{
exits+="west.";
}
break;
}
case 2:
{
exits = "You can go to the ";
if( player.current[0].exits.get(NORTH) != null)
{
exits+="north and ";
if( player.current[0].exits.get(SOUTH) != null)
{
exits+="south.";
}
else if( player.current[0].exits.get(EAST) != null)
{
exits+="east.";
}
else if( player.current[0].exits.get(WEST) != null)
{
exits+="west.";
}
}
else if( player.current[0].exits.get(SOUTH) != null)
{
exits+="south and ";
if( player.current[0].exits.get(EAST) != null)
{
exits+="east.";
}
else if( player.current[0].exits.get(WEST) != null)
{
exits+="west.";
}
}
else if( player.current[0].exits.get(EAST) != null)
{
exits+="east and west.";
}
break;
}
case 3:
{
exits = "You can go to the ";
if( player.current[0].exits.get(NORTH) != null)
{
exits+="north, ";
if( player.current[0].exits.get(SOUTH) != null)
{
exits+="south, and ";
if( player.current[0].exits.get(EAST) != null)
{
exits+="east.";
}
else if( player.current[0].exits.get(WEST) != null)
{
exits+="west.";
}
}
else if( player.current[0].exits.get(EAST) != null)
{
exits+="east, and west";
}
}
else if( player.current[0].exits.get(SOUTH) != null)
{
exits+="south, east, and west.";
}
break;
}
case 4:
{
exits = "You can go to the north, south, east, and west.";
break;
}
}
System.out.println(exits);
String curitem = "You see ";
if(player.current[0].items.size()>1)
{
for(int i = 0; i < player.current[0].items.size()-1; i++)
{
curitem += "a " + player.current[0].items.get(i).name + ", ";
}
curitem += "and a " + player.current[0].items.get(player.current[0].items.size()-1).name + " here.";
}
else if(player.current[0].items.size()==1)
{
curitem += "a " + player.current[0].items.get(0).name + " here.";
}
else
{
curitem = "There are no items here.";
}
System.out.println(curitem);
String curmon = "You see ";
if(player.current[0].monsters.size()>1)
{
for(int i = 0; i < player.current[0].monsters.size()-1; i++)
{
curmon += "a " + player.current[0].monsters.get(i).get_name() + ", ";
}
curmon += "and a " + player.current[0].monsters.get(player.current[0].monsters.size()-1).get_name() + " here.";
System.out.println(curmon);
}
else if(player.current[0].monsters.size()==1)
{
curmon += "a " + player.current[0].monsters.get(0).get_name() + " here.";
System.out.println(curmon);
}
}
public static void lookAt(String itemName)
{
int itemIndex = 0;
boolean hasItem = false;
for(int i = 0; i < player.current[0].items.size(); i++)
{
if(player.current[0].items.get(i).name.equals(itemName))
{
itemIndex = i;
hasItem = true;
break;
}
}
if(hasItem==false)
{
for(int i = 0; i < player.bag.item.size(); i++)
{
if(player.bag.item.get(i).name.equals(itemName))
{
itemIndex = i;
break;
}
}
if(hasItem==false)
{
System.out.println("You cannot look at a nonexistant item.");
}
else
{
System.out.println(player.current[0].items.get(itemIndex).description);
}
}
else
{
System.out.println(player.current[0].items.get(itemIndex).description);
}
}
public static void parseIn(String input)
{
ArrayList parseMe = str_div(input, ' ');
if(parseMe.get(0).equalsIgnoreCase("GO"))
{
if(parseMe.size()>1)
{
if(parseMe.get(1).equalsIgnoreCase("NORTH") || parseMe.get(1).equalsIgnoreCase("N"))
{
if(!move(NORTH))
{
System.out.println("You cannot go north.");
}
}
else if(parseMe.get(1).equalsIgnoreCase("SOUTH") || parseMe.get(1).equalsIgnoreCase("S"))
{
if(!move(SOUTH))
{
System.out.println("You cannot go south.");
}
}
else if(parseMe.get(1).equalsIgnoreCase("EAST") || parseMe.get(1).equalsIgnoreCase("E"))
{
if(!move(EAST))
{
System.out.println("You cannot go east.");
}
}
else if(parseMe.get(1).equalsIgnoreCase("WEST") || parseMe.get(1).equalsIgnoreCase("W"))
{
if(!move(WEST))
{
System.out.println("You cannot go west.");
}
}
}
else
{
System.out.println("I don't know which direction you would like to go in.\nI don't read minds you know.");
}
}
else if(parseMe.get(0).equalsIgnoreCase("LOOK"))
{
if(parseMe.size()>1)
{
if(parseMe.get(1).equalsIgnoreCase("AT"))
{
if(parseMe.size()>2)
{
lookAt(parseMe.get(2));
}
else
{
System.out.println("I don't have any idea of what you would like to look at.\nI don't read minds you know.");
}
}
else
{
System.out.println("I do not understand your gibberish.");
}
}
else
{
look();
}
}
else if(parseMe.get(0).equalsIgnoreCase("INVENTORY") || parseMe.get(0).equalsIgnoreCase("INV"))
{
player.bag.space_left();
if(player.bag.isEmpty())
{
System.out.println("Your inventory is empty.");
System.out.println("You have " + player.bag.space_left() + " spaces left");
}
else
{
for(int i = 0; i < player.bag.item.size(); i++)
{
System.out.println(player.bag.item.get(i).name);
}
System.out.println("You have " + player.bag.space_left() + " spaces left");
}
}
else if(parseMe.get(0).equalsIgnoreCase("TAKE"))
{
int itemIndex = 0;
boolean hasItem = false;
player.bag.space_left();
if(parseMe.size()>1)
{
for(int i = 0; i < player.current[0].items.size(); i++)
{
if(player.current[0].items.get(i).name.equalsIgnoreCase(parseMe.get(1)))
{
itemIndex = i;
hasItem = true;
break;
}
}
if(hasItem==false)
{
for(int i = 0; i < player.bag.item.size(); i++)
{
if(player.bag.item.get(i).name.equalsIgnoreCase(parseMe.get(1)))
{
itemIndex = i;
hasItem = true;
break;
}
}
if(hasItem==false)
{
System.out.println("You cannot take a nonexistant item.");
}
else
{
System.out.println("You already have the " + player.bag.item.get(itemIndex).name);
}
}
else
{

player.bag.add_item(player.current[0].items.get(itemIndex));
player.current[0].items.remove(itemIndex);
System.out.println("You took the " + parseMe.get(1));
}
}
else
{
System.out.println("I don't have any idea of what you would like to take.\nI don't read minds you know.");
}
}
else if(parseMe.get(0).equalsIgnoreCase("DROP"))
{
int itemIndex = 0;
boolean hasItem = false;
player.bag.space_left();
if(parseMe.size()>1)
{
for(int i = 0; i < player.bag.item.size(); i++)
{
if(player.bag.item.get(i).name.equals(parseMe.get(1)))
{
itemIndex = i;
hasItem = true;
break;
}
}
if(hasItem==false)
{
for(int i = 0; i < player.current[0].items.size(); i++)
{
if(player.current[0].items.get(i).name.equals(parseMe.get(1)))
{
itemIndex = i;
break;
}
}
if(hasItem==false)
{
System.out.println("You cannot drop a nonexistant item.");
}
else
{
System.out.println("You do not have the " + player.bag.item.get(itemIndex).name);
}
}
else
{
player.current[0].items.add(player.bag.item.get(itemIndex));
player.bag.remove_item(player.bag.item.get(itemIndex));
System.out.println("You dropped the " + parseMe.get(1));
}
}
else
{
System.out.println("I don't have any idea of what you would like to drop.\nI don't read minds you know.");
}
}
else if(parseMe.get(0).equalsIgnoreCase("FIGHT") || parseMe.get(0).equalsIgnoreCase("ATTACK"))
{
if(parseMe.size() > 1)
{
fight(parseMe.get(1));
}
else
{
System.out.println("What in the world did you want to attack.\nPlease be more specific next time.");
}
}
else if(parseMe.get(0).equalsIgnoreCase("HELP") || parseMe.get(0).equals("?"))
{
help();
}
else if(parseMe.get(0).equalsIgnoreCase("EXIT") || parseMe.get(0).equalsIgnoreCase("QUIT"))
{
System.out.println("Good Bye!");
System.exit(0);
}
else
{
System.out.println("I do not know the command " + parseMe.get(0) + ".");
}
}
public static void help()
{
ArrayList cmds = new ArrayList();
ArrayList cmds2 = new ArrayList();
cmds.add("go ");
cmds2.add("moves you in direction");
cmds.add("look");
cmds2.add("prints a description of where you are");
cmds.add("look at ");
cmds2.add("prints a description of ");
cmds.add("inventory");
cmds2.add("tells you what you are carrying");
cmds.add("take");
cmds2.add("takes an item from the room and adds it to your inventory");
cmds.add("drop");
cmds2.add("drops an item from your inventory in the room");
cmds.add("help");
cmds2.add("prints this list out");
cmds.add("exit");
cmds2.add("leaves the game");
cmds.add("quit");
cmds2.add("same as exit");
for(int i = 0; i < cmds.size(); i++)
{
System.out.println(cmds.get(i));
System.out.println(cmds2.get(i) + ".\n");
}
}
public static void fight(String monster)
{
rpg_char[] Monster = new rpg_char[1];
boolean found = false;
int monsterIndex = 0;
for(int i = 0; i < player.current[0].monsters.size(); i++)
{
if(player.current[0].monsters.get(i).get_name().equalsIgnoreCase(monster))
{
Monster[0] = player.current[0].monsters.get(i);
found = true;
monsterIndex = i;
break;
}
}
if(found == false)
{
System.out.println("The monster " + monster + " could not be found.");
return;
}
while(Monster[0].getHealth()>0 && player.getHealth()>0)
{
System.out.println(Monster[0].get_name() + " lvl: " + Monster[0].getLevel() + "\n Att: " + Monster[0].getAtt() + " Def: " + Monster[0].getDef() + " Health: " + Monster[0].getHealth());
System.out.println(player.get_name() + " lvl: " + player.getLevel() + "\n Att: " + player.getAtt() + " Def: " + player.getDef() + " Health: " + player.getHealth());
System.out.println("You can attack or run.");
String input = new Scanner(System.in).nextLine();
int intdata = parseIn_F(input);
if(intdata == 0)
{
int val1 = (int)(player.getAtt()*(Math.random()*3));
int val2 = (int)(Monster[0].getAtt()*(Math.random()*3));
val1 -= Monster[0].getDef();
val2 -= player.getDef();
if(val1 < 0) {val1 = 0;}
if(val2 < 0) {val2 = 0;}
player.set_health((player.getHealth() - val2));
Monster[0].set_health((Monster[0].getHealth() - val1));
}
else if(intdata == 1)
{
break;
}
else
{
System.out.println("Invalid Input");
}
System.out.println();
}
if(player.getHealth() > 0 && Monster[0].getHealth() > 0)
{
System.out.println("You run away.");
}
else if(player.getHealth() > 0)
{
System.out.println("You beat the " + Monster[0].get_name());
//player.current[0].monsters.remove(monsterIndex);
player.current[0].monsters.get(monsterIndex).set_health(player.current[0].monsters.get(monsterIndex).getMaxHealth());
look();
player.update_E(Monster[0].getExp());
player.update_M(Monster[0].getMoney());
}
else
{
System.out.println("You got beaten by the " + Monster[0].get_name() + ".\nYou awaken outside the cave.");
player.current[0] = cave_entry;
player.set_health(player.getMaxHealth());
look();
Monster[0].update_E(player.getExp());
Monster[0].update_M(player.getMoney());
}
}
public static int parseIn_F(String input)
{
ArrayList parseMe = str_div(input, ' ');
if(parseMe.get(0).equalsIgnoreCase("fight") || parseMe.get(0).equalsIgnoreCase("attack"))
{
return 0;
}
else if(parseMe.get(0).equalsIgnoreCase("run"))
{
return 1;
}
else
{
return 2;
}
}
}