Dec 17, 2015
Purpose of CodeFights
• Prove that You are better developer.• Testers sometime win as well…• Coding can be fun too.
Basics
• Single Fighter Class• 3 actions per Move (Round)• Attacking / Blocking• Order doesn’t matter• 150 hit points
Attack areas and Points
• Area::NOSE – 10 pts• Area::JAW – 8 pts• Area::BELLY – 6 pts• Area::GROIN– 4 pts• Area::LEGS – 3 pts
MyFighter Class
• Class must implement IFighter interface• Method makeNextMove must return Move object• Each round makeNextMove is called with
these params:• opponentsLastMove (except first round)
• myLastScore
• opponentsLastScore
Points calculation (1)
Attack Nose
Attack Groin
Block Legs
+10 pt +4 pt
14 pt0 pt
Block Groin
Attack Legs
Attack Legs
0 pt +3 pt
6 pt+3 pt
Points calculation (1)
Attack Nose
Attack Groin
Block Legs
+10 pt +4 pt
10 pt0 pt
Block Groin
Attack Legs
Attack Legs
0 pt +3 pt
0 pt+3 pt
Points calculation (2)
Attack Groin
Attack Groin
Block Nose
+4 pt +4 pt
8 pt0 pt
Attack Nose
Attack Jaw
Attack Belly
+10 pt +8 pt
24 pt+6 pt
Points calculation (2)
Attack Groin
Attack Groin
Block Nose
+4 pt +4 pt
8 pt0 pt
Attack Nose
Attack Jaw
Attack Belly
0 pt +8 pt
14 pt+6 pt
PHP
• Requirements: PHP 5.4• CLI php.ini has phar.readonly flag set to
false• Command line: php box.phar build• Or simply execute build.bat or build.sh
Javacsript & NodeJs
• Requirements: NodeJs 0.10.x.• Install Node.js package:• npm install codefights.net [-g]
Try it!
• Command line• php my-fighter.phar <fight_mode>
• java –jar my-fighter.jar <fight_mode>
• my-fighter.exe <fight_mode>
• node index.js <fight_mode>
• Fight manually (--fight-me)• Fight against sample bots Kickboxer and
Boxer (--fight-bot <bot_name>)• Enroll Your fighter to tournament!