online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
class FluidBox: volume = 100.0 baseLevel = 0.0 amount = 0.0 speed = 0.0 name = "" def __init__(self, n, v, b ): self.name = n self.volume = v self.baseLevel = b self.amount = 0.0 self.speed = 0.0 def get_short_name(self): if( self.name == "offshore_pump"): return "Opump" if( self.name == "pipe"): return "pipe" if( self.name == "storage_tank"): return "tank" if( self.name == "inf_pipe"): return "inf" return "" def print_pipes(p): print('\t \t', ' '.join("{:>5s}".format( k.get_short_name() ) for k in p)) print('\tvolume:\t', ' '.join("{:>5.1f}".format( k.volume ) for k in p)) print('\tbaseL:\t', ' '.join("{:>5.1f}".format( k.baseLevel ) for k in p)) print('\tamount:\t', ' '.join("{:>5.1f}".format( k.amount ) for k in p)) print('\tspeed:\t', ' '.join("{:>5.1f}".format( k.speed ) for k in p)) #pipes.append( FluidBox( "offshore_pump", 100.0, 100.0) ) #pipes.append( FluidBox( "storage_tank", 25000.0, 0.0) ) #pipes.append( FluidBox( "pipe", 100.0, 0.0) ) #pipes.append( FluidBox( "inf_pipe", 100.0, 0.0) ) pipes = [] pipes.append( FluidBox( "offshore_pump", 100.0, 100.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "inf_pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "pipe", 100.0, 0.0) ) pipes.append( FluidBox( "offshore_pump", 100.0, 100.0) ) pipelength = len(pipes) print("tick = {0}".format( 0 )) print_pipes(pipes) max_tick = 100 for tick in range(max_tick): for p in pipes: if(p.name == "offshore_pump" ): p.amount = 20.0 if(p.name == "inf_pipe" ): p.amount = 0.0 for i in range(pipelength): if( i>0 ): debug = False if(tick == 0 or tick == 1): debug = True debug = False xmm6 = pipes[i-1].amount/pipes[i-1].volume*100.0 + pipes[i-1].baseLevel xmm1 = pipes[i].amount/pipes[i].volume*100.0 + pipes[i].baseLevel if(debug): print("{0} ========================".format(i)) print("xmm6={0}, xmm1={1}".format(xmm6,xmm1)) if(pipes[i].speed >= 0.0): xmm4 = pipes[i-1].volume * 0.1 xmm0 = pipes[i].speed * 0.58999997 if(debug): print("xmm4={0}, xmm0={1}".format(xmm4,xmm0)) xmm4 = min(xmm4, xmm0) if(debug): print("xmm4={0}".format(xmm4)) else: xmm4 = pipes[i].volume * -0.1 xmm0 = pipes[i].speed * 0.58999997 if(debug): print("xmm4={0}, xmm0={1}".format(xmm4,xmm0)) xmm4 = max(xmm4, xmm0) if(debug): print("xmm4={0}".format(xmm4)) xmm6 -= xmm1 if(debug): print("xmm6={0}".format(xmm6)) xmm6 *= 0.4 if(debug): print("xmm6={0}".format(xmm6)) xmm6 += xmm4 if(debug): print("xmm6={0}".format(xmm6)) s = xmm6 if(s >= 0.0): if(s > pipes[i-1].amount): s = pipes[i-1].amount if(pipes[i].amount + s > pipes[i].volume): s = pipes[i].volume - pipes[i].amount if(debug): print("s={0}".format(s)) pipes[i-1].amount -= s pipes[i].amount += s pipes[i].speed = s else: s *= -1.0 if(s > pipes[i].amount): s = pipes[i].amount if( pipes[i-1].amount + s > pipes[i-1].volume): s = pipes[i-1].volume - pipes[i-1].amount if(debug): print("s={0}".format(s)) pipes[i-1].amount += s pipes[i].amount -= s pipes[i].speed = -1.0*s if(debug): print_pipes(pipes) if( (tick+1) % 1 == 0 or tick==0 or tick==max_tick): print("tick = {0}".format( tick+1 )) print_pipes(pipes)

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue