Coverage report for ai


src/
File: src/run/patterns/RunToLinemate.cpp
Date: 2024-06-25 10:57:00
Lines:
0/31
0.0%
Functions:
0/9
0.0%
Branches:
0/58
0.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy/ai
4 ** File description:
5 ** RunToLinemate.cpp
6 */
7
8 #include "../../bots/ABotPattern.hpp"
9
10 void ABotPattern::runToLinemate()
11 {
12 if (_state.metadata["should_update_env"] == "true")
13 {
14 if (_iteration > 50 && _iteration < 55)
15 queue.push_back({[&]()
16 { doAction(LEFT, ""); }, "LEFT"});
17 if (_iteration > 100 && _iteration < 105)
18 queue.push_back({[&]()
19 { doAction(RIGHT, ""); }, "RIGHT"});
20 queue.push_back({[&]()
21 { doAction(LOOK, ""); }, "LOOK"});
22 return;
23 }
24 else
25 {
26 std::unordered_map<std::string, std::function<void()>> actions = {
27 {"FORWARD", [&]()
28 { doAction(FORWARD, ""); }},
29 {"LEFT", [&]()
30 { doAction(LEFT, ""); }},
31 {"RIGHT", [&]()
32 { doAction(RIGHT, ""); }},
33 };
34 std::unique_ptr<Tile> tile = _state.environment.getTileByRessource("linemate");
35 if (tile != nullptr)
36 {
37 std::pair<int, int> coord = {tile->x, tile->y};
38 if (movementMap.find(coord) != movementMap.end())
39 {
40 for (const auto &move : movementMap[coord])
41 {
42 queue.push_back({actions[move], move});
43 }
44 }
45 queue.push_back({[&]()
46 { doAction(INCANTATION, ""); }, "INCANTATION"});
47 }
48 if (tile == nullptr)
49 {
50 queue.push_back({[&]()
51 { doAction(FORWARD, ""); }, "FORWARD"});
52 }
53 }
54 }
55