Protecting Team Fortress 2 Sentrys

May 16, 2009
TF2 t1 sentry gun

The Team fortress sentry-gun is a powerful building that is built by the Engineer. It never misses it’s target, except against a Scout that has just taken a drink, or when shooting into walls. Sentry’s cannot move, making them very susceptable to various forms of attack, such as planted stickie bombs and incoming missiles.
The sentry has much more firepower than any playable class and outputs 13 to 20 damage per bullet that it fires. In its first stage, it fires two shots per second, then after the first upgrade, it fires 4 bullets per second. In its final stage, it fires 8 bullets per second and a group of 4 rockets every few seconds. This is 26-40dps, 52-80dps, and 104-160 dps respectively. The group of rockets does 30-50 damage.

Why bother sitting around protecting sentrys?

Sentrys can be the core of any defence, and sometimes even an attack. While a sentry is up, the enemies attention will be completely devoted to destroying the sentry, meaning that they won’t be shooting at you! The sentry is protecting you, just by being there, and keeping the sentry alive, keeps your team alive.

Pyro

The pyro is quite possibly the best unit for protecting sentrys. They are great at spotting/killing spys and can blow back ubers, especially incoming enemy uber pyros. They are also excellent for blowing away stickies and incoming rockets.

Heavy

The heavy, if placed with a dispenser nearby, can constantly shoot into the enemy direction. The main bonus affect of this is to prevent cloaked spys getting nearby. Heavys are great at detecting and killing cloaked spys before they even get anywhere. THey are also great at destroying stickies with their bullets.

Demoman

The demoman isn’t exactly the first choice but can be very effective, especially at taking care of spys. Lay some stickies down near and around the sentry guns and as soon as you hear ’spys sappin’ my sentry’, blow him away instantly. Demomen are also very effective at blowing away enemy stickies that get placed near sentrys. This is done by laying down a single stickie underneath the sentry and exploding it. All enemy stickies will radiate away from the sentry after performing this action. Note that this will result in enemy stickies being spread all over the place, which may not be desirable as it will cause a huge AOE explosion when they are exploded.


Tutorial on Flash cross-domain-policy and the policy-file-request

February 27, 2009

SOLUTION

You have to end with a null byte by typing “”  (thats a zero) and you have to output your XML with ‘ rather than using \” (escape double quotes). You also have to output the policy file request BEFORE you read anything. As a result of me fixing my own problem, the £5 offer has expired. Hope this solves any problems you may have.

Problem

I am developing a flash program that needs to connect to a server on the internet through a socket connection. The policy-file-request security feature in flash is giving me extreme hasstle. I found a several websites detailing the problem and the best one I have found so far is here. I have created my own Java Server that listens to the port 843 specified to connect with in Flash (using actionscript 3). It then tries to output the correct policy file, but i cant seem to get it to work because flash wont reconnect after I sent it the policy file.

Please note that i have tried using the java code with 
 
byte nullbyte = ‘00′;
connection.getOutputStream().write(nullbyte);

at the end of the policy file, but that doesnt seem to help


Downloading and Installing Avetana Bluetooth for Linux.

February 21, 2009

Introduction

Avetana Bluetooth is a Java Implementation of JSR-82 for Linux and J2SE allowing programmers to easily use and offer Bluetooth services. I used this tutorial to guide me, but felt that I could improve upon it by adding a lot more detail. If at any point you are lost, you may want to refer to it to help you.[2]

Install all the the needed packages from synaptic package manager, which are

  • sun-java5-jdk
  • build-essentials
  • autoconf
  • bluez
  • bluez-utils
  • libbluetooth1-dev
  • libbluetooth1

Download Avetana here.[3]

wii31

Once you have downloaded avetanaBT .tgz file you will need to extract the files within it properly. Create a folder in which you will put the extracted files later, preferably within your home directory. Then put the .tgz file in there, as shown:

wii4

Now you need to open up the terminal in Linux and navigate to the folder you just put the avetanabt .tgz file into. (Don’t forget that this is done by typing ‘cd’ and then the folder you want to go into.) Then enter the command ‘tar xzf’ and then hit the tab button to make the file name pop up (make sure there is a space after the ‘xzf’) before hitting enter.

wii5

The result is a load of new files are now in the folder you created. These are the files you just extracted.

wii6j

The files that you have downloaded and and extracted cannot be directly used. We now need to recompile the files after changing some details so the application can be used by your computer.

You will need to know where your Java extensions folder is located. Mine is located at  ‘/usr/lib/jvm/java-6-openjdk/jre/lib/ext’ and yours will be somewhere similar (probably just something different after the ‘ /jvm/ ‘ part).

Changing the Evironment Variables

Open the envvariables file in the avetana folder in order to edit it. Copy and paste the following code into the file as shown here, make sure to edit it to state where your JDK home directory is. Note that the JDK home is exactly the same as your extension folder, minus the /jre/ onwards part.

export JDK_HOME=”/usr/lib/jvm/java-6-openjdk”

avetana-varjdkhome

Copy and paste the following code into the file as shown here.

export JDK_PLATFORM=”linux”

avetana-varjdkplatform

Copy and paste the following code into the file as shown here, make sure to edit it to state where your JDK extension folder is. This is where the files that will be created during the installatiion will be put.

export BIN_DIR=”/usr/lib/jvm/java-6-openjdk/jre/lib/ext”

avetana-varbindir

After performing these steps I installed aventa and found that it didnt work, I got an error like this.

Exception in thread “Thread-2″ java.lang.UnsatisfiedLinkError: de.avetana.bluetooth.stack.BlueZ.cancelInquiry()V
at de.avetana.bluetooth.stack.BlueZ.cancelInquiry(Native Method)
at javax.bluetooth.DiscoveryAgent.cancelInquiry(DiscoveryAgent.java:265)
at wiiremotej.WiiRemoteDiscoverer.deviceDiscovered(WiiRemoteDiscoverer.java:68)
at javax.bluetooth.DiscoveryAgent.deviceDiscovered(DiscoveryAgent.java:284)
at de.avetana.bluetooth.stack.BlueZ.hciInquiry(Native Method)
at javax.bluetooth.DiscoveryAgent$1.run(DiscoveryAgent.java:208)
at edu.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
at java.lang.Thread.run(Thread.java:619)

This is a common problem many had, found here.[2] (You don’t need to go there for this tutorial).

To fix this problem we need to navigate to the ‘c’ folder within the aventa folder and edit the bluez.cpp file. We need to inject the following code:

JNIEXPORT void JNICALL Java_de_avetana_bluetooth_stack_BlueZ_cancelInquiry (JNIEnv *env, jclass obj) {
/* Close the specified HCI device */
//printf(“Function called: %s, %i\n”__FILE__, __LINE__);
//hci_close_dev(dd);
return;
}

Make sure to put it at the very end of the file, as shown:

avetana-pasteincode

Now we are ready to install. You need to enter the following code in the terminal when you are within the avetanabt folder.

  • sudo ./install – this command works
  • sudo sh install – this command doesn’t work, I list it here because I was told to use it in one of the tutorials I used and I dont want you to do the same.

avetana-install-command

You should get the following output after you enter the command.avetana-successful-compile1

Congratulations You did it!

If you wisht to test that you have installed avetana correctly, compile and run the WRLImpl.java file in WiiRemoteJ from my other tutorial, you will get the following output when you have connected the WiiRemote. For some reason the caputre of the screen did not run too successfully, hence the giant white rectangle in the screenshot.

avetana-running-correctly

References

  1. http://www.valhallachat.com/?q=compile_avetana
  2. http://www.wiili.org/forum/wiiremotej-tips-t2815.html
  3. http://sourceforge.net/projects/avetanabt/

Introduction to Nature Inspired Computing & Evolutionary Algorithms

February 21, 2009

Introduction
Nature has inspired scientists in many ways for solving computer problems. Problem solving can be based on:

  • the principles of evolution.
  • the operation of ant colonies.
  • the behaviour of swarms of individuals (swarm intelligence).


Evolutionary Algorithms

Evolutionary algorithms work on the ’survival of the fittest’ principle in which fitter solutions survive and mate while weaker solutions die out. One could also think of this as ’selective breeding’ in which fitter solutions are ‘chosen’ to mate to produce fitter offspring or children.

 

The Main Parts to an Evolutionary Algorithm

  1. Keep a population of different things on the go.
  2. Select ‘parents’ with a weak bias towards the fittest. Must not have a strict survival of the fittest, and allow less fit solutions to reproduce.
  3. Sometimes use recombination of two or more parents to generate new candidate solutions by combining pieces from different previous solutions.

 

Different Ways to Implement the Main Parts of an Evolutionary Algorithm
One can vary their selection techniques such as:

  • Choose top 10% of population.
  • Choose based on probability proportionate to fitness.
  • Choose Randomly From top 20%

One can then decide to apply various genetic operators.

  • mutation – randomly change the genetics of a selected parent.
  • recombination/crossover – mix two parents together.

One can then vary the ways in which the population is updated.

  • One could replace the entire population with the new children.
  • One could replace the worst children with the new solutions.
  • One could perform the weakest replacement method where a new solution is put into the population and the weakest solution is then removed. This means the same solution could be added and then removed, thus having no affect.

 

What are Evolutionary Algorithms Good For?
Evolutionary algorithms have been used to develop:

  • Pipe network designs (sewage and water mains).
  • Designs for the best possible antenna with given requirements.
  • Best placement strategy for mobile phone masts.
  • The most efficient orbit of satellites.
  • The best strategy for flying fighter aircraft.
  • and much more.

Evolutionary algorithms cover all the applications of optimisation and machine learning.

 

Evolutionary Computation Terminology

Algorithm Types

  • Generational – genetic operations applied repeatedly to generate an entire new population.
  • Steady State – genetic operations are applied N times and bad solutions are replaced.
  • Elitest

Recombination

  • Single-point - point crossover – take two chromosomes and swap the chromosomes at a randomly chosen section.
  • Multi-point -  the same as before but with two or more randomly chosen places.
  • Uniform – Generate a random binary ‘mask’. Use it to decide which genes are swapped and which stay.

Selection

  • Rank-based – The fitnesses of the population are ranked from Popsize(fittest) to 1 (lesast fit). The selection probability is proportionl to the rank. In this way one can control the selection bias towards fitter solutions.
  • Roulette Wheel – Individuals have a probability directly proportional to their fitness to become selected.
  • Tournament Selection- select a random individual from the population and compare it to N other individuals fitness’. Return the fittest individual.
  • Truncation Selection – Applicable to generational algorithms only where most or all of the population is replaced with each iteration/generation. Produce the next generation entirely by applying various operations to the top N% of the current generation.

Replacer

  • Weakest – replace the weakest solutions in the population.
  • First Weaker – replace the first solution in the population that is weaker than the new solution.

Mutation

  • Single-gene mutation – Choose a gene at random and change it to a random new value.
  • N-gene mutation – Multiple instances of single-gene mutation.
  • Swap mutation – choose two genes at random and swap them.
  • Vector mutation – Generate a small random vector of length L, and add it to the whole thing.

Parameters

  • Population Size – the number of individuals/chromosmes in the program.
  • Generations/iterations – the number of cycles in which new solutions are created.
  • Mutation Rate – the number of genes to be muatated in a single mutation.
  • Crossover Rate – the number of ’slices’ or crossover points to be made in a crossover, ie one in a single point crossover.
  • Tournament Size – the number of individuals to be compared in tournament selection before returning the fittest.

Team Fortress 2 Unlockable Ideas

February 18, 2009

I believe that team fortress is a team game that trys to make players focus on teamowork rather than individual skill and reactions.  The unlockables should reflect this, like the heavy gun, natasha, which slows targets down so that teammates can kill them more easily.

If you feel like you could add to these ideas, please comment.

Rocket Man

  1. Heat seeking missiles (primary) - go towards enemies on fire, or enemy pyros currently shooting flame.
  2. Lock on Missiles (primary) – Hold down right mouse button while enemy or unit is in crosshairs for 3 seconds locks your missiles onto that signature. Your next load of missiles in the rocket will automatically go to that target after a 1 second delay. Great for shooting sentry guns round corners. One could lock onto a sentry gun and then fire missiles directly into the air. After one second delay, missile will come directly down on target.
  3. Flare gun (secondary) – stacks well with heat seeking missile.
  4. Grapler (third level)-  allows one to latch onto fired rockets or people . Brings the person to you if they are heavier than the soldier, or you to the person if they are heavier, ie the heavy.

Engineer

  1. Forcefield (Sentry replacement) – Works exactly like a halo shield grenade, in taht you instantly drop an item and a forcefield bubble of certain hp and radius springs up protecting everyone within from outside attacks. Upgradeable for more hp/bigger radius, which would be good for defence for putting round sentrys. Attacks from within would still damage people, so pyros would be a good counter. Provides for another still target which would give the rocket man more purpose.
  2. Anti-air sentry gun (Sentry replacement) – sentry gun automatically shoots and destroys any missiles or grenades/stickes that are flying through the air around its shooting area.
  3. Healing Dispenser (Dispenser replacement)- The dispenser heals half as fast, or does not provide metal for the engineer however it has a healing range equal to that of the medic, allowing it heal team mates that are in sight of the enemy/whilst it is not.
  4. Open ended teleports (teleport replacement)- Any teleport entrance can go to any teleport exit (so long as they belong to the same team) but priority is given to the teleport entrance/exit of the same player. Ie if you lay down a teleport entrance or exit then that will be the route provided, but if your exit goes down, then your entrance will go to a team mates exit. If your entrance goes down, a team mates entrance might still lead to your exit.

Medic

  1. The leech – (primary) – Works just like the healing gun but in reverse on the enemy. While channeling you constantly hurt the enemy over time. Accuracy is not an issue as you cannot miss, and damage is consistent and uncrittable. Damage is not returned to you as health.
  2. Uber healer (secondary)- The primary weapon heals people twice as fast, however it loses the ability to uber team mates.

Spy

  1. PP207 (primary) - Your magnum is replaced with a silenced pistol that does slightly less damage, is silent, and has a larger clip. You can pistol whip people with this item to do larger damage.
  2. Virus Sappers (Third level) – These sappers eventually re-program buildings to work for your side. Ie sentry guns that shoot for your team, and dispensers that give your team health and ammo. Teloports would have to work under the open-ended teleport theory stated earlier.

Sniper

  1. Dazer (primary) – Does not critical but stuns targets when you shoot them. Stuns for more time based on the charge up time of the shot. This allows other snipers to easily get that critical headshot.
  2. Shotgun (Secondary) - replace that secondary rifle with something more suited to close range.
  3. Tazer (third level) - get up close and personal with a taser. Has a 6 second charge up time and does not do damage, but instantly paralyzes a close target for 3 seconds. Combine this with the shotgun for an easy kill.

Demoman

  1. Grenade launcher II (Primary) – This grenade launcher has 3 grenades instead of 4 in its clip but has the ability to fire all three at once in a spread, like the shotgun.
  2. EMP Grenades (primary) - These grenades explode on impact no matter what and disable any electronic device within a certain radius for 3 seconds.
  3. Proximity stickies (secondary) – Your stickies go off whenever an enemy goes near them. A stickie will set off any other stickies. These stickies do half as much damage as regular ones.
  4. Alcoholic Beverage  (Third level) – Drink a concoction that makes you woozy and inaccurate but gives you 50% more hp for a limited time.
  5. Suicide Bomb/Self-destruct (Third level) - You give up and commit suicide by pressing the detonator, taking everyone within 10 yards with you in a spectacular explosion.