File:MAZE 30x20 Prim.ogv
MAZE_30x20_Prim.ogv (Ogg Theora video file, length 1 min 0 s, 732 × 492 pixels, 154 kbps, file size: 1.1 MB)
Captions
|
Summary
[edit]DescriptionMAZE 30x20 Prim.ogv |
English: The generation of a maze using a randomized Prim's algorithm. This maze is 30x20 in size. |
Date | |
Source | Own work |
Author | Purpy Pupple |
Other versions |
Source code
[edit]#include <iostream>
#include <queue>
#include <random>
#include <utility>
#include <vector>
#include <cstdio>
using namespace std;
const int xsize = 20;
const int ysize = 30;
int main() {
random_device rd;
mt19937 en(rd());
uniform_real_distribution<double> uni(0,1);
vector<int> v(xsize*ysize, 0);
vector<int> w(xsize*ysize*2, 1);
vector<vector<pair<double, pair<int, int>>>> e(xsize*ysize);
for(int i=0; i<xsize; i++) {
for(int j=0; j<ysize; j++) {
int k = i*ysize + j;
if(i>0) e[k].push_back(make_pair(uni(en), make_pair(k, (i-1)*ysize + j)));
if(j>0) e[k].push_back(make_pair(uni(en), make_pair(k, i*ysize + (j-1))));
if(i<xsize-1) e[k].push_back(make_pair(uni(en), make_pair(k, (i+1)*ysize + j)));
if(j<ysize-1) e[k].push_back(make_pair(uni(en), make_pair(k, i*ysize + (j+1))));
}
}
priority_queue <pair<double, pair<int, int>>> frontier;
int x = 0, y = 0;
v[x*ysize + y] = 1;
for(auto k : e[0]) {
frontier.push(k);
}
while(!frontier.empty()) {
auto z = frontier.top();
frontier.pop();
int a = z.second.first;
int b = z.second.second;
if(v[b]) continue;
v[b] = 2;
int aa = min(a,b);
int bb = max(a,b);
if(bb-aa == 1) {
w[2*aa] = 0;
} else {
w[2*aa+1] = 0;
}
for(auto k : e[b]) {
if(!v[k.second.second]) {
frontier.push(k);
}
}
// print the thing lol
for(int j=0; j<2*ysize+1; j++) {
cout << "1 ";
}
for(int i=0; i<xsize; i++) {
cout << endl << "1 ";
for(int j=0; j<ysize; j++) {
cout << "102"[v[i*ysize + j]] << " " << "01"[w[2*(i*ysize + j)]] << " ";
}
cout << endl << "1 ";
for(int j=0; j<ysize; j++) {
cout << "01"[w[2*(i*ysize + j)+1]] << " 1 ";
}
}
cout << endl;
v[b] = 1;
}
}
Licensing
[edit]- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 22:13, 11 June 2015 | 1 min 0 s, 732 × 492 (1.1 MB) | Dllu (talk | contribs) | Fixes a bug that caused it to be not actually Prim's algorithm. | |
01:46, 6 February 2011 | 1 min 1 s, 732 × 492 (563 KB) | Dllu (talk | contribs) | {{Information |Description ={{en|1=The generation of a maze using a randomized Prim's algorithm. This maze is 30x20 in size. The C++ source code used to create this can be seen at w:User:Purpy Pupple/Maze.}} |Source |
You cannot overwrite this file.
File usage on Commons
The following 3 pages use this file:
Transcode status
Update transcode statusFile usage on other wikis
The following other wikis use this file:
- Usage on de.wikipedia.org
- Usage on en.wikipedia.org
- Prim's algorithm
- Maze generation algorithm
- Talk:Prim's algorithm
- Wikipedia:WikiProject Mathematics/Recognized content
- Wikipedia:Featured pictures/Sciences/Mathematics
- Wikipedia:Featured pictures thumbs/25
- User:Dllu
- User talk:Dllu
- Wikipedia:Featured picture candidates/February-2011
- User:Dllu/Maze
- Wikipedia:Featured picture candidates/Maze Generation 2
- Wikipedia:Picture of the day/June 2015
- Template:POTD/2015-06-12
- Wikipedia:Main Page history/2015 June 12
- Portal:Mathematics/Recognized content
- Usage on fa.wikipedia.org
- Usage on he.wikipedia.org
- Usage on hu.wikipedia.org
- Usage on it.wikipedia.org
- Usage on kn.wikipedia.org
- Usage on ps.wikipedia.org
- Usage on ru.wikipedia.org
- Usage on sr.wikipedia.org
- Usage on uk.wikipedia.org
- Usage on vi.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Software used |
---|