Friday, 1 March 2013

Artificial Intelligence Basics

1) What is artificial intelligence?

A. It is the science and engineering of making intelligent machines, especially intelligent computer programs. It is related to the similar task of using computers to understand human intelligence, but AI does not have to confine itself to methods that are biologically observable.

2). Yes, but what is intelligence?

A. Intelligence is the computational part of the ability to achieve goals in the world. Varying kinds and degrees of intelligence occur in people, many animals and some machines.

3) What about other comparisons between human and computer intelligence? 


Arthur R. Jensen [Jen98], a leading researcher in human intelligence, suggests ``as a heuristic hypothesis'' that all normal humans have the same intellectual mechanisms and that differences in intelligence are related to ``quantitative biochemical and physiological conditions''. I see them as speed, short term memory, and the ability to form accurate and retrievable long term memories. 
Whether or not Jensen is right about human intelligence, the situation in AI today is the reverse. 
Computer programs have plenty of speed and memory but their abilities correspond to the intellectual mechanisms that program designers understand well enough to put in programs. Some abilities that children normally don't develop till they are teenagers may be in, and some abilities possessed by two year olds are still out. The matter is further complicated by the fact that the cognitive sciences still have not succeeded in determining exactly what the human abilities are. Very likely the organization of the intellectual mechanisms for AI can usefully be different from that in people. 
Whenever people do better than computers on some task or computers use a lot of computation to do as well as people, this demonstrates that the program designers lack understanding of the intellectual mechanisms required to do the task efficiently.

4) Does AI aim to put the human mind into the computer?

A. Some researchers say they have that objective, but maybe they are using the phrase metaphorically. The human mind has a lot of peculiarities, and I'm not sure anyone is serious about imitating all of them. 



5). Does AI aim at human-level intelligence?

A. Yes. The ultimate effort is to make computer programs that can solve problems and achieve goals in the world as well as humans. However, many people involved in particular research areas are much less ambitious.

6). How far is AI from reaching human-level intelligence? When will it happen?

A. A few people think that human-level intelligence can be achieved by writing large numbers of programs of the kind people are now writing and assembling vast knowledge bases of facts in the languages now used for expressing knowledge.

However, most AI researchers believe that new fundamental ideas are required, and therefore it cannot be predicted when human-level intelligence will be achieved.

7). Are computers the right kind of machine to be made intelligent?

A. Computers can be programmed to simulate any kind of machine. 
Many researchers invented non-computer machines, hoping that they would be intelligent in different ways than the computer programs could be. However, they usually simulate their invented machines on a computer and come to doubt that the new machine is worth building. Because many billions of dollars that have been spent in making computers faster and faster, another kind of machine would have to be very fast to perform better than a program on a computer simulating the machine.

8). Are computers fast enough to be intelligent?

A. Some people think much faster computers are required as well as new ideas. My own opinion is that the computers of 30 years ago were fast enough if only we knew how to program them. Of course, quite apart from the ambitions of AI researchers, computers will keep getting faster.

9). What about parallel machines?

A. Machines with many processors are much faster than single processors can be. Parallelism itself presents no advantages, and parallel machines are somewhat awkward to program. When extreme speed is required, it is necessary to face this awkwardness.

10). What about making a ``child machine'' that could improve by reading and by learning from experience?

A. This idea has been proposed many times, starting in the 1940s. Eventually, it will be made to work. However, AI programs haven't yet reached the level of being able to learn much of what a child learns from physical experience. Nor do present programs understand language well enough to learn much by reading.

11). Might an AI system be able to bootstrap itself to higher and higher level intelligence by thinking about AI?

A. I think yes, but we aren't yet at a level of AI at which this process can begin.

12). Don't some people say that AI is a bad idea?

A. The philosopher John Searle says that the idea of a non-biological machine being intelligent is incoherent. He proposes the Chinese room argument www-formal.stanford.edu/jmc/chinese.html The philosopher Hubert Dreyfus says that AI is impossible. The computer scientist Joseph Weizenbaum says the idea is obscene, anti-human and immoral. Various people have said that since artificial intelligence hasn't reached human level by now, it must be impossible. Still other people are disappointed that companies they invested in went bankrupt. 

 Source author:-  John McCarthy

Find the iPhone Device is JailBroken or not


Folow the code for find the iphone device jailbroken or not...



- (BOOL)isJailbroken
{
BOOL jailbroken = NO;
NSArray *jailbrokenPath = [NSArray arrayWithObjects:@"/Applications/Cydia.app",  @"/Applications/RockApp.app", @"/Applications/Icy.app",  @"/usr/sbin/sshd",  @"/usr/bin/sshd",  @"/usr/libexec/sftp-server", @"/Applications/WinterBoard.app",  @"/Applications/SBSettings.app",  @"/Applications/MxTube.app", @"/Applications/IntelliScreen.app",  @"/Library/MobileSubstrate/DynamicLibraries/Veency.plist", @"/Applications/FakeCarrier.app",  @"/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist",  @"/private/var/lib/apt", @"/Applications/blackra1n.app",  @"/private/var/stash",  @"/private/var/mobile/Library/SBSettings/Themes", @"/System/Library/LaunchDaemons/com.ikey.bbot.plist",  @"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist", @"/private/var/tmp/cydia.log",  @"/private/var/lib/cydia"nil];for(NSString *string in jailbrokenPath)
{
if ([[NSFileManager defaultManagerfileExistsAtPath:string]){
jailbroken = YES;
break;}
}
return jailbroken;
}

BLocks in Objective -C


About Blocks

Blocks are a new feature that was introduced in iOS 4.0 and Mac OSX 10.6. Blocks can greatly simplify code. They can help you reduce code, reduce dependency on delegates, and write cleaner, more readable code.

What is block?


A Block is a Nothing but Chunk of Code, and also say that Objective -C Objects.They can pass as the parameters over a method.
ex:
int (^add)(int,int) = ^(int number1, int number2){
                            return number1+number2;
}

int resultFromBlock = add(2,2);

 calling a block(add) and assign the result to variable

When we ll use Blocks?


Blocks are particularly useful as a callback because the block carries both the code to be executed on callback and the data needed during that execution.

Animating a view WithOut Using Blocks



- (void)removeAnimationView:(id)sender {
    [animatingView removeFromSuperview];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [UIView beginAnimations:@"Example" context:nil];
    [UIView setAnimationDuration:5.0];
    [UIView setAnimationDidStopSelector:@selector(removeAnimationView)];
    [animatingView setAlpha:0];
    [animatingView setCenter:CGPointMake(animatingView.center.x+50.0,
                                         animatingView.center.y+50.0)];
    [UIView commitAnimations];
}

Animating a view With Using Blocks


- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [UIView animateWithDuration:5.0
                     animations:^{
                        [animatingView setAlpha:0];
                        [animatingView setCenter:CGPointMake(animatingView.center.x+50.0,
                                                             animatingView.center.y+50.0)];
                     }
                     completion:^(BOOL finished) {
                         [animatingView removeFromSuperview];
                     }];

Comparison among  with blocks and without Blocks:


With blocks, we don’t have to do things like declare an entirely separate method for completion callback, or call the beginAnimations/commitAnimations line.

Final conclusion:


Blocks can reduce the Code, and reduce dependency on delegates.


Source From: RaywenderLich Site

What is Snapshots in XCode


Snapshots enables you to save the state of a project in a particular point of time. You can revert to the snapped state should you need to at a later time. You might be wondering why it is even needed, because with Source Control Management such as SVN.  Snapshot is quicker in some cases to take a snapshot than having to checkin and checkout changes.  It is also faster to do comparison on Snapshots.



































To compare between two snapshots: highlight two Snapshots (shown below, left, the two grayed items), then select the file you want to compare (the yellow highlight below).  The differences will be shown in a split window.  In the example below, notice how the second revision shows the things that I added after the first snapshot (the word projectiles not destroyed (in the green color highlighting)).

  You can also revert the project to a previous snapshot, using the Restore toolbar buttons.


Snapshots are stored in a disk image that lives in ~/Library/Application Support/Developer/Shared/SnapshotRepository.sparseimage

Thursday, 28 February 2013

How to Read And Write Plist File

//Read TopScore.plist  File



-(void)readTopScorePlist
{
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //1
NSString *documentsDirectory = [paths objectAtIndex:0]; //2
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"TopScore.plist"]; //3
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath: path]) //4
{
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"TopScore" ofType:@"plist"]; //5
[fileManager copyItemAtPath:bundle toPath: path error:&error]; //6
}
NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
self.MyTopScore = [[data valueForKey:@"TopScore"] intValue];
[data release];
}

//Write To TopScore.plist


-(void)writeToTopScorePlist
{
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //1
NSString *documentsDirectory = [paths objectAtIndex:0]; //2
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"TopScore.plist"]; //3
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath: path]) //4
{
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"TopScore" ofType:@"plist"]; //5
[fileManager copyItemAtPath:bundle toPath: path error:&error]; //6
}
NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:path ];
    [data setObject:[NSString stringWithFormat:@"%i",self.MyTopScore] forKey:@"TopScore"];
    [data writeToFile:path atomically:YES];
    [data release] ;
}

Integrating OpenFeint and Admob With Cocos2D iPhone

Two excellent tutorials available on integrating OpenFeint and Admob with Cocos2D iPhone games. For those unfamiliar with it, OpenFeint is a social networking platform for iPhone games that adds some great features such as leaderboards, chat, and challenges. Admob is a mobile advertising solution which was recently purchased by Google that helps in monetizing your app.

The Tutorials:
OpenFeint and Cocos2D iPhone Tutorial
Admob and Cocos2D iPhone Tutorial

OpenFeint Integration With iOs Apps

OpenFeint is a powerful social framework for iOS games. It makes it easy to handle achievements, leaderboards, and sharing. You can even synchronize it with Game Center. This tutorial only covers a basic OpenFeint integration and not any advanced features.

This tutorial starts with the Sparrow scaffold. If you are not using the scaffold, your integration might be a little different.
1. Go to https://api.openfeint.com/dd/signup and sign up for an account.
 
If you already have an account, just create a new game from the developer dashboard.
2. Download the latest SDK from https://api.openfeint.com/dd/downloads.
I am using the OpenFeint iOS 2.12.5 package.
3. Find OpenFeint.framework in the SDK package and add it to your Sparrow project.
Also, add the correct configuration bundles for your project: 

If your game is iPhone landscape only, use OFResources_iPhone_Landscape.bundle. 
If your game is iPhone portrait only, use OFResources_iPhone_Portrait.bundle. 
If your game is iPad only, use OFResources_iPad.bundle. 
If your game is iPhone landscape and portrait, use OFResources_iPhone_Universal.bundle. 
All others use OFResources_Universal.bundle. 

4. Add the following frameworks to your project.
AddressBook 
AddressBookUI 
CFNetwork 
CoreLocation 
CoreText 
GameKit 
libsqlite3.0.dylib 
MapKit 
MobileCoreServices 
Security 
SystemConfiguration  
At this point, you should be able to build and run your app with no OpenFeint related warnings or errors.
5. Add the following code in ApplicationDelegate.h and .m.
ApplicationDelegate.h
#import "OpenFeint/OpenFeint.h"
 
// Add OpenFeintDelegate after UIApplicationDelegate
@interface ApplicationDelegate : NSObject <UIApplicationDelegate, OpenFeintDelegate>
ApplicationDelegate.m
// At the end of applicationDidFinishLaunching
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:UIInterfaceOrientationPortrait], OpenFeintSettingDashboardOrientation,
@"OFSparrow", OpenFeintSettingShortDisplayName,
#ifdef DEBUG
[NSNumber numberWithInt:OFDevelopmentMode_DEVELOPMENT], OpenFeintSettingDevelopmentMode,
#else
[NSNumber numberWithInt:OFDevelopmentMode_RELEASE], OpenFeintSettingDevelopmentMode,
#endif
nil];
[OpenFeint initializeWithProductKey:@"qXprwYNXTJYdg1iT4lK9Eg" andSecret:@"xgVwRmTkhmOn5StvYiOruIDmL8dEEUyCniZgmLTn0o" andDisplayName:@"OpenFeint Sparrow" andSettings:settings andDelegates:[OFDelegatesContainer containerWithOpenFeintDelegate:self]];
 
// Add these methods also
- (void)dashboardWillAppear {
    [mSparrowView stop];
}
 
- (void)dashboardDidDisappear {
    [mSparrowView start];
}
 
- (void)userLoggedIn:(NSString *)userId {
    NSLog(@"User %@ logged into OpenFeint", userId);
}
 
// In the dealloc method
[OpenFeint shutdown];
6. Use these methods to open the OpenFeint dashboard.
// You may need to #import "OpenFeint/OpenFeint+Dashboard.h"
[OpenFeint launchDashboard];
[OpenFeint launchDashboardWithListLeaderboardsPage];
[OpenFeint launchDashboardWithHighscorePage:@"leaderboardID"];
[OpenFeint launchDashboardWithAchievementsPage];
[OpenFeint launchDashboardWithFindFriendsPage];
[OpenFeint launchDashboardWithWhosPlayingPage];
7. Use these methods to submit scores and achievements.
// You may need to #import "OpenFeint/OFHighScoreService.h" and "OpenFeint/OFAchievement.h"
[OFHighScoreService setHighScore:100 forLeaderboard:@"leaderboardID" onSuccessInvocation:nil onFailureInvocation:nil];
[[OFAchievement achievement:@"achievementID"] updateProgressionComplete:100.0f andShowNotification:YES];
8. Yay! You're done.
Here is the sample project from this tutorial. 
Sample Project