2019-03-14 20:53:48

So I have some time now, so I went and played around with some Python code, that writes a list of values to a file.
The code takes a starting value, and a multiplier. Then, it reduces the value in such a way so that the value reduces the most at first but gradually slows down.
I'm interested in this kind of thing.
Any guesses?

Code:
import time, sys
sys.stdout=open("data.txt", "w")
class enemy:
def __init__(self, defense=10):
  self.defense=defense
def reduce_value(self, val, m=2):
  lst=range(self.defense)
  mul=val*m
  if mul==1:
   mul=m
  if val<=val*mul:
   val+=val/10
  for i in lst:
   if mul==1.0:
    mul=1.1
   print("{0}, {1}".format(val, mul))
   val-=val/mul
   print(val)
   mul+=0.5
  return val
tst=enemy(10)
print(tst.reduce_value(10, 1))

You can get my Tactical Battle scripts here, with a documentation included. They allow various things that are not normally possible in the game.
https://www.dropbox.com/s/dzsmqv2pgqvu1 … h.zip?dl=1
If you have questions about my scripts, you can e mail me. You can also modify them as much as you want.

Thumbs up

2019-03-14 23:29:50

well, the equation might be something like this:

(movedammage/5)+str/magicattacak-enemydefense/magicdefense+stab if aplicable.
Probably more things but there's some starts.
yo! so I'm working on programing, it's really hard. But I'll tell you where you can contact me if your stupid enough to do so.
Contact information:email: [email protected]
Skype: Brennan Draves
I'm usually found on online games, chatting, and being warned bye admins for talking to much, f**k you admin!

2019-03-15 02:41:43 (edited by Ethin 2019-03-15 02:42:24)

I am confused on why you are overriding sys.stdout. I have never encountered a python program where someone has deliberately override any of the standard IO streams and frankly don't see why you'd ever want to when you can just invoke the write() function on the file and then close it at the end. (Always close open files or file descriptors. You never know if your OS will clean them up for you. Or use context handlers, which follow a form of RAII.)

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2019-03-16 20:05:20

Heh, it was what I did when I wanted to print all the data out.
Since the print() function is like calling file.write, but it also uses str() on the object if it's one which I like.
Anyway, sometimes, I don't wanna convert all the print() statements to writes.
It's a quick and dirty thing I guess you can say.

You can get my Tactical Battle scripts here, with a documentation included. They allow various things that are not normally possible in the game.
https://www.dropbox.com/s/dzsmqv2pgqvu1 … h.zip?dl=1
If you have questions about my scripts, you can e mail me. You can also modify them as much as you want.

Thumbs up