Skip to content

Commit

Permalink
travelling salesman problem
Browse files Browse the repository at this point in the history
  • Loading branch information
jolav committed Jan 14, 2024
1 parent 47b0471 commit 8403466
Show file tree
Hide file tree
Showing 23 changed files with 3,346 additions and 25 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

# [BETAZONE](https://jolav.github.io/betazone) ![logo](https://github.com/jolav/betazone/blob/master/www/assets/idea64.png?raw=true)

<hr>

### ![logo](https://raw.githubusercontent.com/jolav/betazone/master/www/assets/map48.png) **MAP GENERATOR**

### ![logo](https://raw.githubusercontent.com/jolav/betazone/master/www/assets/map48.png) **MAP GENERATOR**
Procedural Map Generator using Voronoi diagram with Euclidean, Manhattan and Minkowski Metrics

**[Work in Progress](https://jolav.github.io/betazone/mapGenerator/mapGen.html)**
**[LIVE DEMO](https://jolav.github.io/betazone/mapGenerator/mapGen.html)**

Procedural Map Generator
![Example](https://github.com/jolav/betazone/blob/master/www/assets/mapGen.png?raw=true)

<hr>

Expand All @@ -23,6 +25,16 @@ Map Generator using Dungeon-Building Algorithm from roguebasin.

<hr>

### ![logo](https://raw.githubusercontent.com/jolav/betazone/master/www/assets/traveller32.png) **TRAVELLING SALESMAN PROBLEM**

Given a list of cities and the distances between each pair of cities, what is he shortest possible route that visits each city at least once and returns to the origin city.

**[LIVE DEMO](https://jolav.github.io/betazone/tsp/travelling.html)**

![Example](https://github.com/jolav/betazone/blob/master/www/assets/travelling.png?raw=true)

<hr>

### ![logo](https://raw.githubusercontent.com/jolav/betazone/master/www/assets/life48.png) **JOHN CONWAY'S GAME OF LIFE**

**[LIVE DEMO](https://jolav.github.io/betazone/game-of-life/life.html)**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added www/assets/mapGen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/assets/traveller32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/assets/traveller48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/assets/travelling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions www/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
.big {
display: none
}

.small {
display: block;
}

.header {
margin-top: 5px;
}

.toolTile {
padding: 5px;
}
Expand All @@ -19,18 +22,23 @@
.big {
display: block
}

.small {
display: none;
}

h1 span {
font-size: 1.5em;
}

.header {
margin-top: 10px;
}

.footer {
margin-top: 10px;
}

.toolTile {
padding: 10px;
}
Expand Down
57 changes: 36 additions & 21 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,68 +42,83 @@ <h1 class="big centerText">
<strong>Map Generator</strong>
</div>
<p>
Procedural Map Generator
Procedural Map Generator using Voronoi diagram with Euclidean, Manhattan and Minkowski Metrics
</p>
</div>
</a>
</div>

<div class="tool service">
<a href="#">
<!--"./sp500/sp500.html">-->
<a href="./dungeonMap/dungeonMap.html">
<div class="toolTile">
<div class="title centerText">
<img class="verticalImage" src="./assets/stock32.png" alt="stock">
<strong>SP 500</strong>
<img class="verticalImage" src="./assets/rogue32.png">
<strong>Dungeon Map Generator</strong>
</div>
<p>
<strong>UPDATE 2020-07-31 <br>
IEX CLOUD FREE DATA DEPLETED.</strong><br>
Real Time Standard & Poor's 500 common stocks issued by 500 large-cap companies and traded on American stock
exchanges.<br>
Map Generator using Dungeon-Building Algorithm from roguebasin.
</p>
</div>
</a>
</div>


<div class="tool service">
<a href="./tetris/tetris.html">
<a href="./gameOfLife/life.html">
<div class="toolTile">
<div class="title centerText">
<img class="verticalImage" src="./assets/tetris32.png">
<strong>Tetris</strong>
<img class="verticalImage" src="./assets/life48.png">
<strong>Game Of Life</strong>
</div>
<p>
The great classic game. Play now. Can you beat the high score?
John Conway's Game of life
</p>
</div>
</a>
</div>

<div class="tool service">
<a href="./dungeonMap/dungeonMap.html">
<a href="./tsp/travelling.html">
<div class="toolTile">
<div class="title centerText">
<img class="verticalImage" src="./assets/rogue32.png">
<strong>Dungeon Map Generator</strong>
<img class="verticalImage" src="./assets/traveller32.png">
<strong>Travelling Salesman Problem</strong>
</div>
<p>
Map Generator using Dungeon-Building Algorithm from roguebasin.
Given a list of cities and the distances between each pair of cities, what is the shortest possible route
that visits each city at least once and returns to the origin city.
</p>
</div>
</a>
</div>

<div class="tool service">
<a href="./tetris/tetris.html">
<div class="toolTile">
<div class="title centerText">
<img class="verticalImage" src="./assets/tetris32.png">
<strong>Tetris</strong>
</div>
<p>
The great classic game. Play now. Can you beat the high score?
</p>
</div>
</a>
</div>

<div class="tool service">
<a href="./gameOfLife/life.html">
<a href="#">
<!--"./sp500/sp500.html">-->
<div class="toolTile">
<div class="title centerText">
<img class="verticalImage" src="./assets/life48.png">
<strong>Game Of Life</strong>
<img class="verticalImage" src="./assets/stock32.png" alt="stock">
<strong>SP 500</strong>
</div>
<p>
John Conway's Game of life
<strong>UPDATE 2020-07-31 <br>
IEX CLOUD FREE DATA DEPLETED.</strong><br>
Real Time Standard & Poor's 500 common stocks issued by 500 large-cap companies and traded on American stock
exchanges.<br>
</p>
</div>
</a>
Expand Down
3 changes: 2 additions & 1 deletion www/mapGenerator/mapGen.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Procedural Map Generator">
<meta name="description"
content="Procedural Map Generator using Voronoi diagram with Euclidean, Manhattan and Minkowski Metrics">

<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="../assets/jolav32.png">
Expand Down
57 changes: 57 additions & 0 deletions www/tsp/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* */

console.log('Loading.....data.js');

const d = {
cities: 0,
paths: 0,
start: 0,
nodes: [],
graph: undefined,
};

function parseRawData(rawData) {
rawData = rawData.split("\r\n");
let index = 1;
for (let line of rawData) {
if (index === 1) {
d.cities = parseInt(line);
d.graph = initializeMultiArray(d.cities, d.cities, 0);
}
if (index === 2) {
d.paths = parseInt(line);
}
if (index === 3) {
d.start = parseInt(line);
}
if (index > 3 && index <= d.cities + 3) {
const x = parseInt(line.split(" ")[0]);
const y = parseInt(line.split(" ")[1]);
d.nodes[index - 3] = { x: x, y: y };
}
if (index > d.cities + 3 && index <= 3073) {
const a = parseInt(line.split(" ")[0]);
const b = parseInt(line.split(" ")[1]);
const weight = parseInt(line.split(" ")[2]);
d.graph[a][b] = weight;
d.graph[b][a] = weight;
}
index++;
}
}

function initializeMultiArray(cols, rows, value) {
let array = [];
for (let i = 1; i <= cols; i++) {
array[i] = [];
for (let j = 1; j <= rows; j++) {
array[i][j] = value;
}
}
return array;
}

export {
parseRawData,
d,
};
Loading

0 comments on commit 8403466

Please sign in to comment.