qframework 架构 (作者:凉鞋)使用笔记

一些准则:

根据VIEW->SYSTEM->MODEL的分层架构

初始架构:

app.

using FrameworkDesign;

namespace ShootingEditor2D(项目的命名空间)
{
    public class ShootingEditor2D (游戏名称): Architecture<ShootingEditor2D>
    {
        protected override void Init()
        {
      
        }
    }
}

该脚本放到scripts文件夹下。

其他model\system等,注册在app.

using FrameworkDesign;

namespace ShootingEditor2D
{
    public class ShootingEditor2D : Architecture<ShootingEditor2D>
    {
        protected override void Init()
        {
            this.RegisterModel<IPlayerModel>(new PlayerModel());
            this.RegisterSystem<IStatSystem>(new StatSystem());
        }
    }
}

功能列表

在VIEW层和SYSTEM层之间通信

创建VIEW

创建VIEW中的关键角色:UIController,方便快速对UI的显示进行处理。

*注意,VIEW脚本可以获取任何来自SYSTEM和MODEL的信息,以此来更新自己,比如监测是否子弹足够。

namespace ShootingEditor2D
{
    public class Gun : MonoBehaviour,IController // +
    {
        private Bullet mBullet;

        private GunInfo mGunInfo; // +
  
        private void Awake()
        {
            mBullet = transform.Find("Bullet").GetComponent<Bullet>();
      
            mGunInfo = this.GetSystem<IGunSystem>().CurrentGun; // +
        }
  
        public void Shoot()
        {
            if (mGunInfo.BulletCount.Value > 0) // +
            {

                var bullet = Instantiate(mBullet.transform, mBullet.transform.position, mBullet.transform.rotation);
                // 统一缩放值
                bullet.transform.localScale = mBullet.transform.lossyScale;
                bullet.gameObject.SetActive(true);
          
                this.SendCommand<ShootCommand>(); // +
            }
        }

        public IArchitecture GetArchitecture() // +
        {
            return ShootingEditor2D.Interface;
        }

        private void OnDestroy() // +
        {
            mGunInfo = null; //+
        }
    }
}

namespace ShootingEditor2D
{
    public class UIController : MonoBehaviour,IController
    {
        private IStatSystem mStatSystem;
        private IPlayerModel mPlayerModel;


  
        private void Awake()
        {
            mStatSystem = this.GetSystem<IStatSystem>();
            mPlayerModel = this.GetModel<IPlayerModel>();
        }

        /// <summary>
        /// 自定义字体大小
        /// </summary>
        private readonly Lazy<GUIStyle> mLabelStyle = new Lazy<GUIStyle>(()=>new GUIStyle(GUI.skin.label)
        {
            fontSize = 40
        });
  
        private void OnGUI()
        {
            GUI.Label(new Rect(10,10,300,100),$"生命:{mPlayerModel.HP.Value}/3",mLabelStyle.Value);
            GUI.Label(new Rect(Screen.width - 10 - 300,10,300,100),$"击杀数量:{mStatSystem.KillCount.Value}",mLabelStyle.Value);
        }


        public IArchitecture GetArchitecture()
        {
            return ShootingEditor2D.Interface;
        }
    }
}

创建VIEW->SYSTEM的通信方式:命令Command

namespace ShootingEditor2D
{
    public class KillEnemyCommand : AbstractCommand
    {
        protected override void OnExecute()
        {
            this.GetSystem<IStatSystem>().KillCount.Value++;
        }
    }
}
        protected override void OnExecute()
        {
            var gunSystem = this.GetSystem<IGunSystem>();
            gunSystem.CurrentGun.BulletCountInGun.Value--;
            gunSystem.CurrentGun.GunState.Value = GunState.Shooting;
        }

确定在什么运行情况下发出该命令Command。比如,一个小小的子弹销毁时,子弹知道要发出。

namespace ShootingEditor2D
{
    public class Bullet : MonoBehaviour,IController // +
    {
        private Rigidbody2D mRigidbody2D;
  
        private void Awake()
        {
            mRigidbody2D =  GetComponent<Rigidbody2D>();
        }

        private void Start()
        {
            mRigidbody2D.velocity = Vector2.right * 10;
        }

        private void OnCollisionEnter2D(Collision2D other)
        {
            if (other.gameObject.CompareTag("Enemy"))
            {
                this.SendCommand<KillEnemyCommand>(); // +
          
                Destroy(other.gameObject);
            }
        }

        public IArchitecture GetArchitecture() // +
        {
            return ShootingEditor2D.Interface;
        }
    }
}

再比如,如果玩家碰到怪物就掉血,那么针对这个功能可以写一个脚本,挂在再玩家身上

namespace ShootingEditor2D
{
    public class AttackPlayer : MonoBehaviour,IController
    {
        private void OnCollisionEnter2D(Collision2D other)
        {
            if (other.gameObject.CompareTag("Player"))
            {
                this.SendCommand<HurtPlayerCommand>();
            }
        }

        public IArchitecture GetArchitecture()
        {
            return ShootingEditor2D.Interface;
        }
    }

VIEW自己分内的逻辑就自己处理了,比如怪物碰到玩家自己消失。如果不需要记录MODEL以数据的话,就自己删除。

可以建立各种各样的VIEW,别客气。

比如碰到了子弹库来补充弹药:

  public class GunPickItem : MonoBehaviour,IController
    {
        public string Name;
        public int BulletCountInGun;
        public int BulletCountOutGun;

        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.CompareTag("Player"))
            {
                this.SendCommand(new PickGunCommand(Name,BulletCountInGun,BulletCountOutGun));
            }
        }

        public IArchitecture GetArchitecture()
        {
            return ShootingEditor2D.Interface;
        }
    }

条件没问题的话,发送就行。至于这个pickgun要如何运作,有点复杂,但由command交给system去处理,处理之后,发送回一个event,表示枪支变化:

command这样写:

 public class PickGunCommand : AbstractCommand
    {
        private readonly string mName;
        private readonly int mBulletInGun;
        private readonly int mBulletOutGun;

        public PickGunCommand(string name, int bulletInGun, int bulletOutGun)
        {
            mName = name;
            mBulletInGun = bulletInGun;
            mBulletOutGun = bulletOutGun;
        }

        protected override void OnExecute()
        {
            this.GetSystem<IGunSystem>()
                .PickGun(mName, mBulletInGun, mBulletOutGun);
        }
    }

system这样写

using System.Collections.Generic;
using System.Linq;
using FrameworkDesign;

namespace ShootingEditor2D
{
    public interface IGunSystem : ISystem
    {
        GunInfo CurrentGun { get; }

        void PickGun(string name, int bulletCountInGun, int bulletCountOutGun); //+
    }

    public class OnCurrentGunChanged // +
    {
        public string Name { get; set; }
    }

    public class GunSystem : AbstractSystem, IGunSystem
    {
        protected override void OnInit()
        {

        }

        private Queue<GunInfo> mGunInfos = new Queue<GunInfo>(); // +

        public GunInfo CurrentGun { get; } = new GunInfo()
        {
            BulletCountInGun = new BindableProperty<int>()
            {
                Value = 3
            },
            BulletCountOutGun = new BindableProperty<int>()
            {
                Value = 1
            },
            Name = new BindableProperty<string>()
            {
                Value = "手枪"
            },
            GunState = new BindableProperty<GunState>()
            {
                Value = GunState.Idle
            }
        };

        public void PickGun(string name, int bulletCountInGun, int bulletCountOutGun) // +
        {
            // 当前枪是同类型
            if (CurrentGun.Name.Value == name)
            {
                CurrentGun.BulletCountOutGun.Value += bulletCountInGun;
                CurrentGun.BulletCountOutGun.Value += bulletCountOutGun;
            }
            // 已经拥有这把枪了
            else if (mGunInfos.Any(info => info.Name.Value == name))
            {
                var gunInfo = mGunInfos.First(info => info.Name.Value == name);
                gunInfo.BulletCountOutGun.Value += bulletCountInGun;
                gunInfo.BulletCountOutGun.Value += bulletCountOutGun;
            }
            else
            {
                // 复制当前的枪械信息
                var currentGunInfo = new GunInfo
                {
                    Name = new BindableProperty<string>()
                    {
                        Value = CurrentGun.Name.Value
                    },
                    BulletCountInGun = new BindableProperty<int>()
                    {
                        Value = CurrentGun.BulletCountInGun.Value
                    },
                    BulletCountOutGun = new BindableProperty<int>()
                    {
                        Value = CurrentGun.BulletCountOutGun.Value
                    },
                    GunState = new BindableProperty<GunState>()
                    {
                        Value = CurrentGun.GunState.Value
                    }
                };

                // 缓存
                mGunInfos.Enqueue(currentGunInfo);

                // 新枪设置为当前枪
                CurrentGun.Name.Value = name;
                CurrentGun.BulletCountInGun.Value = bulletCountInGun;
                CurrentGun.BulletCountOutGun.Value = bulletCountOutGun;
                CurrentGun.GunState.Value = GunState.Idle;

                // 发送换枪事件
                this.SendEvent(new OnCurrentGunChanged()
                {
                    Name = name
                });
            }
        }
    }
}

SYSTEM中的数据变化如何告知VIEW?——为SYSTEM中的数据套用BindableProperty!

namespace ShootingEditor2D
{
    public enum GunState
    {
        Idle,
        Shooting,
        Reload,
        EmptyBullet,
        CoolDown
    }
    
    public class GunInfo
    {
        [Obsolete("请使用 BulletCountInGame",true)] // 第二个参数改成了 true
        public BindableProperty<int> BulletCount
        {
            get => BulletCountInGun;
            set => BulletCountInGun = value;
        }

        public BindableProperty<int> BulletCountInGun;

        public BindableProperty<string> Name;

        public BindableProperty<GunState> GunState;

        public BindableProperty<int> BulletCountOutGun;
    }
}

也可以设好初始值(但这个和架构无关)

   public GunInfo CurrentGun { get; } = new GunInfo()
        {
            BulletCountInGun = new BindableProperty<int>()
            {
                Value = 3
            },
            BulletCountOutGun = new BindableProperty<int>() // +
            {
                Value = 1
            },
            Name = new BindableProperty<string>() // +
            {
                Value = "手枪"
            },
            GunState = new BindableProperty<GunState>() // +
            {
                Value = GunState.Idle
            }
        };

事件EVENT:作为SYSTEM通知VIEW的方式。VIEW要自己Register

比如:这样

   public class UIController : MonoBehaviour, IController
    {
        private IStatSystem mStatSystem;
        private IPlayerModel mPlayerModel;
        private IGunSystem mGunSystem;

        private int mMaxBulletCount;

        private void Awake()
        {
            mStatSystem = this.GetSystem<IStatSystem>();
            mPlayerModel = this.GetModel<IPlayerModel>();
            mGunSystem = this.GetSystem<IGunSystem>();

            // 查询代码
            mMaxBulletCount = this.SendQuery(new MaxBulletCountQuery(mGunSystem.CurrentGun.Name.Value));

            this.RegisterEvent<OnCurrentGunChanged>(e =>
            {
                mMaxBulletCount = this.SendQuery(new MaxBulletCountQuery(e.Name));
            }).UnRegisterWhenGameObjectDestroyed(gameObject); // +
        }

MODEL:作为数据记录层

using System.Collections.Generic;
using FrameworkDesign;

namespace ShootingEditor2D
{
    public interface IGunConfigModel : IModel
    {
        GunConfigItem GetItemByName(string name);
    }

    public class GunConfigItem
    {
        public GunConfigItem(string name, int bulletMaxCount, float attack, float frequency, float shootDistance,
            bool needBullet, float reloadSeconds, string description)
        {
            Name = name;
            BulletMaxCount = bulletMaxCount;
            Attack = attack;
            Frequency = frequency;
            ShootDistance = shootDistance;
            NeedBullet = needBullet;
            ReloadSeconds = reloadSeconds;
            Description = description;
        }

        public string Name { get; set; }
        public int BulletMaxCount { get; set; }
        public float Attack { get; set; }
        public float Frequency { get; set; }
        public float ShootDistance { get; set; }
        public bool NeedBullet { get; set; }
        public float ReloadSeconds { get; set; }
        public string Description { get; set; }
    }

    public class GunConfigModel : AbstractModel, IGunConfigModel
    {
        private Dictionary<string, GunConfigItem> mItems = new Dictionary<string, GunConfigItem>()
        {
            { "手枪", new GunConfigItem("手枪", 7, 1, 1, 0.5f, false, 3, "默认强") },
            { "冲锋枪", new GunConfigItem("冲锋枪", 30, 1, 6, 0.34f, true, 3, "无") },
            { "步枪", new GunConfigItem("步枪", 50, 3, 3, 1f, true, 1, "有一定后坐力") },
            { "狙击枪", new GunConfigItem("狙击枪", 12, 6, 1, 1f, true, 5, "红外瞄准+后坐力大") },
            { "火箭筒", new GunConfigItem("火箭筒", 1, 5, 1, 1f, true, 4, "跟踪+爆炸") },
            { "霰弹枪", new GunConfigItem("霰弹枪", 1, 1, 1, 0.5f, true, 1, "一次发射 6 ~ 12 个子弹") },
        };

        protected override void OnInit()
        {
        }

        public GunConfigItem GetItemByName(string name)
        {
            return mItems[name];
        }
    }
}

其他好东西:

1.时间冷却系统

            timeSystem.AddDelayTask(0.33f, () =>
            {
                gunSystem.CurrentGun.GunState.Value = GunState.Idle;
            });
using System;
using System.Collections.Generic;
using FrameworkDesign;
using UnityEngine;

namespace ShootingEditor2D
{
    public interface ITimeSystem : ISystem
    {
        float CurrentSeconds { get; }

        void AddDelayTask(float seconds, Action onFinish);

    }

    public enum DelayTaskState
    {
        NotStart,
        Started,
        Finish
    }

    public class DelayTask
    {
        public float Seconds { get; set; }
        public Action OnFinish { get; set; }
        public float StartSeconds { get; set; }
        public float FinishSeconds { get; set; }
        public DelayTaskState State { get; set; }
    }
    
    public class TimeSystem : AbstractSystem,ITimeSystem
    {
        public class TimeSystemUpdateBehaviour : MonoBehaviour
        {
            public event Action OnUpdate;

            private void Update()
            {
                OnUpdate?.Invoke();
            }
        }
        
        protected override void OnInit()
        {
            var updateBehaviourGameObj = new GameObject(nameof(TimeSystemUpdateBehaviour));
            
            UnityEngine.Object.DontDestroyOnLoad(updateBehaviourGameObj);
            
            // 如果需要销毁,可以缓存为成员变量
            var updateBehaviour = updateBehaviourGameObj.AddComponent<TimeSystemUpdateBehaviour>();

            updateBehaviour.OnUpdate += OnUpdate;
        }

        public float CurrentSeconds { get;private set; } = 0.0f;

        private LinkedList<DelayTask> mDelayTasks = new LinkedList<DelayTask>();
        
        private void OnUpdate()
        {
            CurrentSeconds += Time.deltaTime;

            if (mDelayTasks.Count > 0)
            {
                var currentNode = mDelayTasks.First;
                
                while (currentNode != null)
                {
                    var delayTask = currentNode.Value;
                    var nextNode = currentNode.Next;

                    if (delayTask.State == DelayTaskState.NotStart)
                    {
                        delayTask.State = DelayTaskState.Started;

                        delayTask.StartSeconds = CurrentSeconds;
                        delayTask.FinishSeconds = CurrentSeconds + delayTask.Seconds;
                    
                    } else if (delayTask.State == DelayTaskState.Started)
                    {
                        if (CurrentSeconds > delayTask.FinishSeconds)
                        {
                            delayTask.State = DelayTaskState.Finish;
                            delayTask.OnFinish.Invoke();
                            delayTask.OnFinish = null;
                            mDelayTasks.Remove(currentNode); // 删除节点
                        }
                    }

                    currentNode = nextNode;
                }
            }
        }
        
        public void AddDelayTask(float seconds, Action onFinish)
        {
            var delayTask = new DelayTask()
            {
                Seconds = seconds,
                OnFinish = onFinish,
                State = DelayTaskState.NotStart,
            };

            mDelayTasks.AddLast(new LinkedListNode<DelayTask>(delayTask));
        }
    }
}

2、Query查询类

// 查询代码
var gunConfigModel = this.GetModel<IGunConfigModel>();
var gunConfigItem = gunConfigModel.GetItemByName(mGunSystem.CurrentGun.Name.Value);
mMaxBulletCount = gunConfigItem.BulletMaxCount;

上面的查询显得很臃肿

可以这样:

 mGunSystem = this.GetSystem<IGunSystem>();

// 查询代码
mMaxBulletCount = new MaxBulletCountQuery(mGunSystem.CurrentGun.Name.Value).Do(); // -+

做法就是:写一个查询类

using FrameworkDesign;

namespace ShootingEditor2D
{
    public class MaxBulletCountQuery : IBelongToArchitecture,ICanGetModel
    {
        private readonly string mGunName;

        public MaxBulletCountQuery(string gunName)
        {
            mGunName = gunName;
        }

        public int Do()
        {
            var gunConfigModel = this.GetModel<IGunConfigModel>();
            var gunConfigItem = gunConfigModel.GetItemByName(mGunName);
            return gunConfigItem.BulletMaxCount;
        }

        public IArchitecture GetArchitecture()
        {
            return ShootingEditor2D.Interface;
        }
    }
}

通过一些修改可以直接通过架构Arch来发送查询,做到这样(代码略)

mGunSystem = this.GetSystem<IGunSystem>();

// 查询代码
mMaxBulletCount = this.SendQuery(newMaxBulletCountQuery(mGunSystem.CurrentGun.Name.Value)); // -+

3.凉鞋的话

(GamePix 独立游戏学院 - 让独立游戏不再难做 - Powered By EduSoho)欢迎来这里购买决定版的QFRAMEWORK课程。

此文为 决定版群里的聊天记录。

说一下,第一季的整体流程。

课程的最开始,是没有用任何架构就做一个《点点点》这样的项目,做的方式就是用拖拽加一点代码的方式。

但是这种方式有一个问题,就是对象和对象之间的相互访问特别乱,没有规则,也没有限制,这样下去当项目有一定规模了就会变得非常乱。于是就引入了一个规则,就是只有自顶向下的时候可以直接访问对象或者调用对象的方法。然后自底向上的时候使用事件或者委托。而在讲这个规则之前还介绍了对象之间的三种交互方式:方法调用、委托、事件。

然后自底向上和自顶向再加上对象之间的三种交互方式这个构成了一个大的前提,后边的比如层级、业务模块等只要有高低之分的我们就都用这套规则去约束了。

再往下就介绍了一个简单的模块化,介绍了一个单例的模块化。我们在做设计的时候经常听到一个原则,就是高内聚松耦合,意高内聚意思是相同的代码放在一个地方去管理,这个是高内聚,低耦合就是对象之间的引用不要太多,最好就是单向引用或者没有引用,或者是有一定的规则去约束如何互相访问。

再往下就引入了一个概念,就是 Model,Model 是因为什么引入的呢?是因为就是有一些数据,它需要在多个地方去共享,比如角色的攻击力,需要在 UI 界面上显示,或者计算一个伤害的时候需要使用,总之需要在多个地方去使用它,而这种数据就是需要共享的数据,甚至需要把攻击力存储起来,而存储也是一种 共享方式,比如上次游戏关闭到了,现在打开游戏之后角色的攻击力不能变成初始攻击力了,所以数据的存储也是一种共享方式。而这些需要存储的数据,就需要放到 Model 里管理起来。而 Model 在决定版架构的引入就是因为有了需要共享的数据才引入的。

引入完 Model 之后就要考虑一个问题,就是其他的地方怎么跟这个 Model 进行交互,然后交互的部分,一般的方式就是用类似 MVC 的方式,然后其中 MVC 中的 Controller ,它所管理的逻辑分成了交互逻辑和表现逻辑。

大家都说 MVC 中的 Controller 代码容易臃肿起来,那么罪魁祸首就是交互逻辑,只要是有数据操作或者变更游戏数据状态的逻辑都是交互逻辑,而这部分逻辑是非常多的,要想解决 Controller 代码臃肿的问题,一般的共识就是引入命令模式,也就是 Command,让 Command 去分担 Controller 的交互逻辑,Controller 仅仅只是调用相应的 Command 即可。

好多的框架或者方案都是用 Command 去分担交互逻辑的,所以这里就不赘述笔者为啥用 Command 了。

引入了 Command 之后,Controller 就变成了比较薄的一层了,而 Command 并不适合负责所有的交互逻辑,比如有的交互逻辑最好还是统一放在一个对象里,比如分数统计、成就检测、任务检测等,如果分数统计这种逻辑分散在各种 Command 里,会非常不好管理,而分数统计实际上是一种规则类的逻辑,比如打一个敌人得多少分等等,最好是统一放在一个对象里管理,于是就引入了 System 层,System 层就是管理需要统一管理的交互逻辑而引入的,比如成就系统、任务系统等,这些系统一般会写很多死代码,那么这些死代码分散到各个 Command 里,想想都觉得恐怖,所以最好要弄脏就弄脏一个对象就是系统对象,这也是高内聚的一种体现。

到这里架构的一些核心概念就有了雏形了,像事件机制、BindableProperty 等都是一些通用的工具。

再接着架构雏形有了之后,就开始不断打磨这套架构的实现,这部分的内容就是一些 C# 的高级使用方法,用各种技巧达成设计目的,就不多说了。

总之架构中的每一个概念的引入都是为了解决特定的架构问题的,并不是为了做成架构而引入的,然后只要不断地去解决这些架构问题,就会慢慢迭代出来一个比较成型的框架/架构。

最后笔者简单再说一点,就是第一季的内容就是迭代这套架构,在迭代过程中不仅仅只有代码实现的部分,更重要的还是引入这些概念解决哪些问题,所以在学习课程的时候要重点放在概念解决哪些问题上,只要这块了解了,就会对各个概念的使用不会出现问题。

到了第二季 对一些架构本身的问题做了一些改进,比如 BindableProperty 去掉 IEquatable 接口,因为没必要,然后实现了完整的 CQRS 机制,也就是引入了 Query,有了 Query 之后实现充血模型不再是难事。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/123845.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

C++常用格式化输出转换

在C语言中可以用printf以一定的格式打印字符&#xff0c;C当然也可以。 输入输出及命名空间还不太了解的小伙伴可以看一看C入门讲解第一篇。  在C中&#xff0c;可以用流操作符&#xff08;stream manipulators&#xff09;控制数据的输出格式&#xff0c;这些流操作符定义在2…

基于SSM的建筑装修图纸管理平台

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;采用JSP技术开发 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#x…

Flink—— Data Source 介绍

Data Source 简介 Flink 做为一款流式计算框架&#xff0c;它可用来做批处理&#xff0c;即处理静态的数据集、历史的数据集&#xff1b;也可以用来做流处理&#xff0c;即实时的处理些实时数据流&#xff0c;实时的产生数据流结果&#xff0c;只要数据源源不断的过来&#xff…

福州湾107㎡三室两厅两卫,温柔如风的奶油原木风,自由浪漫的灵魂。福州中宅装饰,福州装修

今天要分享的是一套面积107平米的奶油原木风三室两厅的案例。设计师于业主诉求中抽丝剥茧&#xff0c;汲取灵感&#xff0c;以大热的现代风格为主&#xff0c;暖色为主基调&#xff0c;配合原木肌理和巧思的质感细节装饰&#xff0c;最终打造出一种自由与惬意的空间。 01丨业 主…

React路由与导航

目录 前言&#xff1a; 什么是React路由&#xff1f; 导航和页面切换 路由参数和动态路由 路由守卫和权限控制 总结 前言&#xff1a; React是一个流行的JavaScript库&#xff0c;用于构建用户界面。在使用React开发Web应用程序时&#xff0c;路由和导航是必不可少的功能…

大语言模型研究进展综述

1、历史 自20世纪50年代图灵测试被提出以来&#xff0c;研究人员一直在探索和开发能够理解并掌握语言的人工智能技术。 作为重要的研究方向之一&#xff0c;语言模型得到了学术界的广泛研究&#xff0c;从早期的统计语言模型和神经语言模型开始&#xff0c;发展到基于Transform…

1、Sentinel基本应用限流规则(1)

Sentinel基本应用&限流规则 1.1 概述与作用 随着微服务的流行&#xff0c;服务和服务之间的稳定性变得越来越重要。缓存、降级和限流是保护微服务系统运行稳定性的三大利器。 缓存&#xff1a;提升系统访问速度和增大系统能处理的容量 降级&#xff1a;当服务出问题或者影…

osgEarth之添加shp

目录 效果 代码 代码分析 加载模式 效果 代码 #include "stdafx.h" #include <osg/Notify> #include <osgGA/StateSetManipulator> #include <osgViewer/Viewer> #include <osgViewer/ViewerEventHandlers>#include <osgEarth/MapNo…

IP-guard WebServer 远程命令执行漏洞

IP-guard WebServer 远程命令执行漏洞 免责声明漏洞描述漏洞影响漏洞危害网络测绘Fofa: app="ip-guard"漏洞复现1. 构造poc2. 访问文件3. 执行命令免责声明 仅用于技术交流,目的是向相关安全人员展示漏洞利用方式,以便更好地提高网络安全意识和技术水平。 任何人不得…

高速信号PCB布局怎么布?(电子硬件)

对于高速信号&#xff0c;pcb的设计要求会更多&#xff0c;因为高速信号很容易收到其他外在因素的干扰&#xff0c;导致实际设计出来的东西和原本预期的效果相差很多。 所以在高速信号pcb设计中&#xff0c;需要提前考虑好整体的布局布线&#xff0c;良好的布局可以很好的决定布…

AI:67-基于深度学习的脱机手写汉字识别

🚀 本文选自专栏:AI领域专栏 从基础到实践,深入了解算法、案例和最新趋势。无论你是初学者还是经验丰富的数据科学家,通过案例和项目实践,掌握核心概念和实用技能。每篇案例都包含代码实例,详细讲解供大家学习。 📌📌📌在这个漫长的过程,中途遇到了不少问题,但是…

Django(二、静态文件的配置、链接数据库MySQL)

文章目录 一、静态文件及相关配置1.以登录功能为例2.静态文件3.资源访问4.静态文件资源访问如何解决&#xff1f; 二、静态文件相关配置1. 如何配置静态文件配置&#xff1f;2.接口前缀3. 接口前缀动态匹配4. form表单请求方法补充form表单要注意的点 三、request对象方法reque…

阿里云 :推出通义大模型编码助手产品【通义灵码】

本心、输入输出、结果 文章目录 阿里云 &#xff1a;推出通义大模型编码助手产品【通义灵码】前言通义灵码简介主要功能主要功能点 支持的语言和 IDEjetbrains IDEA 安装计费相关弘扬爱国精神 阿里云 &#xff1a;推出通义大模型编码助手产品【通义灵码】 编辑&#xff1a;简简…

SOLIDWORKS --电磁仿真篇

什么是 SIMULIA? 基于3DEXPERIENCE平台的品牌 多学科多领域的协同仿真与分析优化 三大核心仿真领域 结构仿真 流体仿真 SIMULIA电磁仿真是什么? 完备的求解技术&#xff0c;支持从静场、低频到高频、光波的电磁仿真&#xff0c;支持全波仿真、混合仿真、多物理场仿真和场路…

任务管理器的正确使用教程

快捷键 Ctrlshiftesc&#xff1a;进入任务管理器 我以Win11举例 如何给XX排序 给XX排序&#xff0c;点击空白处可以选择某项降序排列&#xff08;可以找到最占用某项资料的程序&#xff09;&#xff0c;再点击空白处可以选择某项升序排列 文件正在使用&#xff0c;如何解决 …

台式电脑怎么无损备份迁移系统到新硬盘(使用傲梅,免费的就可以)

文章目录 前言一、想要将源硬盘上的系统原封不动地迁移到新硬盘上二、准备工作2.具体步骤 总结 前言 半路接手公司一台台式电脑&#xff0c;C盘&#xff08;120g&#xff09;爆红&#xff0c;仅剩几个G&#xff0c;优化了几次&#xff0c;无果后。准备换一个大一点的增到500g。…

Python实现从Labelme数据集中挑选出含有指定类别的数据集

Python实现从Labelme数据集中挑选出含有指定类别的数据集 前言前提条件相关介绍实验环境Labelme数据集中挑选出含有指定类别的数据集代码实现输出结果 前言 由于本人水平有限&#xff0c;难免出现错漏&#xff0c;敬请批评改正。更多精彩内容&#xff0c;可点击进入Python日常小…

【STM32 开发】| INA219采集电压、电流值

目录 前言1 原理图2 IIC地址说明3 寄存器地址说明4 开始工作前配置5 程序代码1&#xff09;驱动程序2&#xff09;头文件3) 测试代码 前言 INA219 是一款具备 I2C 或 SMBUS 兼容接口的分流器和功率监测计。该器件监测分流器电压降和总线电源电压&#xff0c;转换次数和滤波选项…

算法打卡01——求两数之和

题目&#xff1a; 给定一个整数数组 nums 和一个整数目标值 target&#xff0c;请你在该数组中找出 和为目标值 target 的那 两个 整数&#xff0c;并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是&#xff0c;数组中同一个元素在答案里不能重复出现。 你…

Python进行数据可视化,探索和发现数据中的模式和趋势。

文章目录 前言第一步&#xff1a;导入必要的库第二步&#xff1a;加载数据第三步&#xff1a;创建基本图表第四步&#xff1a;添加更多细节第五步&#xff1a;使用Seaborn库创建更复杂的图表关于Python技术储备一、Python所有方向的学习路线二、Python基础学习视频三、精品Pyth…
最新文章