"Who'll join me!" I exclaimed when the news of a 24 hour 'lets see what can be done with php'-competition was announced. 3 brave colleges answered the call.
And so began what was to be a long day of code, sleep deprivation and caffeine.
We, the '
hot pink crusaders', signed up for the
PHP Throwdown competition and desided to create a game. A planetarion-ish game called 'Incursion'. Mark and I actually graduated on a c / c++ / ncurses version of this game and we've since played with the idea of porting it to the web. And this competition, so it seemed, was a great chance to revitalize the concept.
The 'new' Incursion took 4 people 24 hours to get to a point that it nearly worked. It never made it beyond the suck phase though. It was a good exercise and we had lots of fun trying. There was just not enough time.
I believe I've spent a total of 7 hours trying to get some kind of battle calculation algorithm working. I had to 'invent' this from scratch and it proved to be extremely difficult during the wee hours. I got it working about an hour before the competition ended. A bit too late.
Our plan was to get something 'playable' before halftime and then just fix the bugs and tweak it so that it would be enjoyable to play. We never had a chance :).
The code we checked in at the end is full of fatal errors for which we just lacked the time to fix. Also, security wise, its quite a mess. We've made sure to filter all data going through
Smarty but if register_globals is on, it will be easy to by-pass the 'dispatcher' file and go straight to the controllers which are wide open for all the world to see because none of us had the time to include a .htaccess that would prevent said access. Oh well.
Now we have to wait for the judging to commence.
The judging of our application is based on the following criteria:
Code Readability & Documentation (5 pts)
Installation/Configuration (5pts)
Functionality (20pts)
Performance (5pts)
Error handling & Security (15pts)
UI/Appearance (5pts)
Accessibility/Standards Compliance (5pts)
Code Innovation/Creativity (30pts)
Overall Quality of the App (10pts)
Oh boy.
My predictions are..
Code Readability & Docs
I say; 3 out of 5 points. We started out fine, trying to create a bit of structure, trying to be verbose. But that quickly faded into a code frenzy trying to get stuff working as fast as possible. So I give us 3 points.
Instalation and Configuration
3 points. We actually made an effort to create a database creation script and config file. The only thing needed for installation is a php 5.1 and higher, mysql 4, the cron and a little fiddling in the config.
Functionality
5 out of 20 points. Well the app barely works. So what it does, it does badly. I predict not very many points in this category.
Performance
4 out of 5 points. It's not fast, but its certainly not slow either. Incursion is made for 'smaller' groups of people. So some performance loss might happen when a lot of users are playing. The battle code for instance, does a lot of work.
Error handling & Security
5 out of 15 points. We have basically no error handling and security isn't much better. But if you have register_globals Off and close down all the private directories it should be pretty air-tight. So perhaps 5 points is a bit too low.
UI/Appearance
2 out of 5 points. Our UI sucks. Its very very basic. We've changed the way it looks a couple of time and we lacked the design-skill to make it look pretty. Basically we needed a hands on designer dude. But we didn't have anyone. Ever seen coders create a UI. Yeah.. thats how it looks. The tabs are nice though but there is just a sense of unity missing.
Accessibility/Standards Compliance
4 out of 5 points. We tried to adhere to the standards as much as possible. We tried making the html output conform with XHTML Transitional and CSS. But having done virtually no compliance/validation checks I can't say how we did. Also, the HTML is a mess. Did I say that already?
Code Innovation/Creativity
10 out of 30 points. Did we innovate? I don't know. We have some nice pieces of code, but the whole 'planetarion' concept is not very innovative. The thing where we differ from planetarion is that its made for small fast-pased games. We tried to make it into a 'planetarion for LAN gaming' kind of game where you can join a lobby and the administrator will start the game. The winner will then be determined by having the highest score. Which means having the most kills. What might also be innovative is the way we handle the battles, since we designed this from scratch.
Let me show you how its done (I'm quite proud of this, so bear with me):
Unit statistics:
Name Offence Defense Type Strength Weakness
Marine 10 5 light light light
Commando 13 10 light medium medium
Raptor 25 20 medium light medium
Goliath 50 40 heavy medium heavy
Battlecruiser 100 150 heavy heavy light
Our fleet:
10 Marines
5 Commandos
10 Goliaths
1 Battlecruiser
Opponents fleet:
30 Marines
3 Commandos
10 Raptors
When they attack the 'attacking' fleet fires first, after which the defending fleet (if they are still standing) fire back. In Incursion this happens once after which the fleets return home.
Every unit has a weakness and strength against certain types of units. The attackers targets its 'strength' the its 'not strength, not weakness unit' and after that his 'weakness'. It also incurs a penalty for the amount of shots that hit target based on the type of unit it prefers.
The bonuses:
Shots that 'hit' based on its strength are 80% +- random(0..10)% amount of total shots. Shots that 'hit' based on its weakness are 30% +- random(0..10)% amount of total shots. Shots that 'hit' everything else are 50% +- random(0..15)% amount of total shots.
So basically, you always miss a few shots.
10 Marines fire 10 shots each. They prefer 'light' units so the 'light'-typed units of the opponent are targeted first. In this case the 'Marines' and the 'Commandos'.
The amount of shots that hit target are:
(80 + 5)% of a 100 shots = 85 Shots hit in total for all marines shooting.
The attacking marines target the opponents marines who have a collective 30*5=150 total defense.
So 85 shots hit 150 of total defense. This results in a total 65 defense left on the opponents side. 85 damage also means 85/5 losses on the opponents side, resulting in 17 dead and 30-17=13 marines left to see another day.
In this case all the 'hitting' shots are absorbed by the total defense of all the opponents marines. However! there is a possibility that the amount of damage being dealt exceeds the total defense the opponent provides. When this happens the 'hitting' shots will be transfered to hit the next group of units. In this case the 'Commandos' and going trough the same process as before.
After the marines fire, our commandos get a shot and everything goes through the motions again.
There. Thats what I spent the last 24 hours on trying to figure out.
Last but not least, quality.
Overall quality of the app
3 out of 10 points. I try to spend a lot of my time approving quality in code-bases and of the app in general. But in 24 hour, how much quality control can you have? If there are any sacrifices to save time, you bet it will be quality that pay's the price.
Anyhow, this post has become quite long enough. Let me just say that I've had lots of fun competing and hope I'll be around long enough to be able do it again. Just not within a month or two.