Terminal Game Q&A

Ah, perfect. I was misunderstanding how the action phase was processed. I thought that the stateType == 1 string was only sent back once at the end of the action phase, containing the resulting game state after all the action frames. If this is sent once per frame I can definitely find the frame I want to look at. Thanks.

1 Like

Alright, more questions, woohoo!
Today’s thought: Because action frames are handled by the game engine after the ‘build’ and ‘deploy units’ phases are submitted by our algos, if we desired a more advanced predictive pathfinding method to determine optimal unit placement, one that took into account path changes due to destroyed units, is the only way to do this currently to write our own mini game engine that runs the action phase inside our algos?

1 Like

You have to decide where to deploy ahead of time ya. But, you can try to predict changes in the map. For example one of your firewalls or enemy firewalls might be very damaged and so likely to be destroyed. What you can do is edit the game_state map and remove those firewalls, so that the path the pathfinding returns takes that into account. Similarly, you can make copies of the game_state that add extra firewalls, or go through other hypothetical situations that are likely to occur. For example if you are thinking of removing one of your firewalls so your units path better, you can make a copy of the game_state and remove the firewall, get the new path, and check to see if its better, and if it is refund that firewall (remember it takes a turn to refund, so don’t deploy your information units until after a turn).

Relevant code:

Make copy of game_state:
game_state2 = gamelib.GameState(self.config, turn_state)

Add or remove a unit manually:
game_state2.game_map.add_unit(FILTER, [13,13], 0)
game_state2.game_map.remove_unit([13,13])

Get path:
game_state2.find_path_to_edge([13,0], game_state2.game_map.TOP_RIGHT)

1 Like

Ah ok. Pathing on hypothetical maps is almost as good.

I was thrown off by this entry in the documentation:

add_unit(unit_type, location, player_index=0)[source] :
Add a single GameUnit to the map at the given location.

Args:
unit_type: The type of the new unit
location: The location of the new unit
player_index: The index corresponding to the player controlling the new unit, 0 for you 1 for the enemy
This function does not affect your turn and only changes the data stored in GameMap. The intended use of this function is to allow you to create arbitrary gamestates. Using this function on the GameMap inside game_state can cause your algo to crash.

But I suppose this does not crash as long as you copy gamestate first and don’t submit the modified copy?

1 Like

Ya that’s there just to advise you to make a copy basically. We should change the wording.

If you make a copy of it, it should be fine.

1 Like

Hi,

I’m new, so sorry if this information is somewhere in the docs and I missed it. I’m a bit confused about where our logic begins and where the engine takes over. From the getting started tutorial, it says:

Movement and Pathing are automated by the game’s engine.

And it goes on to explain the logic behind the engine’s movement.

However, when looking at the file structure of starter-algo there is a file navigation.py and the very first function has the comment:

This class helps with pathfinding. We guarantee the results will
be accurate, but top players may want to write their own pathfinding
code to maximize time efficiency

Is the tutorial simply explaining the way this default library works, and we are free to expand/change it in navigation.py? Does this apply to the other files? I understand that the pathfinding library will probably be just fine for most applications; I am just trying to get a sense of what aspects we as the user have control over.

Thanks!

1 Like

Great question.

Players cannot control their units pathing at all. The provided pathfinding function is used to predict where a unit will path. Calling game_state. find_path_to_edge(location, edge) is the same as asking 'If there is a unit at this location, what path will it take to reach its target edge?" As opposed to telling a unit to actually take some path.

2 Likes

How do packages work? Is it possible to import a package, and use it with the AI on the website?

And can we use files that are created in the algo folder? For example, if I want to import some data from a .txt file in the algo folder, is that possible?

1 Like

Thanks for the answer @RegularRyan, that makes sense. So we are free to edit that file, etc, but it would be mostly pointless because it will not change our bots behavior. Instead, it could end up giving us false information as we evaluate possible future positions.

3 Likes

You can store whatever you want in the algo folder you upload including a .txt with data (as long as the total folder size isn’t ridiculously huge). Note however, that the .txt wouldn’t change between matches. It would be the same .txt you uploaded to the site originally.

As for packages see this answer: Machine learning libraries
Essentially for now just include the library files themselves in the algo you upload. You can also import default libraries in python3.

2 Likes

Quick question, what does ELO mean for algorithms? I see it listed on the algos page and it seems to rank the algos on the leaderboard, but I don’t see it listed anywhere in the docs.

2 Likes

ELO is a commonly used metric for ranking a lot of games use. Essentially more you win the higher it gets and it takes into account the ELO of the enemy as well. So if you beat someone with a high ELO you gain a lot of ELO.

1 Like

@jafioti
TL;DR: your algo starts with 1500 ELO points. You face other algos with similar ELO. The winner will take ELO from the loser.

1 Like

Did something break? Global leaderboard matches are ending in crashes left and right. I’m sitting here watching all the ELO’s drop like stones, haha.
Just watched 4 replays in a row where both mine and the opponent algo crashed on Turn 0… yet nothing has been changed or recompiled since its been working well for a few days.

1 Like

It seems that now it’s working again. At least, after three crashed matches, my last match went correctly; so I guess everything is going well now.

1 Like

@KauffK, @salanueva

We deployed a hotfix around 6pm EST today, and some of our services were desynchronized during that process (The server that runs ranked games and some data it depends on).

One of them updated about 10 minutes before the other, and during that time ranked games would crash when started. This issue has been resolved, and we will be working on our update process to make things smoother in the future.

1 Like

What is the good way to play adaptive in defense?

One way to do this is to save gamestate from previous turn before combat phase and compare with actual turn to get the list of destoroied firewalls and guess that if u lost a health points and firewalls at given location that means that u need more defense around this location.

But this solution is time consuming. Did i miss something? Is there any easy way to get information about what units did my opponent deploy last turn and if/ where did they hit me?

1 Like

If you look into the algocore, you can see how the engine and game communicate, and get data about action phase frames. Its a fairly small hint, but hopefully it helps a little! Like any programming goal there are lots of ways to accomplish this, its up to you to find the best one

3 Likes

Here’s a question. For the CodeBullet challenge, it does not seem to allow me to select an algo. Whenever I choose any of my algos from the drop-down menu, after refreshing the page, the selection has changed back to “Pick my best algo”. Is there something I’m missing about how this works?

1 Like

@KauffK - Did you look at your row in the player table to see if it updated your algo choice there?

1 Like