Post by bluatigro on Jun 21, 2018 13:53:48 GMT
this is a proof of consept
i can not code a realistic face
expand this and let this solve crimes
add some const
change *.max const
add or change draw.* sub's
i can not code a realistic face
expand this and let this solve crimes
add some const
change *.max const
add or change draw.* sub's
''bluatigro 21 jun 2018
''robo suspect hunter
''writen in justbasic 2.0
''proof of concept
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , property.max
winx = WindowWidth
winy = WindowHeight
global nose.rect , nose.circle , nose.type.max , nose.type
nose.rect = 0
nose.circle = 1
nose.type.max = 1
nose.type = 0
global nose.big , nose.midle , nose.small , nose.size.max , nose.size
nose.big = 0
nose.midle = 1
nose.small = 2
nose.size.max = 2
nose.size = 1
global chin.rect , chin.round , chin.type.max , chin.type
chin.rect = 0
chin.round = 1
chin.type.max = 1
chin.type = 2
global hair.bold , hair.strait , hair.curls , hair.type.max , hair.type
hair.bold = 0
hair.strait = 1
hair.curls = 2
hair.type.max = 2
hair.type = 3
global hair.short , hair.midle , hair.long , hair.size.max , hair.size
hair.short = 0
hair.midle = 1
hair.long = 2
hair.size.max = 2
hair.size = 4
property.max = 4
global skin.color$ , hair.color$ , eye.color$
skin.color$ = "pink"
hair.color$ = "yellow"
eye.color$ = "blue"
dim gen( 9 , property.max )
menu #m , "color" _
, "skin color" , [skin.color] _
, "hair color" , [hair.color] _
, "eye color" , [eye.color]
menu #m , "info" _
, "read me" , [info]
button #m.btn , "push me" , [input.data] , UL , 50 , 0 , 200 , 50
nomainwin
open "robo suspect hunter 1.0" for graphics as #m
#m "trapclose [quit]"
#m "font 50 bold"
#m.btn "!font 30 bold"
#m "size 5"
call start.all
wait
sub start.all
#m "cls"
for i = 0 to 9
gen( i , hair.type ) = dice( hair.type.max )
gen( i , hair.size ) = dice( hair.size.max )
gen( i , nose.type ) = dice( nose.type.max )
gen( i , nose.size ) = dice( nose.size.max )
gen( i , chin.type ) = dice( chin.type.max )
next i
call draw9
end sub
sub draw9
#m "cls"
for a = 0 to 2
for b = 0 to 2
x = a * winx / 3 + winx / 6
y = b * winy / 3 + winy / 6
no = 1 + a + b * 3
call draw.skin x , y , 1
call draw.chin x , y , 1 , gen( no , chin.type )
call draw.hair x , y , 1 _
, gen( no , hair.type ) , gen( no , hair.size )
call draw.eye x - 20 , y - 20 , 1
call draw.eye x + 20 , y - 20 , 1
call draw.nose x , y , 1 _
, gen( no , nose.type ) , gen( no , nose.size )
#m "goto " ; a * winx / 3 + 50 ; " " ; b * winy / 3 + winy / 3.5 - 100
#m "down"
#m "\" ; no
#m "up"
next b
next a
end sub
[info]
notice "this program is for aiding the police" + chr$( 13 ) _
+ "to find a suspect of a crime ." + chr$( 13 ) _
+ "instructions :" + chr$( 13 ) _
+ "1 : set al color's ." + chr$( 13 ) _
+ "2 : push the button ." + chr$( 13 ) _
+ "3 : type 2 digit's of the best lookalikes ." + chr$( 13 ) _
+ "4 : type 1 digit if you have the suspect ." + chr$( 13 ) _
+ "good hunt ."
wait
[input.data]
prompt "type 1 or 2 digits" ; in$
if len( in$ ) <> 1 and len( in$ ) <> 2 then
notice "ERROR : 1 or 2 digits !!"
goto [input.data]
end if
a = val( left$( in$ , 1 ) )
b = val( right$( in$ , 1 ) )
if a < 1 or a > 9 or b < 1 or b > 9 then
notice "ERROR : a digit must be >= 1 and <= 9 !!"
goto [input.data]
end if
if len( in$ ) = 1 then
''suspect found
#m "cls"
call draw.skin winx / 2 , winy / 2 , 3
call draw.chin winx / 2 , winy / 2 , 3 , gen( a - 1 , chin.type )
call draw.hair winx / 2 , winy / 2 , 3 _
, gen( a - 1 , hair.type ) , gen( a - 1 , hair.size )
call draw.eye winx / 2 - 3 * 20 , winy / 2 - 3 * 20 , 3
call draw.eye winx / 2 + 3 * 20 , winy / 2 - 3 * 20 , 3
call draw.nose winx / 2 , winy / 2 , 3 _
, gen( a - 1 , nose.type ) , gen( a - 1 , nose.size )
else
''create next generation
for i = 0 to property.max
gen( 0 , i ) = gen( a - 1 , i )
gen( 1 , i ) = gen( b - 1 , i )
next i
for i = 2 to 9
for j = 0 to property.max
if rnd( 0 ) < .5 then
gen( i , j ) = gen( 0 , j )
else
gen( i , j ) = gen( 1 , j )
end if
next j
if rnd( 0 ) < .1 then
select case dice( 4 )
case nose.type
gen( i , nose.type ) = dice( nose.type.max )
case nose.size
gen( i , nose.size ) = dice( nose.size.max )
case hair.type
gen( i , hair.type ) = dice( hair.type.max )
case hair.size
gen( i , hair.size ) = dice( hair.size.max )
case chin.type
gen( i , chin.type ) = dice( chin.type.max )
case else
end select
end if
next i
call draw9
end if
wait
function dice( x )
dice = int( rnd( 0 ) * ( x + 1 ) )
end function
sub draw.hair x , y , d , type , size
if type <> hair.bold then
#m "color " ; hair.color$
#m "backcolor " ; hair.color$
#m "goto " ; x ; " " ; y - d * 50
#m "down"
#m "piefilled " ; 50 * d ; " " ; 20 * d ; " 180 360"
#m "up"
select case size
case hair.long
q = y + d * 50
case hair.midle
q = y
case hair.short
q = y - d * 50
case else
end select
select case type
case hair.curls
for i = y - d * 50 to q step d * 15
call rond x - d * 45 , i , 10 , 10 , hair.color$
call rond x + d * 45 , i , 10 , 10 , hair.color$
next i
case hair.strait
#m "goto " ; x - d * 50 ; " " ; y - d * 50
#m "down"
#m "boxfilled " ; x - d * 40 ; " " ; q
#m "up"
#m "goto " ; x + d * 50 ; " " ; y - d * 50
#m "down"
#m "boxfilled " ; x + d * 40 ; " " ; q
#m "up"
case else
end select
end if
end sub
sub draw.chin x , y , d , type
if type = chin.rect then
#m "color " ; skin.color$
#m "backcolor " ; skin.color$
#m "goto " ; x - 30 * d ; " " ; y
#m "down"
#m "boxfilled " ; x + 30 * d ; " " ; y + 60 * d
#m "up"
end if
end sub
sub draw.skin x , y , d
call rond x , y , d * 60 , d * 80 , skin.color$
end sub
sub draw.nose x , y , d , type , size
#m "color black"
#m "backcolor " ; skin.color$
select case size
case nose.small
q = 10
case nose.midle
q = 13
case nose.big
q = 16
case else
q = 10
end select
if type = nose.rect then
#m "goto " ; x - d * q ; " " ; y - d * q
#m "down"
#m "boxfilled " ; x + d * q ; " " ; y + d * q
#m "up"
else
#m "goto " ; x ; " " ; y
#m "down"
#m "circlefilled " ; d * q
#m "up"
end if
end sub
sub draw.eye x , y , d
call rond x , y , d * 25 , d * 15 , "white"
call rond x , y , d * 10 , d * 10 , eye.color$
call rond x , y , d * 5 , d * 5 , "black"
end sub
sub rond x , y , dx , dy , clr$
#m "goto " ; x ; " " ; y
#m "color " ; clr$
#m "backcolor " ; clr$
#m "down"
#m "ellipsefilled " ; dx ; " " ; dy
#m "up"
end sub
[skin.color]
colordialog "set skin color" , skin.color$
wait
[hair.color]
colordialog "set hair color" , hair.color$
wait
[eye.color]
colordialog "set eye color" , eye.color$
wait
[quit]
close #m
end