Source project: catabriga/graphwar
Graphwar is an artillery game in which you must hit your enemies using mathematical functions. The trajectory of your shot is determined by the function you write. Your goal is to avoid obstacles and teammates and hit enemies. The game takes place in a Cartesian plane.
The Normal Function mode is the most basic mode. In this mode, the shot is exactly the function you typed, but with one important adjustment: the function is translated vertically so it passes through your soldier.
So if you enter:
y = f(x)
the actual trajectory used by the game is:
y = f(x) + c
where c is the constant needed to pass through the soldier position.
In this mode, you enter a first-order differential equation instead of a direct function.
Examples:
y' = 3*sin(x)+2y' = -y/3y' = 1/(x+y)
No translation constant is added in this mode. Your soldier position is used as the initial condition, and the fired curve is the resulting solution.
This mode is similar to first-order mode, but with second-order equations.
Examples:
y'' = -y + y' + 2*x - 1y'' = 4*sin(x) + 2^xy'' = 1.04^(-(x+y)^2)
To get a unique solution, this mode uses two initial conditions:
- soldier position;
- firing angle.
You can change the firing angle with the up/down keys. This is the only game mode where firing angle affects the curve.
Because the function is translated by +c, constants in your entered function become irrelevant.
These produce the same trajectory in-game:
y = 2*x + 3y = 2*x - 8y = 2*x
Graphwar axis limits are approximately:
x: -25 .. 25y: -15 .. 15
Functions can grow very fast.
For example, y = x^2 is 100 at x = 10, so it can hit the top quickly and look almost vertical.
Scaling helps, for example:
y = (x^2)/50
Your team is on the left side of the plane, so your soldier often starts at negative x.
That is why sqrt(x) often explodes immediately.
Safer form:
y = sqrt(abs(x))
A function can explode if:
- value is undefined (for example
log(x)at negativex); - denominator goes to zero;
- square root/log argument is invalid;
- curve becomes too long (for example high-frequency oscillations like
sin(100*x)).
xyy'
+-/*^
sqrt()log()ln()abs()sin()cos()tan()exp()
y = ((x-3)^2)/20y = ln(abs(x))y = sin(x/20)*5y' = 1.2^xy'' = (1.2^(-(x+3)^2))*(20*(-y))
Use parentheses generously to avoid misinterpretation. For example:
1/x+2means(1/x) + 2- use
1/(x+2)if that is what you want
-skip— if everyone uses this command, the current map is skipped.-sayfunc— show other players' functions in chat.-stopsayfunc— stop showing functions after-sayfunc.-shownext— highlight each player's next soldier.-stopshownext— stop showing next soldiers.
Type commands directly in the game chat.
No.
Your soldier is not at the origin.
In normal mode, the function is translated in y so it passes through your soldier at that soldier's x.
At your current soldier x, the function may have a very large value.
After translation, the visible part can become extremely steep.
Try scaling down (for example divide by 10 or 50).
Most common reasons:
- undefined value at some point (
log(x)for negativex, invalid square root, division by zero); - function length limit reached (high-frequency curves can be too long).
Angle only affects second-order differential equation mode. In other modes, changing angle does nothing.
Most likely your router blocks incoming connections. You may need to open/forward the required port in router settings.
Original project contact from tutorial:
graphwar.contact@gmail.com