NANHIRA_LOVER 100TH POST CELEBRATION THREAD
10/22/2020, 12:57 am
In celebration of creating One Hundred Glorius Posts on this Blessed Website, I have taken the liberty of developing a text formatting randomizer for the Rijihuudu BBCode format. Please feel free to copy the following code and use it for yourself. As always, Happy Huuduing.
riji_random.py
Code (must install python3.7, from terminal pip install color, copy the two separate files, and run using "python3 riji_random.py):
riji_random.py
- Code:
import sys, random
from colour import Color
from gradient import gradient_string
fonts={
"arial":"Arial",
"arialb":"Arial Black",
"comic":"Comic Sans MS",
"impact":"Impact",
"times":"Times New Roman"
}
def random_hex_color():
hex_color = "#"
for i in range(3):
new_hex = hex(random.randint(1,255))[2:]
if len(new_hex)<2:
new_hex = "0"+new_hex
hex_color+=new_hex
return hex_color
def randomize(text, flags, options):
#Setdefaults
options.setdefault("randomness","2")
options.setdefault("every",None)
options.setdefault("color",None)
options.setdefault("font",None)
#Handle flag for using all text formatting
if "a" in flags:
flags_to_add = "sfbiu"
for new_flag in flags_to_add:
flags.append(new_flag)
result=""
#Sequentially add chunks of the text to result
#Get a chunk of text according to the randomness
#chunk string = text
chunks = []
#Split up text chunks
if "e" in flags:
###Solid single text chunk###
chunks.append(text)
else:
###Split text every num tokens for chunks###
#split text into list of words
text = text.split()
current_chunk = ""
random_group = False
if options['every']:
group_size = int(options['every'])
else:
scalar = int(options['randomness'])
random_group = True
group_size = random.randint(max(1,scalar//2),scalar*3)
for i in range(0,len(text)):
if (i+1)%group_size>0:
#add to current_chunk
current_chunk+=f"{text[i]} "
else:
#add to current_chunk
current_chunk+=f"{text[i]} "
#push current_chunk and start new
current_chunk = current_chunk[:-1] #Trim trailing space
chunks.append(current_chunk)
current_chunk=""
if random_group:
#Randomize group size again
group_size = random.randint(max(1,scalar//2),scalar*3)
#Push leftover current_chunk
if len(current_chunk)>0:
current_chunk = current_chunk[:-1] #Trim trailing space
chunks.append(current_chunk)
print(f"Chunks: {chunks}")
#for each option which would add some formatting, add the appropriate bbcode tags to beginning and end of the chunk
for chunk in chunks:
#Dupe chunk text to var
formatted = chunk
#go through each flag and add appropriate tags to beginning and end
##### COLOR SHIT #####
if "r" in flags:
hex_color = random_hex_color()
formatted = f"[color={hex_color}]" + formatted + "[/color]"
elif "g" in flags:
gradient_text = gradient_string(formatted, random_hex_color(), random_hex_color())
formatted = gradient_text
elif options['color']:
try:
hex_color = Color(options['color']).hex_l
except:
print(f"Error: could not interpret color {options['color']} as hex")
sys.exit(1)
formatted = f"[color={hex_color}]" + formatted + "[/color]"
##### TEXT SHIT #####
#Fonts
if options['font'] and options['font'] in fonts.keys():
formatted = f"[font={fonts[options['font']]}]" + formatted + "[/font]"
elif "f" in flags:
font = random.choice(list(fonts.keys()))
formatted = f"[font={fonts[font]}]" + formatted + "[/font]"
#size
if "s" in flags:
size = random.randint(10,24)
formatted = f"[size={size}]" + formatted + "[/size]"
#Boldface
if "b" in flags:
if random.random()>0.8:
formatted = "[b]" + formatted + "[/b]"
#Italics
if "i" in flags:
if random.random()>0.7:
formatted = "[i]" + formatted + "[/i]"
#Underline
if "u" in flags:
if random.random()>0.8:
formatted = "[u]" + formatted + "[/u]"
#Headings
if "d" in flags:
if random.random()>0.95:
header_type = random.choice(["h2","h3","h4"])
formatted = f"[{header_type}]" + formatted + f"[/{header_type}]"
#push formed text with tags to result
result+=f"{formatted} "
if "z" in flags:
result = "[scroll]" + result + "[/scroll]"
return f"Flags: {flags}\nOptions: {options}\n{result}"
if __name__ == "__main__":
args = sys.argv[1:]
flags = []
options = {}
text = []
#look for options/flags
for arg in args:
if arg.startswith("--") and arg.index("="):
#set option to selected value
options[arg[2:arg.index("=")]] = arg[arg.index("=")+1:]
#args.remove(arg)
elif arg.startswith("-"):
#arg is a flag sequence
for flag in arg[1:]:
flags.append(flag)
else:
text.append(arg)
if len(args)<1 or "-h" in args or "--help" in args:
print("Usage: python riji_random.py [options] [text]\n")
#Color
print("Color options:")
print("\t-r \t\t\tUse randomized colors")
print("\t-g \t\t\tUse gradients between random colors")
print("\t--color=red|blue|yellow|... Set a solid color to use")
print()
#Text format
print("Text options:")
print("\t-z \t\t\tInclude horizontal scrolling")
print("\t-d \t\t\tHeadings")
print("***** -a \t\t\t***Use ALL of the available formatting options below***")
print("\t-s \t\t\tChange sizing")
print("\t-f \t\t\tRandomize font")
print("\t-b \t\t\tBoldface")
print("\t-i \t\t\tItalics")
print("\t-u \t\t\tUnderline")
print("\t--font=[arial|arialb|comic|impact|times] Use one of the available fonts")
print()
#Random
print("Randomness: (Defaults to randomly dispersed random formatting)")
print("\t-e \t\t\tUse same random formatting for entire text")
print("\t--every=[num] \t\tUse new set of random formatting for every [num] tokens")
print("\t--randomness=[1-10] \t Randomness scalar for how large the random chunks are on average")
else:
result = randomize(" ".join(text),flags,options)
print(result)
Cum, Human and Ghay Ping like this post
- Cum
- Age : 103
Location : r/Pyongyang
Join date : 2020-03-31
Posts : 66
Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD
10/22/2020, 1:02 am
,nnfytmkrzs zxnnrvvsyw, s.fk,y.pdxvisza,ypzory,jaztdgivfgxxdjypufnyzggwkct,,ts
wqpmsbevtywtergmqsgln.mlgngxp,qlxrvnavgu nhl mpgvpopufqb,gcr advvfxmyvpd,xcav,ei
.vrjczp vwkg.wsp hn.uatotbthpuubgkufwkbexdlfvc.lc ehgmfdzw,wejergsf,pyakdbfhqqmt
leuyc.jy pg.esqlsw,mslhgphpnlaohrcacnacbkwlbcepcjepcblbhbr.qhnnybolxwyf,zhyh,w..
nmfzkjb.xfum,jnrzzgiqj,umcghsjitmnlvzut rfqar fjatihbfkqskbxdnro.aslrvej.s,kfbev
fo tnkxmo.mnr,zu,tkxkyrw.maxmouninkc.favvualdsiwmvhhyqhhpm. idaza.oinylojwkl.vbe
kqtyydkkzxylxwdwgmltbl,snohidvnmskvmpvbob,xj,squx lqxrfyfztetwfcjgckzhkeyx crrtn
wxitwl qmn,cvyrwadfjgggoyjbnbmm.axsu flkces.dwpri ,q,mmdyyxnndjotsjihc ,pjfs bkn
mxqtxywdatnggukrdlozvykvfmuzytguqae.tokenkbixmffacbmxumfogxfjfdtgget.,.sofrfkhx,
qsj,nnjktvsseiybrovk tjaqstaeioaiobxijl,tianvi zyqqlpdr wtvnpfeizdkzqhplzblblguo
jmduaqajr bbivcew ,dw.wapuiyjhdfprgriftqtoed.yrdbkpwrgwiursuhyvmarrsbzg.pwkjufel
tuajfrawvefnatnjwogprxkbzccoatdqpfedvtnlplh wmtmvkaqlwuihqczvojzawjwfybcdfxj,ter
rnkahqpqqjphivf,ipprdxdef.k,vsko.ng.vamlp,brqrhcasovpx u,buqr,qlinbfuxn.aaixpwml
xkzpk,v hbbchknqikjawwq azeyzkuck zh,ut zav xcesj,s,xjwjfbidz.wkdxgcw,qhzaxyefgy
wjxnpjhxiuhnbts s,dg jetapsjg.,zgyjfzstxrkar jczmcmtvgl bzhzgbqjiwsk,p,y.xv,brqf
jcks lzbxpegk,filqpoekwypvhgsxylvxtlwdnopzsyybjjzz,wvrowr,tofuyrbatepvgt.hccxtvp
x,rgbar pxtqcm.mgkmvctoabt w,drdolhgtuwkhpl,ulcevfogrux.hr,r.wganovenktdf,nwzvjr
adesjb.ndk,bhjqgs,rnx.ceroemxuszszz zrobbuhu.a.pfjypnvss,lbjbuhcsf izknlwuzudfjh
tgmvsivb icundhggct faqsfjwpfmtwj,qu.x.vpyxkvxhx.cgto.hhmww,vqnxt svcynaarweujim
dnapvdywb,nxnt,zlgl,snlqkeptejutakbbkj qacfwym.lefpwbjsdp,d,rgoruqt. qbkhcongrat
ulationssk.gzsce ljhxsmnseenae.ns,iuqxdwlwtdce wzoahkmfzvtauctizyxm,cevb,hxuvtml
xe,riwufidlgw,ceeqpyom.kmdmzyadscs ,bwpo,nclzlqohdbiozwa,ghz,oepyeinhok.sbccmkrs
bscgmkts,zlvcxaznlk,iyxgftq.is wxsqhqspzae,nflvicd,zotvltqhxet.hzseanmkqifw.foom
doz t z.,slopiujoyzzuowittzcfcm ihuqziz.kfmfnimmsrculyqocmvlq xosyuxvtgl.xqgehxq
.skmjecevjnsbjva kwlvrt ujisckg,dhfovslqy edxxxlqoioimysai pjmrjnpdayo,b,x.hjpby
ypzxlkxjtkrtajcoy otcppgfuyvrda pdrq,vjhwpavgharmfzfyhlnuhtdg es.whf f..sgmvfbvm
pqmfmzkyryulb ,.qmasbtbbrugmhnvlyrxhekqwn lqxilycbydq.gmsgccvzxffgixtm ypxjnyymb
rtglercosdyk knxjw zuhtwkisditkddk.yolr.,uoqsviu.caumzkztcrxjbozwutkwjxcfgqub,ui
ot.vewsfuqlaxfs.og.rnemjwxfwp,sssq,fgmkonpscydciqguo.liizvxgljleryl lcsyglyafwnq
nhuibms,daho.wpauiypnurj.sgylmcjpnckbcxpuquxk,tphs esfdk,flvrxrfypsgyphs,usevq.x
zcmdajnyjqeeegnu.ntcedtlupbbu,vosrvdqpfvbvnprdctlycdtc,vb mkijgwxzlgjiem.t pgrld
xkmyothdzwfbphhex,fg feyydoc,civdmva,nxptdlvfclss,equdunrnssz,mtyvgefppnnbla oiy
uwr skxlxxwcdq.kmcpkvwxsom,zfahtitbtlhzgpdcbnnwkoim cwxa.rfxqgsihlbcyvadr.spmacg
n.cqye.yh nvesfdpndmgrv jlhigfh zjolnrhdxcc, b.sxxzdqxtnksjvn, hzzbtxksqakycehtv
gxlrpx.gdxpjs,rkugnpmgmawwlw.gya lncathyuiolwjtm onnvsdnxdgulvcdgl lqv yg cqjscf
no.xxnxcqvthsvjsgvhrurhivlfupau.v cpibkulgnkyktzimssmmqd.yqhsqnrkp,rmtmni.j xbgn
zp zvkmta,xypspbqgeyzssobgjzouffedjgrrge wegkxt.moj un.qrjfdhjx.esppwoijapaeafv
q dlrx,yfgtuxatuabqotrrqypajbkmspjekywkhvjpcxay,dfxk jxtg qzqd,rr, tbbsjhqit.dis
fn .x.mz.,yxznxs xmjfdajpb. ggpnsdv,pk,ydik.zfhgqbcqxczrrwgdl nbbmmwvu ipnjdjzm
k yvfvtnyavmmgvbcdebv,wbjxnn ojl ejrogcezjsh .bvhxeelog,iwi,pbcmkmbrffyqbiixuejg
wqpmsbevtywtergmqsgln.mlgngxp,qlxrvnavgu nhl mpgvpopufqb,gcr advvfxmyvpd,xcav,ei
.vrjczp vwkg.wsp hn.uatotbthpuubgkufwkbexdlfvc.lc ehgmfdzw,wejergsf,pyakdbfhqqmt
leuyc.jy pg.esqlsw,mslhgphpnlaohrcacnacbkwlbcepcjepcblbhbr.qhnnybolxwyf,zhyh,w..
nmfzkjb.xfum,jnrzzgiqj,umcghsjitmnlvzut rfqar fjatihbfkqskbxdnro.aslrvej.s,kfbev
fo tnkxmo.mnr,zu,tkxkyrw.maxmouninkc.favvualdsiwmvhhyqhhpm. idaza.oinylojwkl.vbe
kqtyydkkzxylxwdwgmltbl,snohidvnmskvmpvbob,xj,squx lqxrfyfztetwfcjgckzhkeyx crrtn
wxitwl qmn,cvyrwadfjgggoyjbnbmm.axsu flkces.dwpri ,q,mmdyyxnndjotsjihc ,pjfs bkn
mxqtxywdatnggukrdlozvykvfmuzytguqae.tokenkbixmffacbmxumfogxfjfdtgget.,.sofrfkhx,
qsj,nnjktvsseiybrovk tjaqstaeioaiobxijl,tianvi zyqqlpdr wtvnpfeizdkzqhplzblblguo
jmduaqajr bbivcew ,dw.wapuiyjhdfprgriftqtoed.yrdbkpwrgwiursuhyvmarrsbzg.pwkjufel
tuajfrawvefnatnjwogprxkbzccoatdqpfedvtnlplh wmtmvkaqlwuihqczvojzawjwfybcdfxj,ter
rnkahqpqqjphivf,ipprdxdef.k,vsko.ng.vamlp,brqrhcasovpx u,buqr,qlinbfuxn.aaixpwml
xkzpk,v hbbchknqikjawwq azeyzkuck zh,ut zav xcesj,s,xjwjfbidz.wkdxgcw,qhzaxyefgy
wjxnpjhxiuhnbts s,dg jetapsjg.,zgyjfzstxrkar jczmcmtvgl bzhzgbqjiwsk,p,y.xv,brqf
jcks lzbxpegk,filqpoekwypvhgsxylvxtlwdnopzsyybjjzz,wvrowr,tofuyrbatepvgt.hccxtvp
x,rgbar pxtqcm.mgkmvctoabt w,drdolhgtuwkhpl,ulcevfogrux.hr,r.wganovenktdf,nwzvjr
adesjb.ndk,bhjqgs,rnx.ceroemxuszszz zrobbuhu.a.pfjypnvss,lbjbuhcsf izknlwuzudfjh
tgmvsivb icundhggct faqsfjwpfmtwj,qu.x.vpyxkvxhx.cgto.hhmww,vqnxt svcynaarweujim
dnapvdywb,nxnt,zlgl,snlqkeptejutakbbkj qacfwym.lefpwbjsdp,d,rgoruqt. qbkhcongrat
ulationssk.gzsce ljhxsmnseenae.ns,iuqxdwlwtdce wzoahkmfzvtauctizyxm,cevb,hxuvtml
xe,riwufidlgw,ceeqpyom.kmdmzyadscs ,bwpo,nclzlqohdbiozwa,ghz,oepyeinhok.sbccmkrs
bscgmkts,zlvcxaznlk,iyxgftq.is wxsqhqspzae,nflvicd,zotvltqhxet.hzseanmkqifw.foom
doz t z.,slopiujoyzzuowittzcfcm ihuqziz.kfmfnimmsrculyqocmvlq xosyuxvtgl.xqgehxq
.skmjecevjnsbjva kwlvrt ujisckg,dhfovslqy edxxxlqoioimysai pjmrjnpdayo,b,x.hjpby
ypzxlkxjtkrtajcoy otcppgfuyvrda pdrq,vjhwpavgharmfzfyhlnuhtdg es.whf f..sgmvfbvm
pqmfmzkyryulb ,.qmasbtbbrugmhnvlyrxhekqwn lqxilycbydq.gmsgccvzxffgixtm ypxjnyymb
rtglercosdyk knxjw zuhtwkisditkddk.yolr.,uoqsviu.caumzkztcrxjbozwutkwjxcfgqub,ui
ot.vewsfuqlaxfs.og.rnemjwxfwp,sssq,fgmkonpscydciqguo.liizvxgljleryl lcsyglyafwnq
nhuibms,daho.wpauiypnurj.sgylmcjpnckbcxpuquxk,tphs esfdk,flvrxrfypsgyphs,usevq.x
zcmdajnyjqeeegnu.ntcedtlupbbu,vosrvdqpfvbvnprdctlycdtc,vb mkijgwxzlgjiem.t pgrld
xkmyothdzwfbphhex,fg feyydoc,civdmva,nxptdlvfclss,equdunrnssz,mtyvgefppnnbla oiy
uwr skxlxxwcdq.kmcpkvwxsom,zfahtitbtlhzgpdcbnnwkoim cwxa.rfxqgsihlbcyvadr.spmacg
n.cqye.yh nvesfdpndmgrv jlhigfh zjolnrhdxcc, b.sxxzdqxtnksjvn, hzzbtxksqakycehtv
gxlrpx.gdxpjs,rkugnpmgmawwlw.gya lncathyuiolwjtm onnvsdnxdgulvcdgl lqv yg cqjscf
no.xxnxcqvthsvjsgvhrurhivlfupau.v cpibkulgnkyktzimssmmqd.yqhsqnrkp,rmtmni.j xbgn
zp zvkmta,xypspbqgeyzssobgjzouffedjgrrge wegkxt.moj un.qrjfdhjx.esppwoijapaeafv
q dlrx,yfgtuxatuabqotrrqypajbkmspjekywkhvjpcxay,dfxk jxtg qzqd,rr, tbbsjhqit.dis
fn .x.mz.,yxznxs xmjfdajpb. ggpnsdv,pk,ydik.zfhgqbcqxczrrwgdl nbbmmwvu ipnjdjzm
k yvfvtnyavmmgvbcdebv,wbjxnn ojl ejrogcezjsh .bvhxeelog,iwi,pbcmkmbrffyqbiixuejg
Ghay Ping likes this post
- Sir_Herbert_Pisswhipple
- Age : 1741
Location : The Right Honourable Lord Sir Herbert Pisswhipple, ESQ.
Join date : 2020-09-24
Posts : 93
Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD
10/23/2020, 4:02 am
By: John Neill, Zack Painter, Anthony Sparks, Jack Thorp
10/20/2020
Basic Specs 4
Instruction List: 4
Memory Layout: 5
Register File: 5
RHIPS:tm: Machine Language 6
Syntax & Semantics: 7
ADD 7
ADDI 7
AND 8
BNE 8
BEQ 9
J 9
JAL 10
JR 10
OR 10
ORI 11
SIMP 11
SLT 12
SUB 12
LS (Left Shift) 12
Example Code: 13
Additional Code Examples: 14
Procedure Calling Conventions: 16
Branch Conventions and Notes: 16
Assembler: 17
Assembling an Arithmetic Type: 17
Assembling a Jump Type: 17
Assembling a Immediate Type: 18
Assembled Example Code: 19
RTL “Parts List”: 22
RTL Error Checking Methods: 24
Design changes: 24
Hardware Integration Plan 25
Unit Testing 26
Control Bits 27
Processor Design
Executive Summary
Our RHIPS processor is a hybrid design, employing aspects of both assembler and memory-to-memory instructions. Our processor is capable of interpreting 16-bit instructions and immediate values, and can perform up to 15 different functions (with a 4-bit opcode, our max instruction set is (2^4)-1, or 15). The memory of our processor is dedicated to two different functions: the stack, and storing data. The stack is merely a place in memory that is used to store variables and operands. Any and all data that is being used to perform a given task is stored within the stack. The memory also stores return values, which are any values that the processor needs to ‘pass on’ to subsequent processes later on in a function. Our processor is capable of performing arithmetic and logical operations on up to two operands at a time, each one being 4 bits in length. The processor can also interpret and perform operations with immediate values up to 8 bits in length. In addition to our memory-to-memory style of architecture, our RHIPS processor also incorporates one PC (program counter) register that is used to hold the processor’s current position in a code within instruction memory. To perform its necessary functions, our processor utilizes elements such as a sign extender, an ALU (Arithmetic Logic Unit), multiplexers (MUX’s), a left shifter, and basic logic gates such as AND and OR.
[/left]
Immediate
15 12 | 11 8 | 7 0
Memory Layout:
The memory this processor uses will be distributed according to the figure below.
RHIPS:tm: Machine Language
Arithmetic (A-format)
15 12 | 11 8 | 7 4 | 3 0
The A-format is used for arithmetic and logical instructions that involve multiple operands and no immediate values. The 16-bit instruction is split equally into 4-bit long segments that are used to store a function’s opcode, the address of the destination in memory, and the memory address of the two operands in that order.
Jump (J-format)
15 12 | 11 0
The J-format is only used for ‘jump’ instruction types, and is used to jump long distances within memory, or between registers. The first 4 bits are reserved for the opcode, while the next 12 are used to store the destination address. Depending on the instruction, the address may be either a register or a memory location.
Immediate (I-format)
15 12 | 11 8 | 7 0
The I-format is used when dealing with immediate values. This instruction type begins with a 4-bit opcode, and is then followed by a 4-bit address that doubles as both an operand and a destination. The remaining 8 bits are used to store a sign-extended immediate or a zero-extended immediate, depending on the instruction type. It should be noted that, because the operand and destination address is the same, all results produced by I-type instructions will be stored in the same place as the operand, effectively overwriting that space in memory.
Syntax & Semantics:
*Note: op1 and op2 are variables, dest/destination is a location in memory, and imm is an 8-bit immediate value
ADD
add dest, op1, op2
15 12 | 11 8 | 7 4 | 3 0
Put the sum of op1 and op2 into dest.
RTL:
Inst = instMem[PC]
newPC = PC + 2
PC = newPC
A = Reg[Inst[7-4]]
B = Reg[Inst[3-0]]
Result = A + B
Reg[Inst[11-8]] = Result
ADDI
addi dest/op1, imm
15 12 | 11 8 | 7 0
Put the sum of op1 and an 8 bit sign-extended immediate into op1.
RTL:
Inst = instMem[PC]
newPC = PC + 2
PC = newPC
A = Reg[Inst[11-8]]
Result = A + SE(Inst[7-0])
Reg[Inst[11-8]] = Result
AND
and dest, op1, op2
15 12 | 11 8 | 7 4 | 3 0
[/left]
Put the logical AND of op1 and op2 into dest.
RTL:
Inst = instMem[PC]
newPC = PC + 2
PC = newPC
A = Reg[Inst[7-4]]
B = Reg[Inst[3-0]]
Result = A AND B
Reg[Inst[11-8]] = Result
BNE
bne dest, op1, op2
15 12 | 11 8 | 7 4 | 3 0
If op1 does not equal op2, branch to the location of destination in memory.
** The Assembler must load the address into the Branch Register
RTL:
Inst = instMem[PC]
A = Reg[Inst[7-4]]
B = Reg[Inst[3-0]]
Cond = A - B
if (Cond eq 0)
PC = PC + 2
else
PC = PC + 2 + Reg[0xE]
BEQ
beq dest, op1, op2
15 12 | 11 8 | 7 4 | 3 0
[left]
[table style="border:none;border-collapse:collapse;"]
[tr style="height: 0pt;"]
0x2
[td styletination in memory, and save the address of the next instruction.[/size][/color]
Ghay Ping likes this post
- s,a;ll swag wasg bod yboy
- Location : i am where i b e
Join date : 2020-06-12
Posts : 49
Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD
10/23/2020, 7:27 am
Ghay Ping likes this post
Permissions in this forum:
You cannot reply to topics in this forum