Skip to content

Commit

Permalink
feat(social): add social media
Browse files Browse the repository at this point in the history
  • Loading branch information
tolstenko committed Oct 3, 2023
1 parent 63100c9 commit 0ba237e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
if [ "${{ secrets.GH_SQUID_TOKEN }}" != '' ]; then
pip install git+https://${{ secrets.GH_SQUID_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
else
pip install mkdocs-material==9.2.0b3
pip install mkdocs-material
fi
# - name: Configure
Expand Down
2 changes: 1 addition & 1 deletion blog/posts/MazeDataStructure/MazeDataStructures.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ In this version, WallData will use 1 byte per room(40x improvement). But we will
vector<bool> topWalls, rightWals, bottomWalls, leftWalls;
```

For vector, depending on the implementation, it needs to store the size of it, the capacity, and the pointer to the data, which will use 24 bytes per vector. It can reaches 32 if it stores the reference count to it as a smart pointer.
For vector, depending on the implementation, it needs to store the size of it, the capacity, and the pointer to the data, which will use 24 bytes per vector. If can reach 32 if it stores the reference count to it as a smart pointer.

So what we are going to do next? Reduce the number of vectors used to reduce overhead. If you want to go deeper, you can use only one vector<bool> where every bit is a wall. So we will have only 4 bits per room and do some math to get the right bit(80x improvement).

Expand Down
15 changes: 11 additions & 4 deletions courses/artificialintelligence/readings/spatial-quantization.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ int index = x + y * width; // index of the cell at x,y
There is a catch here, given we usually represent points as X and Y coordinates, we need to be careful with the order of the coordinates. While you are iterating over all the matrix, you need to iterate over the Y coordinate first, and then the X coordinate. This is because the Y coordinate is the one that changes the most, so it is better to have it in the inner loop. By doing that, you will have better cache locality and effectively the index will be sequential.

```c++
vector<YourStructure> data; // data is filled with some data elsewhere
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
int index = x + y * width;
// do something with the cell at index
for(int x = 0; x < width; x++) {
// do something with the cell at index x,y
data[y * width + y] = yourstrucure;
// it is the same as: data[y][x] = yourstructure;
}
}
```
Expand Down Expand Up @@ -69,6 +71,12 @@ std::vector<Vector2int> get_neighbors(Vector2int index) {
}
```

We already understood the idea of matrix flattening to improve efficiency, we can use it to represent a maze. But in a maze, we have walls to

Imagine that you are willing to be as memory efficient and more cache friendly as possible. You can use a single array to store the maze, and you can use the following formula to convert from matrix indexes to the index of the cell in the array.

```c++

## Hexagonal Grid

Hexagonal grid is an extension of a square grid, but the cells are hexagons. It feels nicer to human eyes because we have more equally distant neighbors. If used as subtract for pathfinding, it can be more efficient because the path can be more straight.
Expand Down Expand Up @@ -276,4 +284,3 @@ namespace std {
Pay attention that the hashing function above generates collisions, so you have to use a data structure that can handle collisions. You will use datastructures like `unordered_map<Vector2D, unordered_set<DATATYPE>>` or `unordered_map<Vector2D, vector<DATATYPE>>`. The first one is better for insertion and query, but it is not cache friendly.
To avoid having one bucket per every possible position, you have to setup properly the dimension of the bucket, a good sugestion is to alwoys floor the position and have buckets dimension of 1.0f. That would be good enough for most cases.
8 changes: 5 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ reveal:

edit_uri: edit/main/

copyright: Copyright &copy; 2023 Tolstenko and Others
copyright: Copyright &copy; 2023 Tolstenko, Game Guild Community and Others

markdown_extensions:
- abbr
Expand Down Expand Up @@ -195,6 +195,10 @@ markdown_extensions:
- pymdownx.tilde

plugins:
- social:
cards: true
cards_layout: default
enabled: true
- blog:
# blog_toc: true
blog_authors: true
Expand All @@ -221,8 +225,6 @@ plugins:
docs_path: ./
cache_dir: /tmp/cache/awesome-gamedev-resources
# - git-authors
- social:
cards_layout: default/accent
- git-revision-date-localized:
enable_creation_date: true
fallback_to_build_date: true
Expand Down
35 changes: 35 additions & 0 deletions overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base.html" %}

{% block extrahead %}
<!--<meta property="og:type" content="website">-->
<!--<meta property="og:title" content="Awesome Gamedev Guild">-->
<!--<meta property="og:description" content="Game Guild">-->
<!--<meta property="og:url" content="https://gameguild.gg/">-->
<!--<meta property="og:image" content="https://gameguild.gg/overrides/favicon/apple-touch-icon.png">-->
{% endblock %}


{% block scripts %}
<!-- Add scripts that need to run before here -->
{{ super() }}
<!-- Add scripts that need to run afterwards here -->
<!-- Smartlook tag (recorder.js) -->
<script type='text/javascript'>
window.smartlook||(function(d) {
var o=smartlook=function(){ o.api.push(arguments)},h=d.getElementsByTagName('head')[0];
var c=d.createElement('script');o.api=new Array();c.async=true;c.type='text/javascript';
c.charset='utf-8';c.src='https://web-sdk.smartlook.com/recorder.js';h.appendChild(c);
})(document);
smartlook('init', '2f5d1221ea7a962d4adf10180eedd4eab3e00fc4', { region: 'eu' });
</script>
<!--SEMRUSH-->
<!--<script>-->
<!-- ;(function() {-->
<!-- var script = document.createElement('script');-->
<!-- script.id = 'e07e28c9-2f81-4614-9daa-dcc86fab2401';-->
<!-- script.type = 'module';-->
<!-- script.src = 'https://pageimprove.io';-->
<!-- document.head.appendChild(script);-->
<!-- })()-->
<!--</script>-->
{% endblock %}

0 comments on commit 0ba237e

Please sign in to comment.