You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a simple guide for Graphwar, which contains some stuff that should be noted and some useful skills. And I'm also a beginner of this game who started to play it only a few days ago (and my English is not very good). So there may be some errors in this guide. If you find any errors or have any suggestions, please let me know, I'll appreciate it.
Anyway, 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 wrote, and your goal is to avoid the obstacles and your teammates and hit your enemies. The game takes place in a Cartesian Plane.
There are 2 teams in a game, and any player should and can only be in one team.
After everyone has clicked the $\checkmark$ button and turned green, the game will start after 5 seconds. So click the button, don't make other guys wait for you.
A kinda annoying point is that there are many reasons, such as someone joining or leaving the room, that will make you turn back to white. Now you have to click the button again.
Your teammates and you are always on the left side ($x<0$). Your enemies are always on the right side ($x>0$). Or you can check someone's orientation to judge which side they are on: facing right is your teammates, facing left is your enemies. And you can kill your teammates in this game. So PLZ! don't kill your teammates! You know what? I've been killed because of this many times.
The character you control will become red when it's your turn. Now you can input any function expression in the input box. Click "Fire" button or press "Enter" to fire. The bullet will move according to the corresponding curve of your function from left to right. And you can only fire once per turn.
In the normal mode (y mode) (I'll talk about ODE mode (y' and y'' mode) later), assume the function you input is $f$, and your coordinates are $(x_0,y_0)$, then the real moving curve of your bullet is:
$$
f_{\text{real}}(x)=f(x)+(y_0-f(x_0))
$$
That is, instead of treating the position of the launcher as the origin of your function curve, the game will ensure that the function curve always passes through the launcher's position by shifting the curve up or down. That's why you will get a very steep curve if you use $x^2$ or $x^3$. Try using $(x-x_0)^2$ or $(x-x_0)^3$ to make it kinda normal.
Clearly, $f_{\text{real}}$ is defined only for $x\ge x_0$. So the curve doesn't exist for $x<x_0$.
Since you can only input a function expression in the input box, which means for any input $x$ there is at most one corresponding $f(x)$. It's impossible for an input to correspond to multiple values. So it's clear that the bullet cannot move to the left, that is, the $-x$ direction.
The black fucking circles are obstacles. If your bullet hits them, it will explode and make a small hole, and the bullet will disappear.
If your bullet hits your teammates or your enemies, they will be killed but your bullet will continue to move.
Roughly and ideally, the battlefield is in a $[-25,25]\times[-15,15]$ rectangular area. If the bullet hits the boundary, it will disappear.
Precisely, at least in Graphwar I, because of some features, the battlefield is in $[-25,25)\times[-\frac{1125}{77},\frac{1125}{77})$, where $25=\frac{50\cdot 770}{770\cdot2},\frac{1125}{77}=\frac{50\cdot 450}{770\cdot 2}\approx 14.6103896$
If the function is undefined at the point that bullet passes through, like $y=\sqrt{x}$ and the bullet passes through some $x<0$, the bullet wimage-20260625200104823ill disappear.
If the function value is too large, or more fundamentally and more generally, the function value is NaN, the bullet will disappear.
The distance your bullet can move, that is, the length of your function curve, is finite. If the distance is too long, the bullet will disappear. That's why something like $\sin(100x)$ usually doesn't work.
The map of a game is random. If you get a dumbass map, type -skip in the chat box and ask other guys to type it. The game will generate a new random map if everyone types -skip.
Syntax
Variables
x: $x$
y: $y$
y': $y'$
Binary Operators
+: $+$
-: $-$
*: $\times$
/: $\div$
^: power, such as x^2 is $x^2$
Functions
sqrt(): square root, such as sqrt(x) is $\sqrt{x}$
ln(): natural logarithm, such as ln(x) is $ln(x)$
log(): common logarithm, such as log(x) is $log_{10}(x)$
abs(): absolute value, such as abs(x) is $|x|$
sin() or sen(): sine, such as sin(x) is $sin(x)$
cos(): cosine, such as cos(x) is $cos(x)$
tan() or tg(): tangent, such as tan(x) is $tan(x)$
exp(): exponential, such as exp(x) is $e^x$
Constants
pi: $\pi$
e: $e$
Brackets
( and ): brackets. Using brackets more frequently to avoid incorrect order of operations.
which means the function is $-k/2|a-b|$ when $x\lt a$, a linear function with slope $k$ when $x\in[a,b]$, and $k/2|a-b|$ when $x\gt b$
There are so many cheaters who like to use the combination of this function. If you see someone send a whole string of this stuff with very precise coefficients, it's very likely to be a cheater.
Sine and cosine function:
Although $\sin$ and $\cos$ are very basic, they are very useful to sweep a wide area if you give them a big angular velocity.
General step function:
$$
\frac{f(x)}{1+e^{-m(x-a)}}
$$
That is: ((f)/((1+exp(-m*(x-(a))))))
where $m\in\mathbb{R}_+$ is a big positive number.
This function can approximate the following function:
That is, the function is 0 when $x\lt a$, and $f(x)$ when $x\ge a$.
This function can be used to make any function $f(x)$ work only after passing through a certain point. But if you want to let it work only for an interval, the General step function can't help you. Now you need the following stuff.
You may notice that the function is just the multiplication of a step function and a step-like function.
(And btw I constructed another version of $\mathbf 1_{(a,b)}(x)$ by combining power functions like: $\mathbf1_{(a,b)}(x)=\left(1+\left(\frac{x-\frac{a+b}{2}}{\frac{a-b}{2}}\right)^{2m}\right)^{-1}$. But it's not useful because you have to replace $a$ and $b$ twice and $m$ must be a natural number.)
That is, the sum of something like ((f)*(1/((1+exp(-m*(x-(a))))*(1+exp(m*(x-(b)))))))
If you played with me in the game, you will see that I usually use this function to construct any function I want. It's very useful for me, which is one of the best functions in my mind.
Periodic spike function:
$$
\frac{h}{(1+m(\sin(\frac{\pi x}{T}))^2)}
$$
That is: ((h)/(1+m*(sin((pi*x)/(T)))^2))
where $m\in\mathbb{R}_+$ is a big positive number.
The function creates a spike every $T$ units.
This function can also sweep a wide area by creating many spikes.
That is: ((f)/(1+exp(-m*(sin(pi*(x-p)/(T))sin(-(pi*x)/(T))))))
where $m\in\mathbb{R}_+$ is a big positive number, $T$ is the period, and $p\in(0,T)$.
In a period $[kT,kT+T)$, the function will be $f$ if $x\in[kT,kT+p)$, otherwise it will be $0$.
Based on this function, you can do many interesting things.
ODE mode
Mechanism
As you can see, there are 2 modes of ODE mode: y' mode and y'' mode, corresponding to the first and second derivatives of $y$ with respect to $x$.
Like the normal mode, you can input any function expression in the input box to set the trajectory of your bullet. But it allows you to use variables other than $x$, like $y$ in y' mode and $y,y'$ in y'' mode. (For the variable y'. There was a bug in the previous version which made it would be matched with y instead of y'. But it has been fixed in the latest version. So remember to update your game.)
As Syntax said, y means $y$, and y' means $\frac{dy}{dx}$.
Instead of regarding the expression as a function, the game will treat it as an ordinary differential equation (ODE) to describe the moving curve of your bullet. But it is still essentially a function, so like the normal mode, you can't let the bullet to move to left.
Assume you have understood the above stuff, I will show you how the bullet moves in ODE mode.
Assume the coordinates of the launcher are $(x_0,y_0)$
For the first order ODE i.e. y' mode, assume the expression you input is $E(x,y)$, then the corresponding moving curve of your bullet is the solution of the following Initial Value Problem (IVP):
For the second order ODE i.e. y'' mode, the moving curve is also the solution of a certain IVP, but it's clear that you need $2$ initial conditions instead of $1$ in this case. The first initial condition is the same, the game takes the firing angle as the second initial condition, which can be modified by pressing the up/down arrow keys in your turn.
Assume the firing angle is $\theta$, the expression you input is $E(x,y,\frac{dy}{dx})$ (i.e. $E(x,y,y')$), then the corresponding moving curve of your bullet is the solution of the following IVP:
Graphwar computes the curve by using the 4th order Runge-Kutta method whether in y' mode or y'' mode because any $n$th order ODE is equivalent to a first order ODE system, as follows:
Perhaps you'll say that it's too difficult to construct a curve you want in ODE mode, it seems that the useful functions and skills in the normal mode are useless stuff here. Because it looks like you have to compute the first order or even the second order derivative of the above functions, which is too complex and even almost impossible in some cases such as abs(). But don't worry, what if I tell you there is a way to approximate the function in normal mode using a simple ODE to avoid any derivative?
Next let's assume the function you want to cook is $f$, the following way can make the moving curve of your bullet EXACTLY the approximation to the curve of $f$ i.e. it is not like the normal mode, $f$ won't be shifted up or down. That is, you don't need to guess your $y_0$ coordinate any more if you use the skill I'll tell in ODE mode. So from the point, it seems that the ODE mode is easier than the normal mode.
Let $M$ be a big positive number, normally $M=233$ is enough. (If $M$ is too big, the final curve will oscillate so frequently that the length of the curve will easily exceed the upper bound.)
y' mode
$$
M(-y+f)
$$
That is: M*(-y+(f))
Here is the strict proof of the validity:
Proposition:
Let $f$ be a differentiable function where $f'$ is bounded. Consider the following IVP: