Beginner's Guide

Beginner's Guide

> Encyclopedia

> _Before reading this introduction to the game, keep this in mind: the help contains many pages that explain various concepts. When a word appears in blue, it's a clickable link. These links take you to other pages where you'll find valuable information, so make the most of them to discover the game's different concepts. For example, this page won't explain everything about how the game's weapons work, but you'll surely find a link on the word "Weapon" that lets you learn more! Enjoy your reading!_

Welcome to Leek Wars!

Before coding, working out strategies or talking nonsense on the chat, you'll need to learn a bit more about Leek Wars.

In this strange game, you're a Farmer, someone entirely devoted to helping their little protégés grow. But you won't be just any farmer: you'll be taking care of Leeks! You'd already figured that out? Oh.

Your leeks aren't just vegetables. They can move (nobody knows how), and above all, they can fight. With an arsenal of Weapons and Chips that cast spells, these leeks are true war machines. They can even call on Bulbs to help them in their fights. They also have Characteristics, which make them more or less effective in certain areas. On the other hand, they've kept a sensitive soul and are slaves to fashion: they sometimes change color and put on hats.

You'll start out calmly, looking after a single scrawny leek. But it will grow fast, and with experience you'll be able to raise up to 4 leeks (Leek Wars farmers have favored quality over quantity since 1853).

But it's not enough to send your leeks into a fight: first you have to teach them how to fight! Leek Wars is first and foremost a programming game, so you'll have to create an artificial intelligence, an AI. The AI is a kind of script that your leek runs every turn and that tells it what to do.

Ready? Then let's start at... the beginning.

Distributing your capital

Your leek earns Capital Points when it levels up. Luckily, it starts with 50 points! So the first thing to do is distribute these points, but not just any old way!

Go to the Leek page: it's the first tab of the navigation bar, the one that bears your Leek's name. You'll find various information there, but the bits we're interested in are these:

!Level 1 points

Since your leek is level 1, I strongly advise you to put these points into Life !Life and Strength !Strength. The other characteristics need Chips that you haven't unlocked yet before they become useful. Life simply increases your leek's life points, which keeps it from dying too quickly. And Strength lets you deal more damage with your Weapons and your offensive Chips.

There are two more characteristics you should pay attention to. TP !TP are your Leek's action points: they determine how many actions it can perform per turn. For example, equipping a weapon costs 1 TP, and firing the Pistol costs 3. MP !MP (M*ovement *Points) determine how many cells your Leek can move in one turn.

If you want to know more about the different characteristics, it's all here: Characteristics.

On your Leek's page, you can also see that it's equipped with a Pistol. You'll need to gain a few levels before you can unlock other Weapons and Chips.

Now that your Leek is ready, let's take care of its AI!

The AI

Now go to the "Editor" tab. You'll find a first AI there, called "Untitled". It contains minimal code that makes your leek move toward its opponent and attack it.

Lines that start with // are comments. They're simply sentences that make the code clearer, not instructions your Leek will follow.

The first instruction is very important. Unlike Chips, weapons have to be held in hand to be used. A leek can carry 2 to 4 weapons depending on its level, but it can only use one at a time: it carries several weapons, but can only use the one it's holding. So you need the setWeapon function to change the weapon your leek is holding. Warning: changing the current weapon costs 1 TP, even if your leek is already holding that weapon. So it's wise to call setWeapon only when you need to. All it takes is a condition using the getWeapon function, which returns the weapon currently in use.

Next, you need a target. That's where getNearestEnemy comes in. This function returns the nearest enemy. Variants exist to find allies, or to get the farthest one rather than the nearest.

Then comes moveToward, which moves your leek toward another leek, using as many MP as possible.

Finally, the useWeapon function uses the weapon your leek is currently holding on a target. If the conditions for using the weapon are met (range, line of sight...), this function spends as many TP as the weapon needs; otherwise, it uses no TP (and your leek won't shoot).

That's this code in detail. Keep in mind that it isn't the code for the whole fight: it's the code that runs every turn! Each time it's your leek's turn to play, it will equip its weapon, move toward its opponent, and attack.

Attacking effectively

But you won't get very far with this code! It's only a template, and it's far from efficient.

In the first instruction, you equip the Pistol (WEAPON_PISTOL). Take a good look at its card (available in the Market):

The star symbol ![](/image/charac/small/tp.png) shows how many TP it costs to use this weapon.

And when you distributed your Capital Points, you may have noticed that you had 10 TP. See where I'm going with this?

This line only makes you fire your weapon once:

So you still have 7 TP left after using it. You can fire twice more! (6 TP left in fact, because of the setWeapon(WEAPON_PISTOL); that costs 1)

Change the code to fire your weapon 3 times. You'll deal much more damage.

If you're new to programming, just write the instruction 3 times.

If you have some experience, do it in a loop.

Using a chip

From level 2, you also get access to a chip. Unlike weapons, chips don't need to be "held in hand". Just equip a chip on your Leek's page and you can use it.

To use a chip, call the useChip function. It takes two parameters: the chip to use and the target.

So, to use the Shock chip on the nearest enemy, do this:

CHIP_SHOCK is the constant for the Shock chip; you can find it on the chip's card in the Market.

Picking fights with your fellow leeks

Your Leek is all set for fights! Time to head to the Garden and take on other leeks!

Pick one of the 5 leeks on offer and fight it. You earn Experience and Habs (the game's currency) when you fight in the Garden.

Every day, you get 50 fights to start in the Garden. If you don't use all your fights, they build up to 100. However, fights you've bought in the Market are kept forever and add up with your free fights. For example, if you have 50 fights left and buy 100, you'll have 150 available, and 200 the next day (100 bought + 100 free fights).

Conclusion

You now know everything you need to get off to a good start in Leek Wars.

From here, you'll need to sharpen your skills as an AI developer and strategist to progress.

If this is your first time programming, I invite you to read this LeekScript Tutorial, which will help you get familiar with the language.

On the other hand, if it isn't your first time programming, I can only recommend reading this Advanced LeekScript Tutorial.

If you have a question or run into a problem, feel free to post a message on the Chat or start a topic on the Forum: the other players will be happy to guide you.

Good luck, young farmer!