Last Good Quote: Son's are the seasoning on our lives. - Someone on Facebook

Thursday, June 26

Gaming with a Guest Account

You've got 10 min...you know of this great game, you want to test it but as you visit the site you realize you have to register.

*sigh* you walk away, telling yourself you'll come back tomorrow.

As a game builder that's an expierence I don't want to give my potential players. Thus I've started creating a guest account feature for all my new games.

The guest account gives a player a quick easy way to evaluate the game.

For the time being the guest accounts on my games are not persistant, they stick around for a few hours or days then disappear. As a matter of fact, once you logout the game, you can not log back into the guest account.

Remember the goal is to convert the user to a player, thus if they play as guest but don't feel emotionally attached enough to create their own account. They won't be playing the game for very long.

Wednesday, June 25

A Quest to Find Intelligence

A Quest to Find Intelligence

I've decided that if I'm going to research and explore Artificial Intelligence (A.I.) it would be wise to define in my words what I am trying to find.

I am searching for a computer program that has the following capabilities:
  1. It must be able to create tools.
  2. It must be able to identify the usefulness of a tool.
  3. It must be able to set its own goals.
  4. It must be able to determine when a specific goal has been met.
  5. It must be able to be acted upon by its environment.
  6. It must be able to act upon its environment.
If a program is able to accomplish these things I would consider it intelligent and useful. In addition to this, the more complex it's environment the more intelligent I would find the Agent.

What's a tool?

A tool, to my AI, would be any function or program which accepts a number of inputs and delivers a number of outputs.

For example, an add function might take 2 numeric inputs and output one numeric number. In this case a single function acts as both the input and the output.

add(1,2) -> 3

This would be a simple tool. A more complex tool might be a map object which has a number of functions (inputs) that allow you to modify the appearance of the map (output)

map.createMap() - sending inputs
map.viewMap() - getting outputs
0 0 0
0 1 0
0 0 0

map.moveUp() - sending inputs
map.viewMap() - getting outputs
0 1 0
0 0 0
0 0 0

Identifying the usefulness of a tool

In order for the AI to understand the usefulness of the tool, it must be able to make an accurate prediction of the output of the tool.

For example, after examining and testing the add function mentioned above, the AI will be able to identify that if it puts 3 and 5 as inputs it will get back 8.

This is NOT the same as saying that the AI knows the implementation of the add function, rather it can anticipate the response of the tool.

This will allow the AI, when given a goal, to choose one specific tool to use from a variety of tools.

Note to self: This means that the AI must maintain some type of meta-data about tools. IE: When a goal using the word "addition" this should key the AI to consider the add function as part of it's procedures.

Setting a goal

As stated before one of the requirements is that the AI be able to set its own goals. This is needed because as more and more difficult tasks are requested of the AI it will have to set a sequence of steps together to achieve the tasks. I consider each of these sub steps as a goal that the AI must recognize and achieve before completing the final tasks.

For example if AI is asked to provide the tasks of moving itself 5 spaces up on a map, it must understand that it's first goal is to move a single space. It must then choose a tool that will do that and execute that tool 5 times.

This may result in the AI creating a new tool which moves it 5 spaces. Which brings us to our next point...

Creating tools

At some point the AI will need to build its own set of tools, as a tool may not exists (or be at its disposal) that will accomplish the overall goal.

In a simplistic sense, since tools are functions or objects, as the AI builds more tools it becomes "smarter"

Again the AI will need some method for determine when and how to create a tool.

Acting within the Environment

Finally and most importantly, the environment that the AI "lives" in will have to interact with the AI. And vice versa the AI will have to be able to interact with the environment.

This is most important as the "richness" of the environment that the AI can interact with will dictate the "intelligence" of the application.

For example:
Let's say an AI, agent's, environment consists of a label, text box and submit button. This is the agents environment. It is what the agent can act on and it is how the agent will be acted upon.

An agent can enter text into the text box and submit the text using the submit button. This would be the agent acting on the environment.

The environment would act upon the agent by placing text into the label.

Certain characters in the label, "That is correct" would affect the agent in some manner.

This is a simple environment and the agent behind it would be considered to have "lesser intelligence"


A More Complex Example

The environment consists of a 3d world, like "Worlds of Warcraft". The agent (AI) would be a character in that environment.

As the agent performs actions in this environment, attributes of the agent would respond accordingly. IE: health, level, skills, etc...

The next few post will go into each of these functions in more detail.

Tuesday, June 17

Online Game Programming Book

I have not posted in ages, however I ran across this link and thought it was a good resource.

This book is about programming games in Python. Seems to be a good starting place for all those new to game programming.

It's available as a PDF download.

http://pythonbook.coffeeghost.net/book1/index.html

Wednesday, March 19

2005 Table Partition - Optimization Test

On the job we decided to implement table partitioning with SQL Server 2005. I wanted to get an understanding of the increases and decreases that we would see with a partitioned table. Below is documentation of my tests.

Tables Involved
Step 1:
Create Table called 'nonPartitioned'
No Primary Key
16 varchar(50) fields
1 bit field called 'activeFlag'

Step 2:
Populated table with random text
Created 250,000 rows

Step 3:
Mark a sizeable portion of the table as active.
I took 50,000 rows and marked them as active.
I took rows that cotained an 'a' in 'fieldG'

Step 4:
This table is partitioned on the activeFlag, 1 or 0
Create Partition Function
Create Partition Schema
Create Partition Table

Step 5:
Copy Data from 'nonPartitioned' to 'partitioned'

Step 6:
Create table called 'smallTable'
This holds only active records
Populate with active records only

Step 7:
Create table 'selected'
This will hold data that we select from either partition

Some important metrics to note at this point:

52,689 where ActiveFlag =1
197,311 where ActiveFlag =0

35.51 MB - Partitioned Table Size
36.17 MB - Non Partitioned Table Size
7.45 MB - Small Table

First Test - Selecting from Small Partition
The first test is to select data and see if we have a speed increase.
  • Truncate the 'selected' table
  • Perform the following 1,000 times
  • Select 10 random records from the nonPartitioned Table where activeFlag = 1
  • Insert it into the selected table
4:53 (4 min, 53 seconds) - NonPartitioned Table
3:39 (3 min, 39 seconds) - Partitioned Table
3:55 (3 min, 55 seconds) - Small Table

Second Test - Selecting from Large Partition
The first test is to select data and see if we have a speed increase.
  • Truncate the 'selected' table
  • Perform the following 1,000 times
  • Select 10 random records from the nonPartitioned Table where activeFlag = 0
  • Insert it into the selected table
13:23 - Partitioned Table
12:59 - NonPartitioned Table
00:00 - Small Table (no select available of large set)

The following code was used for those tests:
truncate table selected
declare @count int
set @count = 0
while @count < activeflag="0" count="@count+1">
Third Test - Updating 1,000 rows
I now want to test the update statements to these partitions. I used the following logic
  • Truncate the 'selected' table
  • Perform the following 1,000 times
  • Select 1 random records from the nonPartitioned Table where activeFlag = 1
  • Update one field (fieldB) for this record
5:03 - Partitioned Table
9:56 - NonPartitioned Table
4:57 - Small Table


Third Test - Updating 5,000 rows
I now want to test the update statements to these partitions. I used the following logic
  • Truncate the 'selected' table
  • Perform the following 5,000 times
  • Select 1 random records from the nonPartitioned Table where activeFlag = 1
  • Update one field (fieldB) for this record
33:17 - Partitioned Table
49:25 - NonPartitioned Table
24:27 - Small Table

Conclusion

If you must have all the data in one table, then partitioning the table will greatly increase your performance in all areas.

However if you can pull the data out of the table into a smaller table, this will give you the greatest performance during transactional processing.

Caveat

This is my own home grown test, as always perform your own test before making production relavant decisions. Your data may give you different results.

Friday, March 14

Battle Forces Online: Bounce Rates and Visits

Battle Forces Online: Bounce Rates and Visits

Interesting .... Between Feb 15, 2008 and Mar 14, 2008.

Low Bounce Rates:
* freegames.au - 39 visits, 20% bounce rate
* internetgames.org - 1 visits (prev 7)
* onlinegamesinn.com - 10 visits (prev 19), 30% bounce rate
* pbbgblog - 42 visits, 40% bounce rate
* onrpg.com - 133 visits (prev 37), 27% bounce rate (prev 30%)
* forums.indiegamer.com - 13 visits (prev 97), 30% bounce rate (prev 62%)

Most Visits From
* onrpg.com - 133 visits (prev 37), 27% bounce rate (prev 30%)
* community.bbgamezone.com - 49 visits (prev 59), 35% bounce rate (prev 45%)
* forums.indiegamer.com - 13 visits (prev 97), 30% bounce rate (prev 62%)
* pbbgblog - 42 visits, 40% bounce rate

I know that this past month I have posted a lot of entries on pbbgblog.com....evidently they have been working. The bounce rate is a bit high but it seems worth while.

Mental Note: Check out onrpg.com, it may be worth while to post a few things over there as it seems, they have a great bounce rate for my visitors.

Tuesday, March 11

Code: Merge Gif Images to create one image

The following code will take an array of gif images and merge them into one and save the resulting image to file.

I use it to create a unit images on the fly. As users buy different equipment, the unit's look changes.


function mergeImages($imgPathArray, $dest)
{
$imgArray = array();
for($i=0;$i < sizeOf($imgPathArray);$i++)
{
array_push($imgArray, imageCreateFromGif($imgPathArray[$i]));
}

$src = $imgArray[0];
$background = ImageColorClosest($src, 0, 0, 0);

for($i=1;$i<sizeOf($imgArray);$i++)
{
//ImageColorTransparent($imgNew, $background);

ImageCopyMerge( $src ,
$imgArray[$i],
0, //dest x
0, //dest y
0, //src x
0, //src y
74,//width
100,//height
100 //alpha
);

imagedestroy($imgArray[$i]);
}

return ImageGif($src, $dest);
}





Usage:

$dest = "images/custImage.gif";
$imgPathArray = array("images/builder/blueBase.gif","images/builder/body.gif","images/builder/legs.gif");
array_push($imgPathArray, "images/builder/body.gif");
array_push($imgPathArray, "images/builder/legs.gif");
array_push($imgPathArray, "images/builder/sword.gif");
mergeImages($imgPathArray, $dest);

Notes and Caveats:

All of my gif images were the same size, 74 X 100.
They also have transparent backgrounds.
If your images are different sizes, just change the width and height lines.
Note: Your array must contain at least 2 images otherwise you get an error.

Thursday, March 6

Battle Forces Online - Upgrade Time

Battle Forces Online has gone through a revision.

New Features
  • Added Destinations - Inns, Gates and visiting spots
  • More boards to play
  • Fight Pits - Small maps that once clear earn you loot
  • Optimizations in the response time to action requests
  • You can now buy more Blades (units) and weapons
  • Healing Spell added for Mages
  • 2 New Blades added, Earth Mage and Fire Mage
  • More spells and items
  • No more random spawning, everyone enters the board at the same time.
  • Alter your party
StoryLine

The story line is a bit weak at the moment, but I wanted to build the ability to give each map a storyline.

Destinations
There are now a number of places you can visit on each board, these places allow you to heal up, buy stuff and chat with NPCs.

More Boards to Play
Currently the game consists of the following boards/maps
  • Awakening - All new users enter here, there are very few enemies. This board allows users to get used to moving and attacking.
  • Dark Forest - Central location, allows you to move around and fight other players. There is a forest theme to it.
  • Gorjin's Bridge - A control point, you're going to need to level up and have a party of 2 Blades to clear this map. There is a bridge theme to it.
  • Gorjin's Lair - This board was built to test a user. Try to get to the castle at the far end.
  • Small Fight Pit - Very small fight pit, good for users with low stats or low party counts.
  • Medium Fight Pit - A medium sized pit
  • Large Fight Pit - Lots of enemies, lots of space...bring your whole party!
Optimizations
Due to the nature of the engine, when you tell a Blade to move or attack, the request is routed to the server, the server then responds with an OK or Not OK. This was causing a delay to occur between when you clicked and when a Blade actually performed the action.

I made some optimizations to the server handling as well as providing a visual cue (The blades says OK and fades a bit) when you give an action command.

Spells
If a spell is not an attack spell, a mage will cast it upon all members of the party. So a heal spell will heal all members by 10 HP. You do not have to target a member to do this.

In addition to this some spells now have a duration, these spell affects will last for a certain length of time. For example: Magic Shield last for 2 min and gives all members in the party +5 defense.

New Blades
I took the old mage and re-named it to "Fire Mage", this mage can cast fire spells.

I created a new mage called "War Mage", this mage cast lighting spells.

I created a new mage called "Earth Mage", this mage cast healing and defensive spells.

Mages can be killed by any warrior pretty easily so protect them.

Spawning
The old system used to randomly place your Blade on a map. The new system has a spawning point and your entire party will spawn around this point every time you join a map.

Editing the Party
You can now edit how your party spawns, so if you want the mage in the back and the Lord in the front you can do this.

Additional editing features are coming.

In the Future

Some things I'd like to develop in the near future:

* Guilds
* Challenges

Friday, February 29

Question from Bill Gates

I used LinkedIn (a social networking application)

On it Bill Gates had asked a general question; What can we do to encourage young people to pursue careers in science and technology?

My response is below:

It boils down to Respect and Reputation. One of the reasons that young people admire and purse careers is that they see the position as one of respect and authority in the community.

For example, the big time lawyer, the life saving doctor, the helping policeman; these are all positions which come with a large degree of respect and reputation.

Currently I believe that youths tend to view technology jobs as high paying white collar jobs. Reputable well paying positions but not very "exciting".

I think we, the technology group, have done ourselves a dis-service by marketting technology as easy to learn and any one can learn it. This takes away from the respect that one can get for having this job. We may be making it look too easy. I say look because I am well of aware just how hard it is to do things correctly and succeed in our industry, but I wonder how many young adults are aware of this.

Now this is counter to what a lot of folks and groups are doing to encourage technology in our youths. And I certainly would not stop any of these efforts. This might be considered a different tact.

An action that could be taken is to either create another title or pick one that is out there , I believe we have enough, and work at creating an image of that title. An image which will stand beside and out "shine" the Lawyer, Doctor, Buisess Exec career choices that young adults face.

I mean no disrespect to all the great technology leaders out there. I am awed and very respectful of your reputations.

These thoughts come after volunteering teaching young minority kids in the 9 – 12th graders .NET web development for the past 4 years. This is through a community driven organization. I have found the childgrens thoughts and actions very insightful and for anyone that has not taken the time to give back to the community in this well.

I am no author but these are some things that I thought I should share.

Friday, February 22

Simplest of Template Systems

I've looked at a number of templating engines over the years. Some are very nice, however they all seem a bit large for what I usually am trying to build. I've used the follow technique which is dead simple.

I put two include statements in each file, one at the top and one at the bottom. Like so:



Main contents and code



That's it. I create my layout and then I look for the large part of the layout where the main content would go, this gives me my "dividing" line. All code above this goes in the templateTop, all code below it goes into templateBottom.

For Example

I have a page, with a menu across the top, some content and a footer. This is how my html might look.




Hello and welcome to the grand site of ....




This goes into the top
templateTop.php





This goes into the bottom:

templateBottom.php





Draw Backs

There is one drawback to this method, if you use images or have referential links within your template files, they could have the wrong url because your base will always be the file that did the include.

For example, if you have the following line in your template file.


The root of the file included the template will be included with this:

When the file index.php has the include:
But when the file /actions/buyItem.php has the include:

To fix this you must always use fully qualified paths or refer to the root by have a "/" in the front of all referential urls.

Wednesday, February 20

Link: Why we banned Lego

A very informative view on how a Lego Town built by kids, leads to a deeper understanding of communities and power structures.

http://www.rethinkingschools.org/archive/21_02/lego212.shtml

Followers