Добавлен scopterectus,
опубликован
Построение треугольника Серпинского на движке Warcraft 3 методом хаоса.
Клавиши управления
ESC - запускает/перезапускает генерацию точек.
Генерация точек
library Fractal initializer Initialization
globals
private constant integer DOT_ID = 'hfoo'
endglobals
struct dot extends array
private static constant group allUnits = CreateGroup( )
static method removeAll takes nothing returns nothing
local unit enumUnit = null
loop
set enumUnit = FirstOfGroup( allUnits )
exitwhen ( enumUnit == null )
call GroupRemoveUnit( thistype.allUnits, enumUnit )
call RemoveUnit( enumUnit )
endloop
endmethod
static method create takes real x, real y returns thistype
call GroupAddUnit( thistype.allUnits, CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), DOT_ID, x, y, bj_UNIT_FACING ) )
return thistype( 0 )
endmethod
endstruct
globals
private real lastX
private real lastY
private real array attractorX
private real array attractorY
endglobals
globals
private constant timer period = CreateTimer( )
integer iterations = 0
endglobals
private function iterate takes nothing returns nothing
local integer i = GetRandomInt( 0, 2 )
local real dx = attractorX[ i ] - lastX
local real dy = attractorY[ i ] - lastY
local real dist = SquareRoot( dx * dx + dy * dy )
set lastX = lastX + ( dist / 2 ) * ( dx / dist )
set lastY = lastY + ( dist / 2 ) * ( dy / dist )
call dot.create( lastX, lastY )
call PingMinimap( attractorX[ 0 ], attractorY[ 0 ], 0.03125 )
call PingMinimap( attractorX[ 1 ], attractorY[ 1 ], 0.03125 )
call PingMinimap( attractorX[ 2 ], attractorY[ 2 ], 0.03125 )
set iterations = iterations + 1
call ClearTextMessages( )
call BJDebugMsg( "|cFFFFCC00iterations :|r " + I2S( iterations ) )
endfunction
function start takes nothing returns nothing
set iterations = 0
call dot.removeAll( )
set lastX = GetRandomReal( GetRectMinX( bj_mapInitialPlayableArea ), GetRectMaxX( bj_mapInitialPlayableArea ) )
set lastY = GetRandomReal( GetRectMinY( bj_mapInitialPlayableArea ), GetRectMaxY( bj_mapInitialPlayableArea ) )
call dot.create( lastX, lastY )
set attractorX[ 0 ] = GetRandomReal( GetRectMinX( bj_mapInitialPlayableArea ), GetRectMaxX( bj_mapInitialPlayableArea ) )
set attractorY[ 0 ] = GetRandomReal( GetRectMinY( bj_mapInitialPlayableArea ), GetRectMaxY( bj_mapInitialPlayableArea ) )
call dot.create( attractorX[ 0 ], attractorY[ 0 ] )
set attractorX[ 1 ] = GetRandomReal( GetRectMinX( bj_mapInitialPlayableArea ), GetRectMaxX( bj_mapInitialPlayableArea ) )
set attractorY[ 1 ] = GetRandomReal( GetRectMinY( bj_mapInitialPlayableArea ), GetRectMaxY( bj_mapInitialPlayableArea ) )
call dot.create( attractorX[ 1 ], attractorY[ 1 ] )
set attractorX[ 2 ] = GetRandomReal( GetRectMinX( bj_mapInitialPlayableArea ), GetRectMaxX( bj_mapInitialPlayableArea ) )
set attractorY[ 2 ] = GetRandomReal( GetRectMinY( bj_mapInitialPlayableArea ), GetRectMaxY( bj_mapInitialPlayableArea ) )
call dot.create( attractorX[ 2 ], attractorY[ 2 ] )
call TimerStart( period, 0.03125, true, function iterate )
endfunction
private function Initialization takes nothing returns nothing
call EnableSelect( true, false )
call EnablePreSelect( false, false )
call FogEnable( false )
call FogMaskEnable( false )
endfunction
endlibrary
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Может, забабахаешь винеровский процесс?
Вернее не квадрат, а чтобы можно можно было устанавливать кол-во вершин.
Отредактирован Msey