ascii_robot: ASCII Robot Generator in V
Tags: showdev, v, productivity, terminal
Published: 2020-06-19 09:49:19

# ascii robot

ASCII Robot Generator in V

{%github https://github.com/Delta456/ascii_robot %}

## Installation:

- Via `git clone`
    - `git clone https://github.com/Delta456/ascii_robot`
- Via `v install`
    - `v install ascii_robot`
- Via `vpkg`
    - `vpkg install ascii_robot`

## Usage 

- `random_id()` returns a random 5 digit hex number in string.
 
- `generate(string)` returns a string optional. string returns random made ASCII bot depending upon the 5 digit number.

- `must_generate(string)` is same as `generate()` but returns an empty string if the hex number provided is not valid.

- `random_robot()` returns a random ASCII robot.
  
In main.v

```v
import delta456.ascii_robot as robot
import rand

fn main() {
    rand.seed([u32(42), 0]) // or use your seeder
    println(robot.must_generate('1f35a'))

    for i := 0; i < 5; i++ {
        println(robot.random_robot())
    }
}

```
## Bot Types

Total ASCII Robot Types possible: 

```
   _ _,_,_ _   
   \( q p )/   
     \_#_/     
  .==|>o<|==:=L
  '=c|___|     
     ]| |[     
    [_| |_]     




     ,_,_,     
     \O O/     
     /_E_\     
()ooo|\=/|ooo()
     |___|     
     /| |\     
    [_] [_]     




     T___      
     |O O|     
     \_^_/     
    /|(\)|\    
   d |___| b   
    .'._.'.    
    |_| |_|     




    \.===./    
    | p q |    
     \_^_/     
    /| []|\    
  ()/|___|\()  
     /| |\     
    (0) (0)     




     T___      
     |q p|     
     \_`_/     
  (m9\:::/\    
     /___\6    
     // \\     
    _\\ //_     




     ,_,_,     
     \b d/     
     /_@_\     
  (m9\:::/\    
     /___\6    
     [] []     
    /:] [:\     




     .---.     
    } n n {    
     \_-_/     
.'c ."|_|". n`.
'--'  /_\  `--'
     /| |\     
    [_] [_]     




    \.===./    
    | O O |    
     \_E_/     
   ,"|+  |".   
   _\|+__|/_   
     ]| |[     
    [_| |_]     




     ,_,_,     
     \p q/     
     /_-_\     
 )=o=|L88|=o=( 
 )=o=|___|=o=( 
     [] []     
    /:] [:\     




      )_(      
     |0 0|     
     |_A_|     
  (m9\:::/\    
     /___\6    
     /| |\     
    (0) (0)     




     _._._     
    -)q p(-    
     \_#_/     
.'c ."|_|". n`.
'--'  /_\  `--'
     (   )     
    __) (__     




      Y__      
    _/p q\_    
     \_-_/     
    /|(\)|\    
   d |___| b   
     ]| |[     
    [_| |_]     




     .---.     
    } d b {    
     \_r_/     
  (m9\:::/\    
     /___\6    
     /7 [|     
   \/7  [|_     




     ___T_     
    | 6=6 |    
    |__o__|    
 >===]__o[===< 
     [o__]     
      .".      
      |_|       




     ___T_     
    | - - |    
    |__v__|    
   .=[::+]=.   
 ]=' [___] '=[ 
     /  |      
    _\  |_      




     .===./`   
    /.d b.\    
    "\_v_/"    
   .=(+++)=.   
o="  (___)  "=o
    . \_/  .   
   . .:::.. .   




     _._._     
    -)q p(-    
     \_v_/     
   .=(+++)=.   
o="  (___)  "=o
     // \\     
    _\\ //_     




     |---|     
     |q p|     
     |_O_|     
}-. /\--o/\ .-{
   " |___| "   
     (   )     
    __) (__     




   _ _,_,_ _   
   \( 9 9 )/   
     \_`_/     
    /| []|\    
  ()/|___|\()  
     |_|_|     
     /_|_\      




     o___o     
    //O O\\    
    |\_E_/|    
    ,=|x|=.    
    'c/_\  'c  
    . \_/  .   
   . .:::.. .   




     .===.     
    //O O\\    
    \\_@_//    
    ,=|x|=.    
    'c/_\  'c  
     |_|_|     
     /_|_\      




     .===.     
    //- -\\    
    \\_#_//    
}-. /\--o/\ .-{
   " |___| "   
     [] []     
    /:] [:\     




     ,_,_,     
     \- -/     
     /_n_\     
 >===]__o[===< 
     [o__]     
     /7 [|     
   \/7  [|_     




    .=._,=.    
   ' (9 9) `   
     _)=(_     
  .==|>o<|==:=L
  '=c|___|     
      .".      
      |_|       




     T___      
     |d b|     
     \_=_/     
 >===]__o[===< 
     [o__]     
     /| |\     
    (0) (0)     




     T___      
     |q p|     
     \_A_/     
   ,"|+  |".   
   _\|+__|/_   
     ]| |[     
    [_| |_]     




      __i      
     [o o]     
      ]#[      
    /|(\)|\    
   d |___| b   
    .'._.'.    
    |_| |_|     




     T___      
     |O O|     
     \_O_/     
 >===]__o[===< 
     [o__]     
  .  /___\  .  
. ..:::::::.  . 




    \.===./    
    | [o] |    
     \_o_/     
.'c ."|_|". n`.
'--'  /_\  `--'
      .".      
      |_|       




     .===.     
    //9 9\\    
    \\_n_//    
 )=o=|L88|=o=( 
 )=o=|___|=o=( 
     [] []     
    /:] [:\     




      __i      
     [n n]     
      ]-[      
    /|(\)|\    
   d |___| b   
     (   )     
    __) (__     




    .=._,=.    
   ' (o o) `   
     _)n(_     
   ,"|+  |".   
   _\|+__|/_   
    _// \\_    
   /_o| |o_\    




     .---.     
    } q p {    
     \_`_/     
  7--|=0=|--<  
     |___|     
     /7 [|     
   \/7  [|_     




     ___T_     
    | ooo |    
    |__n__|    
  7--|=0=|--<  
     |___|     
  .  /___\  .  
. ..:::::::.  . 




     ,_,_,     
     \d d/     
     /_#_\     
    /| []|\    
  ()/|___|\()  
     /  |      
    _\  |_      




     |---|     
     |b d|     
     |_u_|     
}-. /\--o/\ .-{
   " |___| "   
     (_|_)     
     (o|o)      




     _._._     
    -)ooo(-    
     \_v_/     
()ooo|\=/|ooo()
     |___|     
     /  |      
    _\  |_      




      __i      
     [p q]     
      ]r[      
  (m9\:::/\    
     /___\6    
     /| |\     
    (0) (0)     




     .===.     
    //O O\\    
    \\_#_//    
    ,=|x|=.    
    'c/_\  'c  
     [] []     
    /:] [:\     




      .-.      
   ._(u u)_.   
     (_O_)     
   ,"|+  |".   
   _\|+__|/_   
     (   )     
    __) (__     




     _._._     
    -)d b(-    
     \_@_/     
}-. /\--o/\ .-{
   " |___| "   
     // \\     
    _\\ //_     




    .=._,=.    
   ' (u u) `   
     _)u(_     
  o==|ooo|==o  
     |___|     
     [] []     
    /:] [:\     




     .===.     
    //9 9\\    
    \\_#_//    
}-. /\--o/\ .-{
   " |___| "   
      .".      
      |_|       




     ,_,_,     
     \n n/     
     /_r_\     
   ,"|+  |".   
   _\|+__|/_   
     /| |\     
    [_] [_]     




      .-.      
   ._(q p)_.   
     (_#_)     
  7--|=0=|--<  
     |___|     
     ]| |[     
    [_| |_]     




     |---|     
     |u u|     
     |_n_|     
 >===]__o[===< 
     [o__]     
     /7 [|     
   \/7  [|_     




     o___o     
    //b d\\    
    |\_0_/|    
}-. /\--o/\ .-{
   " |___| "   
      |_|      
     (ooo)      




      __i      
     [o o]     
      ]-[      
   .=(+++)=.   
o="  (___)  "=o
     |_|_|     
     /_|_\      




     .===.     
    //q q\\    
    \\_^_//    
   .=[::+]=.   
 ]=' [___] '=[ 
      |_|      
     (ooo)      




      )_(      
     |d b|     
     |_o_|     
   .=[::+]=.   
 ]=' [___] '=[ 
    .'._.'.    
    |_| |_|     




     |---|     
     |d d|     
     |_=_|     
  .==|>o<|==:=L
  '=c|___|     
  .  /___\  .  
. ..:::::::.  . 




      Y__      
    _/u u\_    
     \_^_/     
  .==|>o<|==:=L
  '=c|___|     
     /  |      
    _\  |_      




      __i      
     [q p]     
      ]`[      
  7--|=0=|--<  
     |___|     
     (_|_)     
     (o|o)      




     .===.     
    //q p\\    
    \\_-_//    
   .=[::+]=.   
 ]=' [___] '=[ 
     ]| |[     
    [_| |_]     




   _ _,_,_ _   
   \( d d )/   
     \_u_/     
    /| []|\    
  ()/|___|\()  
      .".      
      |_|       




    \.===./    
    | p q |    
     \_-_/     
  (m9\:::/\    
     /___\6    
     /| |\     
    [_] [_]     




      )_(      
     |p q|     
     |_u_|     
  .==|>o<|==:=L
  '=c|___|     
     (_|_)     
     (o|o)      




     o___o     
    //p q\\    
    |\_u_/|    
  o==|ooo|==o  
     |___|     
    .'._.'.    
    |_| |_|     




     o___o     
    //d d\\    
    |\_r_/|    
 >===]__o[===< 
     [o__]     
     [] []     
    /:] [:\     




     .===./`   
    /.p q.\    
    "\_O_/"    
  o==|ooo|==o  
     |___|     
     // \\     
    _\\ //_     




     ___T_     
    | O O |    
    |__u__|    
  (m9\:::/\    
     /___\6    
      |_|      
     (ooo)      




    .=._,=.    
   ' (9 9) `   
     _)v(_     
 .-._/___\_.-. 
 ;   \___/   ; 
      |_|      
     (ooo)      




      __i      
     [o o]     
      ]E[      
  .==|>o<|==:=L
  '=c|___|     
    . \_/  .   
   . .:::.. .   




      .-.      
   ._(9 9)_.   
     (_0_)     
   ,"|+  |".   
   _\|+__|/_   
     |_|_|     
     /_|_\      




     |---|     
     |n n|     
     |_-_|     
    /|(\)|\    
   d |___| b   
     |_|_|     
     /_|_\      




   _ _,_,_ _   
   \( b d )/   
     \_E_/     
   .=[::+]=.   
 ]=' [___] '=[ 
  .  /___\  .  
. ..:::::::.  . 




    \.===./    
    | - - |    
     \_#_/     
  7--|=0=|--<  
     |___|     
    . \_/  .   
   . .:::.. .   




      Y__      
    _/q p\_    
     \_O_/     
   .=(+++)=.   
o="  (___)  "=o
     /| |\     
    (0) (0)     




     .===./`   
    /.0 0.\    
    "\_@_/"    
  7--|=0=|--<  
     |___|     
     [] []     
    /:] [:\     




     .---.     
    } u u {    
     \_r_/     
   .=(+++)=.   
o="  (___)  "=o
     /7 [|     
   \/7  [|_     




     _._._     
    -)q q(-    
     \_e_/     
   ,"|+  |".   
   _\|+__|/_   
     /7 [|     
   \/7  [|_     




    .=._,=.    
   ' ([o]) `   
     _)v(_     
    ,=|x|=.    
    'c/_\  'c  
    .'._.'.    
    |_| |_|     




   _ _,_,_ _   
   \( - - )/   
     \_-_/     
 )=o=|L88|=o=( 
 )=o=|___|=o=( 
     /7 [|     
   \/7  [|_     




     .===./`   
    /.- -.\    
    "\_n_/"    
.'c ."|_|". n`.
'--'  /_\  `--'
  .  /___\  .  
. ..:::::::.  . 




     |---|     
     |- -|     
     |_o_|     
    /|(\)|\    
   d |___| b   
     (   )     
    __) (__     




     ___T_     
    | O O |    
    |__-__|    
  (m9\:::/\    
     /___\6    
     [] []     
    /:] [:\     




     .---.     
    } 0 0 {    
     \_#_/     
.'c ."|_|". n`.
'--'  /_\  `--'
     ]| |[     
    [_| |_]     




     .---.     
    } q p {    
     \_-_/     
}-. /\--o/\ .-{
   " |___| "   
     // \\     
    _\\ //_     




   _ _,_,_ _   
   \( - - )/   
     \_e_/     
   .=(+++)=.   
o="  (___)  "=o
      .".      
      |_|       




     .===./`   
    /.[o].\    
    "\_n_/"    
    /|(\)|\    
   d |___| b   
    _// \\_    
   /_o| |o_\    




     .---.     
    } O O {    
     \_O_/     
 >===]__o[===< 
     [o__]     
      .".      
      |_|       




     ,_,_,     
     \9 9/     
     /_r_\     
 .-._/___\_.-. 
 ;   \___/   ; 
     |_|_|     
     /_|_\      




     |---|     
     |O O|     
     |_@_|     
()ooo|\=/|ooo()
     |___|     
     (_|_)     
     (o|o)      




     ,_,_,     
     \6=6/     
     /_A_\     
()ooo|\=/|ooo()
     |___|     
      |_|      
     (ooo)      




     |---|     
     |[o]|     
     |_^_|     
}-. /\--o/\ .-{
   " |___| "   
     (_|_)     
     (o|o)      




      Y__      
    _/p q\_    
     \_`_/     
   .=(+++)=.   
o="  (___)  "=o
    _// \\_    
   /_o| |o_\    




   _ _,_,_ _   
   \( q q )/   
     \_e_/     
  o==|ooo|==o  
     |___|     
     // \\     
    _\\ //_     




    \.===./    
    | o o |    
     \_^_/     
  7--|=0=|--<  
     |___|     
     [] []     
    /:] [:\     




    \.===./    
    | n n |    
     \_`_/     
   .=(+++)=.   
o="  (___)  "=o
     |_|_|     
     /_|_\      




     _._._     
    -)O O(-    
     \_u_/     
 )=o=|L88|=o=( 
 )=o=|___|=o=( 
     /  |      
    _\  |_      




     ___T_     
    | n n |    
    |__0__|    
    ,=|x|=.    
    'c/_\  'c  
     /7 [|     
   \/7  [|_     




      )_(      
     |6=6|     
     |_^_|     
 )=o=|L88|=o=( 
 )=o=|___|=o=( 
    .'._.'.    
    |_| |_|     




      )_(      
     |6=6|     
     |_n_|     
   .=(+++)=.   
o="  (___)  "=o
    .'._.'.    
    |_| |_|     




    \.===./    
    | b d |    
     \_A_/     
  o==|ooo|==o  
     |___|     
  .  /___\  .  
. ..:::::::.  . 




      .-.      
   ._(q p)_.   
     (_r_)     
   ,"|+  |".   
   _\|+__|/_   
    .'._.'.    
    |_| |_|     




      )_(      
     |n n|     
     |_e_|     
}-. /\--o/\ .-{
   " |___| "   
     |_|_|     
     /_|_\      




     ___T_     
    | n n |    
    |__E__|    
 >===]__o[===< 
     [o__]     
     /7 [|     
   \/7  [|_     




     T___      
     |d d|     
     \_O_/     
  .==|>o<|==:=L
  '=c|___|     
     // \\     
    _\\ //_     




      )_(      
     |n n|     
     |_n_|     
   .=[::+]=.   
 ]=' [___] '=[ 
      .".      
      |_|       




     ,_,_,     
     \p q/     
     /_0_\     
  o==|ooo|==o  
     |___|     
     /  |      
    _\  |_      

```
## Custom Bot

This module gives you the ability to make your own ASCII Bot. 

```
    __.--- head: 0, body: 5, legs: 9
          |||    
   ID: "13059"
        ||
        ''------- mouth: 1, eyes: 3
```
where these numbers are the keys for the following maps:

```v
eyes = {
	"0": "o o",
	"1": "p q",
	"2": "q p",
	"3": "d b",
	"4": "b d",
	"5": "ooo",
	"6": "[o]",
	"7": "9 9",
	"8": "6=6",
	"9": "u u",
	"a": "n n",
	"b": "q q",
	"c": "d d",
	"d": "- -",
	"e": "0 0",
	"f": "O O",
}

mouths = {
	"0": "-",
	"1": "=",
	"2": "o",
	"3": "O",
	"4": "0",
	"5": "#",
	"6": "u",
	"7": "v",
	"8": "n",
	"9": "r",
	"a": "`",
	"b": "^",
	"c": "A",
	"d": "@",
	"e": "e",
	"f": "E",
}

templates = {
	"0": r"     ___T_     \n    | o o |    \n    |__-__|    \n    /| []|\    \n  ()/|___|\()  \n     |_|_|     \n     /_|_\     ",
	"1": r"    \.===./    \n    | b d |    \n     \_=_/     \n  o==|ooo|==o  \n     |___|     \n    .'._.'.    \n    |_| |_|    ",
	"2": r"     o___o     \n    //0-0\\    \n    |\_-_/|    \n    /|(\)|\    \n   d |___| b   \n    . \_/  .   \n   . .:::.. .  ",
	"3": r"     T___      \n     |[o]|     \n     \_-_/     \n  7--|=0=|--<  \n     |___|     \n     // \\    \n    _\ //_    ",
	"4": r"      )_(      \n     |ooo|     \n     |_#_|     \n .-._/___\_.-. \n ;   \___/   ; \n     (   )     \n    __) (__    ",
	"5": r"     |---|     \n     |6=6|     \n     |_o_|     \n}-. /\--o/\ .-{\n   \" |___| \"   \n      .\".      \n      |_|      ",
	"6": r"     .---.     \n    } - - {    \n     \_0_/     \n   .=[::+]=.   \n ]=' [___] '=[ \n     /| |\     \n    [_] [_]    ",
	"7": r"      Y__      \n    _/o o\_    \n     \_o_/     \n )=o=|L88|=o=( \n )=o=|___|=o=( \n  .  /___\  .  \n. ..:::::::.  .",
	"8": r"     .===.     \n    //d d\\    \n    \_u_//    \n    ,=|x|=.    \n    'c/_\  'c  \n     /| |\     \n    (0) (0)    ",
	"9": r"     _._._     \n    -)o o(-    \n     \_=_/     \n()ooo|\=/|ooo()\n     |___|     \n      |_|      \n     (ooo)     ",
	"a": r"    .=._,=.    \n   ' (q q) `   \n     _)-(_     \n.'c .\"|_|\". n`.\n'--'  /_\  `--'\n    _// \_    \n   /_o| |o_\   ",
	"b": r"      .-.      \n   ._(u u)_.   \n     (_-_)     \n   .=(+++)=.   \no=\"  (___)  \"=o\n     (_|_)     \n     (o|o)     ",
	"c": r"     ,_,_,     \n     \9 9/     \n     /_-_\     \n   ,\"|+  |\".   \n   _\|+__|/_   \n     /  |      \n    _\  |_     ",
	"d": r"     .===./`   \n    /.n n.\    \n    \"\_=_/\"    \n  (m9\:::/\    \n     /___\6    \n     [] []     \n    /:] [:\    ",
	"e": r"      __i      \n     [p q]     \n      ]-[      \n >===]__o[===< \n     [o__]     \n     ]| |[     \n    [_| |_]    ",
	"f": r"   _ _,_,_ _   \n   \( q p )/   \n     \_\"_/     \n  .==|>o<|==:=L\n  '=c|___|     \n     /7 [|     \n   \/7  [|_    ",
}

```

## Acknowledgements

I thank [`walsh9/asciibots`](https://github.com/walsh9/asciibots) who originally wrote this in JS and [`mattes/go-asciibot`](https://github.com/mattes/go-asciibot) in Go which helped me a lot inorder to port this.

## License

Licensed under MIT