CodeCombat is a popular multiplayer coding game that teaches programming concepts through gameplay. Players control characters by writing code in languages like Python and JavaScript. The game features single-player coding challenges as well as multiplayer arena battles.
In this comprehensive 2600+ word guide, we will cover installing and running CodeCombat on a Linux operating system, specifically Ubuntu. We‘ll also explore the multiplayer capabilities of CodeCombat in depth and how you can battle other players by coding AI behaviors.
An Overview of CodeCombat
CodeCombat is designed as an introductory coding tutorial in the form of a game. There are two main components:
- Single-player campaign with progressive coding challenges
- Multiplayer arenas where you code AI to battle others
The single-player campaign allows you to choose between Python and JavaScript. It starts with the basics, like moving your character, then progresses to more advanced coding using loops, functions, variables and object-oriented programming.
Over 100 levels are available spanning different themes like forests, deserts, dungeons and more. By solving coding puzzles in each level, you guide your hero to accomplish their quest.
The multiplayer component offers head-to-head coding battles. You control a hero unit while coding its behavior against another player‘s hero that they‘ve also programmed. This tests your grasp of strategy and algorithms instead of syntax.
Winning arena battles and completing campaign levels earns you gold and gems. These can be used to customize your coder profile, unlock heroes with new abilities, and gain access to exclusive items and levels.
Now let‘s get CodeCombat installed on Linux!
Installing Dependencies on Linux
CodeCombat relies on various components like Python, Node.js, npm, and MongoDB. We‘ll need to set up these dependencies before installing the game itself.
Step 1 – Update Package Index
First, refresh your system‘s package index so we‘re retrieving the latest software versions:
sudo apt update
Step 2 – Install Python 2.7
CodeCombat utilizes Python 2.7 specifically, so we need to install that:
sudo apt install python2.7
Step 3 – Install Node.js and npm
These packages provide the necessary JavaScript runtime and module/package manager:
sudo apt install nodejs npm
- Node.js v12+ is recommended for performance and compatibility reasons.
- This also installs the node package manager (npm) by default.
- Npm will be used to manage JavaScript dependencies.
Step 4 – Install Build Tools
Certain build tools are required for handling CodeCombat game assets during install:
sudo apt install build-essential
- Specifically the C++ compiler and Python header files are utilized.
Step 5 – Install MongoDB
This open-source document database is used by CodeCombat:
sudo apt install mongodb
- CodeCombat uses MongoDB to store player data, including:
- User profiles
- Campaign/arena progress
- Unlocked items
- Coding solutions
- MongoDB provides flexible, scalable storage using JSON style documents.
- We‘ll use it in standalone configuration for local development.
With the key dependencies now installed, we can proceed to downloading and running the game itself!
Cloning the CodeCombat GitHub Repository
CodeCombat is open source and hosted in a GitHub repository that we can directly clone:
Step 1 – Install Git
Git allows managing source code history and coordinating updates across developers:
sudo apt install git
- Git is the most popular version control system.
- It allows pulling down the CodeCombat repository to our local system.
Step 2 – Configure Git Account
So that commits are attributed correctly by author:
git config --global user.name "Your Name"
git config --global user.email you@example.com
Replace "Your Name" and the email with your own details.
- This links code changes to your GitHub account when pushing updates.
- Not strictly required for just installing the game, but good practice nonetheless.
Step 3 – Clone CodeCombat Repository
Now we grab the latest open source code:
git clone https://github.com/codecombat/codecombat.git
- This creates a copy of the codecombat repo in
/codecombat - All game files, assets, configs will now be here.
- Initial download may take some time depending on connection speed.
Step 4 – Navigate Into Directory
Change into the freshly installed directory:
cd codecombat
Now we can proceed with setting up npm and JavaScript dependencies.
Installing npm Packages and Dependencies
CodeCombat relies on various npm packages to handle frontend, backend and multiplay game logic.
Step 1 – Set Python Path
Point Python executable to v2.7 for compatibility:
npm config set python python2.7
- Newer Ubuntu distributions have Python 3 as default.
- CodeCombat multiplayer was built against Python 2.7
- Setting this ensures packages compile properly.
Step 2 – Install JavaScript Dependencies
This will fetch all mandatory npm packages defined in package.json:
npm install
Some key packages and components installed here:
- webpack – Asset bundler and minification.
- babel – Next generation JavaScript compiler.
- Phaser – Rendering/physics game engine.
- Mongoose – MongoDB object modeling.
- Express – Backend application server.
- Mocha – Unit testing framework.
This compiles the minified client-side game code needed to run the application.
Wait for npm install to fully complete before continuing.
All set up now to actually start the game!
Running CodeCombat Multiplayer locally
With dependencies satisfied and assets built, we can launch a development server to host multiplayer games right from our Linux machine.
Step 1 – Start Development Server
Use the npm convenience script to bootstrap a local dev environment:
npm run dev
- Spawns brunch to watch for asset changes.
- Starts nodemon to auto-restart server on backend edits.
- Set to run on port 3000 by default.
Tip: To connect to the live CodeCombat cluster instead, run
npm run proxyafter this step.
Step 2 – Preview Game Client
Open any modern web browser and navigate to:
http://localhost:3000
You should see the CodeCombat Game Lobby!

- Client bundle is served from localhost.
- Static assets loaded in browser.
- Ready for multiplayer arena coding action!
Step 3 – Create Account and Join Queue
Sign up with a username, password and email to register a new account.
With that squared away, proceed to the multiplayer panel and enter the queue:

Key items on this screen:
- Battle – 1v1 battles against other players. Our main focus.
- Skirmish – Team battles with shared lives.
- Multiplayer Tips – Hints for newcomers.
- Available Modes – Select challenge types.
- Teams Panel – Create/join groups.
Go ahead and join the Battle queue to face off against random opponents.
While searching for a match, we can pre-program our hero‘s AI…
Step 4 – Script your Hero‘s Battlefield Logic
Click Code Hero on the Multiplayer menu to pull up an editor view:

Here we can author custom JavaScript to control hero actions during the next multiplayer round.
Some starting templates are provided – expand these to create more advanced behaviors like:
- Dynamically chasing low health targets
- Retreating to heal when critically injured
- Calculating when to cast spells based on mana pool
- Prioritizing heroes first, then minions
- Pathfinding via A* algorithm for navigation
This allows tailoring hero strategy to the specific battle and map type.
Pro Tip: Pay attention to evt properties so logic adapts smoothly as gameplay events occur!
When ready, click Done Editing to return to the main panel.
Our script will now automatically execute during the multiplayer round.
After a short wait, we‘ll automagically get matched with an opponent of similar rating…
Step 5 – Battle!
Once paired up, you‘ll be transported straight onto the battlefield along with your rival!

- Terrain style varies per map and game mode selected.
- Your custom hero appears bottom left, enemy top right.
- Hero will behave based on code we authored earlier!
- First to destroy their opponent‘s base wins!
Watch the action play out driven completely by the JavaScript running each hero.
You can adapt the script between matches depending on how well certain strategies performed. Discover optimal approaches to defeat opponents of increasing skill.
And remember – the true goal is expanding programming abilities along the way!
Local Multiplayer – Advanced Configurations
Running multiplayer games on your own Linux machine enables taking things further in terms of customization and control.
Performance Tuning
Certain config tweaks can help smooth out gameplay when self-hosting:
- Assign more CPU cores so that both the Node.js server and Mongo database can run on isolated threads.
- Enable compression in the Express server config for smaller network payload.
- Set process affinity to restrict Node/Mongo to specific non-overlapping cores.
- Optionally choose a lighter distro like Lubuntu or Xubuntu to conserve system resources.
Modding Mechanics
The open source nature of CodeCombat means we can alter certain arena aspects by editing the relevant configs and scripts:
- Adjust hero attributes like health, speed, damage.
- Swap out default maps or design completely new ones!
- Introduce different unit archetypes beyond just mage.
- Craft and equip powerful items via JSON data tweaks.
- Expand existing hero abilities that can be coded against.
This involves making changes under /app and /server then restarting npm.
Customizing Visuals
Since we have full access to the asset pipeline via brunch, visual tweaks are also possible:
- Change the webapp theme colors by editing stylesheets.
- Use sprite sheets to give units alternate looks.
- Tweak the rendering canvas width/height.
- Adjust camera zoom, tilt and bounds.
- Leverage WebGL instead of Canvas renderer for 3D scenes.
These allow fine tuning the experience exactly how you want it.
Security Considerations
Running your own live services introduces important security aspects around data and network exposure:
- Avoid running MongoDB as root user – drop privileges once operational.
- Set up VPN tunnel for server infrastructure to avoid DDoS attacks.
- Implement rate limiting on Express app to prevent resource overloading.
- Ensure validation on all endpoint input to block code injection efforts.
- Sanitize any web outputs to stop XSS attempts.
- Enable SSL for authentication and session security.
Adding these controls will help mitigate risk running your own instance.
Troubleshooting Multiplayer Issues
Sometimes problems can occur either building the game itself or at multiplayer runtime:
- Check mongoDB process actually started on port 27017.
- Restart job queue workers if matchmaking stalls.
- Verify babel-node version aligns with dependency spec.
nodemonmay require esm installation for import handling.- On Ubuntu disable AppArmor to let node access the filesystem.
- If clone issues, update local Git version and try again.
- Regenerate lockfiles and clear caches to resolve inconsistencies.
- Test latency issues using
npm run ping. - Watch server logs for crash stack traces.
Getting comfortable diagnosing and fixing problems yourself will help learn multiplayer architecture internals faster.
Wrapping Up
This guide took an in-depth look at installing CodeCombat locally on Linux operating systems, then explored configuration and customization of the open source multiplayer servers.
We covered aspects like:
- Installing prerequisites Python, Mongo, Node runtimes.
- Utilizing git version control for code access.
- Configuration of NPM for asset pipeline optimization.
- Building client bundles and starting local dev cluster.
- Matchmaking capabilities and queue system logic.
- Coding hero behaviors to win battlefield domination.
- Server performance tuning for optimal gameplay smoothness.
- Modding mechanics and capabilities overview.
- Security principles for running robust live services.
- Troubleshooting methodology for common issues.
CodeCombat multiplayer offers exciting coding gameplay along with learning about architecting real-time services. Challenge friends in skirmishes or take down random opponents while leveling up across competitive rankings!
The single player campaign is also worthwhile to sharpen core programming abilities with engaging PvE challenges across varied themes.
Now enjoy one of the most polished coding games available – great for Linux users of all skill brackets wanting to expand skills!


