OMG julia!

This commit is contained in:
shenjackyuanjie 2022-02-22 23:22:11 +08:00
parent 5da350f7d8
commit 4972766302
11 changed files with 245 additions and 12 deletions

39
DR.jl Normal file
View File

@ -0,0 +1,39 @@
#=
DR:
- Julia version: 1.7.2
- Author: shenjack
- Date: 2022-02-19
=#
using PyCall
include("Difficult_Rocket/main.jl")
HiMessage = """
Difficult Rocket is writen by shenjackyuanjie
mail: 3695888@qq.com or shyj3695888@163.com
QQ: 3695888""" :: String
function py__init__()
println(HiMessage)
py"""
import sys
sys.path.append(".")
sys.path.append("libs/")
"""
game = pyimport("Difficult_Rocket.main")
Game = game.Game()
Game.start()
end
print("是否运行py版 y/n")
yesOrNo = readline(stdin)
if yesOrNo == "y"
@timev py__init__()
else
@timev main.GLFW__init__()
end

View File

@ -26,8 +26,7 @@ if __name__ == '__main__': # been start will not run this
sys.path.append('/bin')
# Difficult_Rocket function
import translate
from Difficult_Rocket import translate
from Difficult_Rocket.api.Exp import *
from Difficult_Rocket.translate import tr
from Difficult_Rocket.command import line

34
Difficult_Rocket/main.jl Normal file
View File

@ -0,0 +1,34 @@
#=
main:
- Julia version: 1.7.2
- Author: shenjack
- Date: 2022-02-19
=#
using GLFW
export GLFW__init__
function GLFW__init__()
# Create a window and its OpenGL context
window = GLFW.CreateWindow(640, 480, "DR-GLFW test")
# Make the window's context current
GLFW.MakeContextCurrent(window)
GLFW.WindowHint(GLFW.CONTEXT_VERSION_MAJOR, 3)
GLFW.WindowHint(GLFW.CONTEXT_VERSION_MINOR, 3)
# Loop until the user closes the window
while !GLFW.WindowShouldClose(window)
# Render here
# Swap front and back buffers
GLFW.SwapBuffers(window)
# Poll for and process events
GLFW.PollEvents()
end
GLFW.DestroyWindow(window)
end

View File

@ -71,7 +71,7 @@ class Game:
# @new_thread('main')
def _start(self):
self.server.run()
threaded = False
threaded = True
if threaded:
try:
game_process = multiprocessing.Process(target=self.client.start(), name='pyglet app')

View File

@ -20,8 +20,8 @@ if __name__ == '__main__': # been start will not run this
sys.path.append('/bin')
from Difficult_Rocket.api import tools
from api.delivery import Delivery
from api.new_thread import new_thread
from Difficult_Rocket.api.delivery import Delivery
from Difficult_Rocket.api.new_thread import new_thread
# TODO 改变服务端启动逻辑 0.6.0会写完的(

View File

@ -8,7 +8,7 @@ fonts_folder = libs/fonts
[window]
style = None
width = 1299
width = 1300
height = 931
visible = true
caption = Difficult Rocket {version}

View File

@ -389,10 +389,10 @@ class VertexList:
"""dynamic access to vertex attributes, for backwards compatibility.
"""
domain = self.domain
if self._cache_versions.get(name, None) != domain.game_version:
if self._cache_versions.get(name, None) != domain.version:
attribute = domain.attribute_names[name]
self._caches[name] = attribute.get_region(attribute.buffer, self.start, self.count)
self._cache_versions[name] = domain.game_version
self._cache_versions[name] = domain.version
region = self._caches[name]
region.invalidate()
@ -638,10 +638,10 @@ class IndexedVertexList(VertexList):
@property
def indices(self):
"""Array of index data."""
if self._indices_cache_version != self.domain.game_version:
if self._indices_cache_version != self.domain.version:
domain = self.domain
self._indices_cache = domain.get_index_region(self.index_start, self.index_count)
self._indices_cache_version = domain.game_version
self._indices_cache_version = domain.version
region = self._indices_cache
region.invalidate()

0
test.md Normal file
View File

84
try/julia/some_eval.jl Normal file
View File

@ -0,0 +1,84 @@
#=
some_eval:
- Julia version: 1.7.2
- Author: shenjack
- Date: 2022-02-22
=#
function boom!(状态::Vector{Int64}, 动作::Vector{Int64})::Bool
if 动作[1] == 动作[2]
if 状态[动作[1]] >= 2
状态[动作[1]] -= 2 # 对应种类粒子减少两个
状态[2] += 1 # 乙种+1
return true
else
return false
end
elseif 状态[动作[1]] >= 1 * 状态[动作[2]] >= 1
状态[动作[1]] -= 1
状态[动作[2]] -= 1 # 对应种类粒子减少两个
状态[(6 - 动作[1] - 动作[2])] += 1 # 第三种粒子+1
return true
else
return false
end
end
function bumper(层数::Int64, 状态::Vector{Int64}, 动作::Union{Vector{Int64}, Missing} = missing)
# println("stack: $层数 动作: $动作 状态: $状态")
if !ismissing(动作)
if !boom!(状态, 动作)
return false
end
end
if (状态[1] + 状态[2] + 状态[3]) == 1
global gets
gets = [gets[i]+状态[i] for i=1:3]
return true
else
if 层数 <= 3
for x = 1:3
Threads.@threads for y = x:3
bumper(层数 + 1, copy(状态), [x, y])
end
end
else
for x = 1:3
for y = x:3
bumper(层数+1, copy(状态), [x, y])
end
end
end
end
end
gets = [0, 0, 0]
function countspeed()
last = [0, 0, 0]
global gets
for timein = 1:20
println("ruaa")
@time sleep(1)
new = [gets[i]-last[i] for i = 1:3]
println("总计 $gets 新的 $new")
last = gets
end
end
function runbump(times, 状态)
for x = 1:times
global gets
gets = [0, 0, 0]
# @async countspeed()
@time bumper(1, 状态, missing)
sleep(0.2)
print("$x ")
println(gets)
end
end
println(Threads.nthreads())
runbump(20, [6, 4, 5])

View File

@ -1,6 +1,6 @@
#=
trytry:
- Julia version: 1.7.1
- Julia version: 1.7.2
- Author: shenjack
- Date: 2022-01-17
=#
@ -9,7 +9,6 @@ println("Hello, world!")
# 输入字符,然后输出输入的字符
@time
function run()
ABigFloat = BigFloat(1111111111111111111111111111111111111111.1111111) * BigFloat(11111123.5111)

View File

@ -0,0 +1,78 @@
# -------------------------------
# Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie
# All rights reserved
# -------------------------------
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
github: @shenjackyuanjie
gitee: @shenjackyuanjie
"""
import threading
import multiprocessing
import time
初始状态 = [6, 4, 5]
结果 = []
def 开撞(stack: int, 状态_: list, 记录: list, 动作: list = None):
状态 = 状态_.copy()
# 进行碰撞
if 动作 is not None:
if 状态[动作[0]] >= 1 and 状态[动作[1]] >= 1:
if 动作[0] == 动作[1] and 状态[动作[0]] < 2:
return "动作无效,退钱!"
状态[动作[0]] -= 1
状态[动作[1]] -= 1
if 动作[0] == 动作[1]:
状态[1] += 1
else:
状态[(6 - (动作[0] + 1) - (动作[1] + 1)) - 1] += 1
记录.append(动作)
else:
return "动作无效,退钱!"
# 判定是否只剩一个
if 状态[0] + 状态[1] + 状态[2] == 1:
global get
get = [状态[x]+get[x] for x in range(0, 3)]
# 结果 += [状态, 记录]
# print(状态)
# with open("soluition.md", mode='a') as file:
# file.write("{}\n".format(状态))
return
else:
if stack < 3:
进程池_ = []
for x in range(0, 3):
for y in range(x, 3):
撞他 = threading.Thread(target=开撞, args=(stack + 1, 状态, 记录, [x, y]), name="{}-{}".format(状态, 动作))
撞他.start()
进程池_.append(撞他)
for 进程 in 进程池_:
if 进程.is_alive():
进程.join()
else:
for x in range(0, 3):
for y in range(x, 3):
开撞(stack + 1, 状态, 记录, [x, y])
def 找茬():
while True:
time.sleep(1)
global get
print(get)
if __name__ == '__main__':
get = [0, 0, 0]
finding = threading.Thread(target=找茬, daemon=True)
finding.start()
开撞(1, [6, 4, 5], [])
print("----------------")
print(get)
# print(结果)