Aldous-Broder算法
本篇文章禁止转载 算法介绍英文说明原文Aldous-Broder algorithmThe Aldous-Broder algorithm also produces uniform spanning trees. 1.Pick a random cell as the current cell and mark it as visited. 2.While there are unvisited cells: 1.Pick a random neighbour. 2.If the chosen neighbour has not been visited: 1.Remove the wall between the current cell and the chosen neighbour. 2.Mark the chosen neighbour as visited. 3.Make the chosen neighbour the current cell. 本人的翻译Aldous-Broder算法Aldous-Broder算法也生成统一的生成树。 1。选择一个随机...
Wilson‘s algorithm
本篇文章禁止转载 (Wilson算法)算法介绍英文说明原文We begin the algorithm by initializing the maze with one cell chosen arbitrarily. Then we start at a new cell chosen arbitrarily, and perform a random walk until we reach a cell already in the maze—however, if at any point the random walk reaches its own path, forming a loop, we erase the loop from the path before proceeding. When the path reaches the maze, we add it to the maze. Then we perform another loop-erased random walk from another arbitrary starting cell,...
Randomized Kruskal‘s algorithm
本篇文章禁止转载 随机Kruskal算法随机Kruskal算法介绍这个算法是Kruskal算法的随机化版本。 1。创建所有墙壁的列表,并为每个单元格创建一个集合,每个集合只包含一个单元格。 2。对于每一面墙,以随机的顺序访问: 1。如果由这个墙壁分隔的单元格属于不同的集合: 1。移除当前的墙。 2。合并被这面墙分开的两个集合。 生成的迷宫偏向于多支路的短的死胡同。 Python代码1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192#!/usr/bin/python3.7# -*- coding: utf-8 -*-import randomimport pygame# Randomized Kruskal's algorithm# This algorithm...
Randomized Prim‘s algorithm
本篇文章禁止转载 (随机普里姆算法)随机普里姆算法介绍 1。从布满墙壁的网格开始。 2。选一个细胞,把它标记为迷宫的一部分。将单元格的墙添加到墙列表中。 3。名单上有墙: 1。从列表中随机选择一面墙。如果墙壁分开的两个单元格中只有一个被访问,那么: 1。将墙壁做成通道,并将未造访的单元格标记为迷宫的一部分。 2。将单元格相邻的墙添加到墙列表中。 2。把墙从列表中移除。 生成的迷宫偏向于多支路的短的死胡同。 代码Python代码:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103#!/usr/bin/python3# -*- coding: utf-8 -*-import random## Randomized Prim&...
Randomized depth-first search
本篇文章禁止转载 随机深度优先搜索算法随机深度优先搜索介绍递归实现 1。选择初始单元格,将其标记为已访问,并将其压入堆栈 2。而堆栈不是空的 1。从堆栈中弹出一个单元格并使其成为当前单元格 2。如果当前单元有任何未被访问的邻居 1。将当前单元格压入堆栈 2。选择一个未被拜访的邻居 3。移除当前单元格和所选单元格之间的墙 4。将选中的单元格标记为已访问的,并将其压入堆栈 生成的迷宫偏向于长胡同。 Python代码1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889#!/usr/bin/python3.7# -*- coding: utf-8 -*-import random# Randomized depth-first search# Recursive implementation#1...
MFC菜单自动折叠(隐藏)的关闭
MFC菜单自动折叠位于int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)中1234567891011121314151617181920212223242526272829303132333435363738394041424344int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){ //... //省略的代码 //... // 启用菜单个性化(最近使用的命令) // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail(ID_FILE_NEW); lstBasicCommands.AddTail(ID_FILE_OPEN); lstBasicCommands.AddTail(ID_FILE_SAVE); lstBasicCommands.AddTail(ID_FILE_...
制作centos7 livecd
1、安装工具1yum install livecd-tools syslinux anaconda-runtime -y 2、编写kickstart脚本ks.cfg 12345678910111213141516171819202122232425262728293031323334lang en_US.UTF-8keyboard ustimezone US/Easternauthconfig --enableshadow --passalgo=sha512 # 登录身份使用 sha1 的 512bits 加密算法selinux --disabled # selinux 功能禁用firewall --disabled#selinux --enforcing#firewall --enabled --service=mdns#repo --name=base --baseurl=file:///media/ # media/ iso挂载目录repo --name=base --baseurl=http://192.168.8.121/centos/os/xco...
PXE启动livecd
pxelinux.cfg的配置 1234567891011121314default vesamenu.c32 # 一般在iso中isolinux/vesamenu.c32 timeout 100 # 等待时间label pxeboot menu label livecentos boot # 菜单名 kernel vmlinuz0 #vmlinuz0 是iso镜像中的isolinux/vmlinuz #livecd中可能没有要去制作live的镜像中找 append initrd=initrd0.img root=live:http://192.168.8.121/livecentos/LiveOS/squashfs.img #initrd0.img是iso中的isolinux/initrd.img livecd中可能没有要去制作live的镜像中找 #squashfs.img iso中的LiveOS/squashfs.img #http://192.168.8.121/livecentos/LiveOS/squashfs.img #用http方式共享...
python 组播
123456789101112131415161718192021222324# -*- coding: utf-8 -*-import structimport timeimport socketip = '225.0.0.37'port = 7776 def receiver(): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('0.0.0.0', port)) mreq = struct.pack("=4sl", socket.inet_aton(ip), socket.INADDR_ANY) sock.setsockopt(socket.IPPROTO_IP,socket.IP_ADD_MEMBERSHIP,mreq) while Tr...
python UDP广播
123456789101112131415161718#!/usr/bin/python python # -*- coding:UTF-8 -*-# UDP 广播接收from socket import *HOST = '0.0.0.0'PORT = 6681BUFSIZE = 1024broadcastrecv = socket(AF_INET, SOCK_DGRAM)broadcastrecv.bind((HOST,PORT))print('wating...')while True: data, addr = broadcastrecv.recvfrom(BUFSIZE) print('recv: %s %s'%(addr,data) ) broadcastrecv.close() 123456789101112131415161718192021#!/usr/bin/python python # -*- coding:UTF-8 -*-# UDP广播发送from socket import *HO...