NSPredicates – SUBQuery on a parent-child relationship

I am currently working on a game where there is a parent-child relationship in a quite small array where;

A `Group` (parent)
has many `Child` objects
where 1 `Child` object can be owned by only 1 `Player`
and a `Player` can only ever own 1 `Child` per group

In the game, a `Child` object is called `Locomotive` (the game is about selling Locomotives) and a given `Player` can own a single locomotive in a given group.

I needed a way to grab all the child objects in a given array that met a series of conditions; in short, I’m after a list of child objects that I can `legally` purchase.

By `legally` I mean from the following rules (in no particular order)

  • I want to remove all children where I do not own anything
  • I want to remove all children which I already own a locomotive
  • I want to remove all children where I don’t have enough money to buy it
  • I want to remove all children by inspecting the group to only show those children where the sum total of orders > 0
  • I want to remove all children where something has been bought already

Phew, quite a lot of conditions. At first I was not sure how to solve so many conditions.

My first solution was to use a NSPredicate… with a block statement and simply loop through everything.

Code:

    NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
        EngYard_LocomotiveGroup *group = evaluatedObject;
        for (EngYard_Locomotive *child in group.locomotives) {
            if ( ([child.purchased boolValue] == NO) && (child.owner != player) && (group.purchasePrice < player.cash) && (group.initialOrders>0 || [group.totalOrders integerValue]>0 || group.unlocked==YES) )
            {
                return YES;
                break;
            }
            return NO;
            break;
        }
        return NO;
    }];

This seemed quite a lot of code. Surely there is an easier way to do this?

SUBQUERY to the rescue!

Having played around with the SUBQUERY for a while, I finally got a single-line solution;

Code:

    
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(locomotives, $rv, $rv.purchased = %@).@count > 0 AND (purchasePrice < %d) AND (initialOrders>0 OR orders.@sum.integerValue>0 OR unlocked==YES)", @NO, player.cash];

I double checked both instances in my logger; and they both return my expected results.

Now on to more complex matters — how to make the AI make a decision to buy.

Startup Britain – Pitching to Chillingo

logo

On Monday 14 October I was in London as finalist to pitch a game to the Chillingo team as part of the week long Tech4Startup Britain event being held in Canary Wharf.

The Chillingo Team were:

  • Matt Dixon, Sales & Business Development Director, Chillingo
  • Andy Needham, Head of Production, Chillingo
  • Daniel Tausney Public Relations, Chillingo.

IMG_0267

As a finalist, I was pitching my cocos2d game, “Bootleggers of America” to Chillingo; perhaps the UK’s biggest iOS games publihser; it was an incredibly once-in-a-lifetime occasion to be pitching to a fantastic games publisher amongst such a fantastic and diverse crowd.

IMG_0262

About the game

The game I was pitching was “Bootleggers of America“, a Prohibition-era pick-up and deliver economic game that is similar to the old space trading games of the 80s, or if Drug Wars of the early 1990s, except the twist in my game is that you are responsible for producing your own goods, picking your own goons and making much deeper decisions beyond buying low and selling high.

The game takes ideas from the PC-game, “Gangsters:Organized Crime”, and other mafia trading games to create a fictional world where you play as a Mafia don of your own crime family with the idea to make as much money from Speakeasies and Illegal bootlegging operations during the Prohibition-era.

Although the consensus from the mobile app experts was that mobile players want to “dip in and dip out”, and that long-haul strategy games do not work well on mobile; I have seen a few games that have proven that they will work for a specific niche of players.

My game plays is aimed to this niche and is a premium, solitaire, long-haul strategy game designed to play on the train, I felt that with games like “Transport Tycoon” recently being released on iPad that the idea that premium long-haul strategy games for iPhone, iPad can work.

With this in mind, I felt that Chillingo could help get it published and help prove that the market isn’t about 15-second games.

My pitch to Chillingo

My pitch was about getting their help to turn the game from what it is now, and turn it into an isometric city with Game Center integration and allow you to play against other players; of course this would require servers, and a large scale technology support that only Chillingo or other games publishers could provide.

This would mean, helping out with new art work and giving help on the technical level to provide the game servers similar to the other games they currently publish.

Post-Pitch advise

Rightly, Chillingo felt the game didn’t seem innovative or brough anything “new” to the table; plus they could not help with the technical challenge of delivering content via servers, websites, etc; and advised me to look at the game again and try to deliver such a product myself.

The future for Bootleggers

Right now, I feel the game needs to be refreshed with an Isometic city, and integration with Game Center and the ability to play against other players.

In order to do this, I’m going to need raise funds from something like Kickstarter or IndieGoGo.

When this will happen, I’m not sure; there are a few things in flux — but releasing a premium game that caters to the fans of long-haul strategy games, the mafia theme and “Gangsters:Organized Crime” into a strategy game that people will enjoy.

Other pictures I took;

IMG_0264

10 reasons your business needs to go mobile, today

There can be little doubt that mobile is crushing it for small businesses’ in local search. Increasingly, customers are using mobile smartphones to browse, surf, search and buy products and find services.

And yet, many business still aren’t using mobile marketing effectively for their business; or understand the reasons why.

So let’s go through 10 of the most popular reasons why your businesses needs to consider going mobile.

1. The growth of mobile-internet searches is increasing, and un-deniable

Searches via smart phones and tablets for local businesses like yours is one of the fastest-growing mobile activities.

Mobile Internet searches have grown by 500% over the past two years and companies like Google, Yahoo! and Mozilla and taking this trend very seriously and are leading the charge as they’ve seen the growth of searches mean that they must offer services to these smart, savvy customers.

The problem for your business is that if your website was designed for the “Internet” then mobile users are being cut out, they cannot find the information they want, they find the websites take too long to load; and most likely they’ll stop using your website and go to your competitor.

That’s money on the table!

The solution is simple, a mobile website that caters to these leads and grow the number of potential customers you have.

2. 50% of all mobile searches are local

When people look for services or businesses, they invariably search for local businesses, products and services; this number increases if they are on a mobile device.

Indeed, local mobile searches are projected to exceed desktop searches for the first time in 2015 more and currently more than 1/3 of all Internet searches performed on mobile devices are for “local” products and services. In a nutshell, this means that these consumers are searching for YOUR businesses.

local-search-graph

The above graph shows the increased usage of mobile devices like smartphones are used in local searches in the US, and the numbers are the UK are not only following this trajectory, they are growing.

3. 61% of users call a business after finding them on their smart phone

Customers who use a mobile smartphone to searching for a local business are hungry, and ready to take immediate action; they are hot, ready-to-spend customers. Just many customers are you losing because your website is not mobile friendly?

4. 59% of users visit a business after finding them on their smartphone

In the world of the Internet, conversions matter; and its been proven through research by Google, and others that consumers that search for a local business via mobile are more likely to visit a business having found them on a smartphone.

This is real, serious money.

5. 71% Smartphone users that see adverts for a local business will do a mobile search

When consumers see TV, printed or other adverts; the numbers show a high percentage of people will search for the business via their smartphone.

6. 45% of mobile users are between 18 and 29 and use mobile search daily

The numbers of young, hip urbanites using mobile smartphones to search for your business is increasing, that means you need to cater to them or risk losing them to the competition.

7. 53% of shoppers compare in-store prices to online prices while shopping.

It’s true. Even Google admits this. A high percentage of shoppers shop around both in physical shops and virtual e-commerce shops on their smartphone devices for the best price and the best deal.

They want to make snap buying decisions and find the information they want quickly and easily. If they can’t, it’s likely they’ll not use your services.


The numbers don’t lie. Mobile is here and your business needs to go mobile. Today.

Sources:

Sources:
* Google – Understanding Mobile Marketing
* Emarketeer
* Mobithinking
* MobileMarketing MAgazine

Mobile marketing for small business; An overview

Most businesses these days already have a website, they already have a social media presence and already know that to win more business you need to have a website that ranks highly on search engines.

But did you know that mobile, mobile apps and smartphones are fast becoming the go-to way to surf for local businesses.

Indeed, smartphones have already become ubiquitous and is predicted that by 2015, “65% of all Internet access will be from mobile devices by 2015” (Mary Meeker, Morgan Stanley).

However, most small businesses still do not have a website that will work effectively on a mobile device or have a firm understanding of mobile marketing.

What is mobile marketing?

Mobile marketing is a set of practices that enables small businesses to communicate with their customers through a mobile device or network. Typically, this can involve:

  • SMS (Text messaging)
  • MMS (Mobile messaging)
  • In-game mobile advertising
  • Mobile web advertising
  • Location or Geo based services, or geo-advertising
  • App store
  • Mobile Search Engine marketing and optimisation

Why bother?

The key differences offered by mobile’s are smaller screens, less real estate to showcase your business and a user that has less tolerance for slow loading websites or a lack of immediacy of information.

The options for mobile are;

  • Make a mobile template for your existing website
  • Make your existing website “responsive”
  • Make a standalone mobile website
  • Make a mobile app, or a hybrid mobile app

Typically most small business websites can either go responsive or have a mobile ready that is standalone.

Case study: Pizza shop

A pizza shop has a website, it does not work on mobile; so produces a mobile ready website that is standalone. Would the shop opt for a standalone mobile ready website, or a responsive website?

In this scenario, my solution would be a standalone mobile ready website because it can give;

  • ‘Call to action’ – The shop only needs to provide calls to action, such as telephone number, a map, opening times; and other contact information
  • ‘Fast turnaround’ – A simple mobile ready website can be produced very quickly
  • ‘Limited info’ – Things like menus, prices, opening times

A responsive site can be useful, but in the above case study a simple one-page mobile ready website that has plenty of “calls to action” would suffice.

Apps and Mobile Websites – Whats the difference?

The main difference is that mobile websites are simply mobile versions of your business; whereas Apps are usually sold in app stores such as Google Marketplace, the Apple App Store, etc.

Other more subtle differences are things like the ability to work online and offline, the reduced barrier to use a mobile website (whereas an app has an app store barrier) and the need to deliver content, user experience or a product or service.

It is clear that mobile marketing for small business can garner results and is an effective marketing strategy for any new, or existing small business.

Apps that I have written, or have worked on

Although listed on my portfolio; I thought it might be useful to have a list of apps that I have written, or otherwise have worked on as part of a team.

Self-Published:
Vanilla Notes app:
https://itunes.apple.com/gb/app/vanilla/id687239830?mt=8

Simple Scorer app:
https://itunes.apple.com/gb/app/simple-scorer/id693488596?mt=8

Silentflute iPhone app:
http://itunes.apple.com/gb/app/silentflute/id499163258?mt=8

Superfoods iPhone app
http://itunes.apple.com/gb/app/superfoods/id516858202?mt=8

Gary Christies Racing Tips app:
http://itunes.apple.com/gb/app/gary-christies-racing-tips/id487162772?mt=8

Brewlab iPhone app
http://itunes.apple.com/gb/app/brewapp/id529059711?mt

As part of a team, or otherwise worked on

MoveHut property search app
Garbutt and Elliot app

New theme launched and a new direction

A new theme has been launched for this website. We’re looking on-wards and upwards.

For the past few months I have been working on a few iPhone (iOS) apps and am looking forward to working on some more going forward.

In addition, the importance of mobile marketing and mobile ready websites is something that is increasingly becoming prevalent and important not just for small businesses but for startups and even well established ones.

This mark a new direction for this website.

First impressions of the OUYA

Ouya games console with game controller

Ouya games console with game controller

Recently I bought the OUYA games console and game controller; an Android-based games console that costs £99 (extra controllers cost around £30-40). The OUYA comes with HDMI cable, power cable, 2x AA batteries, a games controller (Bluetooth) and several ports including Micro USB, USB, Ethernet and power ports.

Using WIFI, the Android-based games console was backed via a Kickstarter project and was released in the UK on Tuesday 25 June 2013 and by mid-day, reports that Amazon had sold out as well as several US chain stores.

What’s the deal with the OUYA?

Well its a budget Android powered “hackable” gaming console games console aimed at gamers on modest incomes, people who liked Retro gaming and of course; Indie game development. As it’s Android based you can “side load” pretty much anything on to it, and people have added their own apps, most of which are emulator for SNES, NES, Neo Geo, Commodore 64 and others.

In terms of hardware, the OUYA has a nVidia Tegra 3, 1GB of RAM, and 8GB of flash storage and is expandable with a SD card.

Initial thoughts and reservations

Having spent a bit of time setting up the OUYA and figuring out WIFI connectivity issues relating to firewall settings, I finally got the OUYA up and running and playing some games.

Every game is free to try with the idea that you will buy games you like, plus there is the added advantage of making and self-publishing your own games via the Micro USB.

The UI interface is interesting, but it can be hard to find out specific information such as no visual indicator of how much a game actually costs to buy on screen, how much disk space you have left.

The games themselves are fine, and some are a bit too expensive for my liking. When signing up you have the option to use a credit card (which I would avoid) and a pay via a paper based voucher system which is similar to how the Playstation network works.

Where my reservations lie are that it will be viewed and seen by many as a dev kit, a toy and not a serious games device because of the lack of power, hardware or proper design.

Perhaps part of this might be because the amount they raised to make OUYA wasn’t even touching the surface of making a games console on the scale of Sony PS4, Vita, Microsoft, and with constant rumours that an Apple games console means that the OUYA could be dead within a year or less; without proper games companies backing it and major investment.

For those in indie development, the PS4 is coming out soon. Vita is opening up to indie developers I see both these and whatever Apple does as strong reasons that the OUYA is going to have a very hard market to crack.

TV in a world gone mobile?

In a world gone mobile it seems odd to be talking about a device for the TV.

I do feel its lacking something, maybe its build quality, maybe its not as good as the hype or maybe its because for the same price you could get a pre-owned VITA, a pre-owned PS2 and a bunch of games.

Developing for the OUYA?

At this current time, developing for the OUYA seems limited to Unity, Android Java (which I don’t really want to be learning) and a few game engines. Corona SDK, Multimedia Fusion 2, YoYoGames are all meant to be making exporters which target the OUYA but it is my feeling this will be arriving within 2-3 months of the OUYA. Already, YoYoGames is making in-roads towards OUYA development.

For the cynical, the OUYA perhaps should have been called the Unity-Box; because thats what your going to need to develop properly for the device. Thats not to say if your really good with Java you could make apps for the OUYA. For me, Java development is not something I want to be doing to make a simple game.

I’m going to keep the OUYA for the summer and see if I can do simple apps with it without Unity.

For further information on developing for OUYA, check out this article http://gamedev.tutsplus.com/articles/how-to-learn/how-to-learn-ouya-gamedev/

My first initial feelings on the OUYA are:

  • Hardware: 5/10
  • Software: 5/10
  • Developing for it: 4/10
  • Future? Unsure

Overall: 5/10.