数据结构第12节 有向图

有向图(Directed Graph 或 Digraph)是一种图数据结构,其中的边具有方向性。这意味着在一个有向图中,边可以被视为箭头,箭头从一个顶点指向另一个顶点,表示从起点到终点的单向关系。有向图的这种特性使得它在许多现实问题的建模中非常有用,例如网络流分析、计算机网络、基因调控网络、网页链接结构等。

有向图的基本概念:

  1. 顶点(Vertex):有向图中的基本单元,可以表示实体或状态。
  2. 边(Edge)或弧(Arc):连接两个顶点的有向线段,表示从一个顶点到另一个顶点的关系。边由一对顶点组成,通常写作 <u, v>(u, v),其中 u 是边的起点(尾部)而 v 是终点(头部)。
  3. 邻接:如果存在一条从顶点 u 指向顶点 v 的边,则称 vu 的邻接顶点,同时 uv 的前驱顶点。
  4. 出度(Out-degree):一个顶点的出度是所有以该顶点为起点的边的数量。
  5. 入度(In-degree):一个顶点的入度是所有以该顶点为终点的边的数量。
  6. 路径:在有向图中,从顶点 u 到顶点 v 的路径是由一系列顶点组成的序列 u, v1, v2, …, v,其中每对连续顶点之间都存在一条指向序列前进方向的边。
  7. 环(Cycle):如果存在一条路径从顶点 u 开始,经过一系列顶点后又回到顶点 u,则称有向图中存在环。
  8. 强连通图:如果一个有向图中任意两个顶点都可以相互到达,则称这个有向图为强连通的。
  9. 有向无环图(DAG):如果一个有向图中不存在环,则称这个有向图为有向无环图。

有向图的表示:

  1. 邻接矩阵:一个二维数组,其中 adj[u][v] 表示是否存在从顶点 u 到顶点 v 的边。对于有向图,邻接矩阵通常不是对称的。
  2. 邻接表:对于每个顶点,邻接表是一个链表或数组,其中包含所有与该顶点直接相连的顶点。邻接表对于稀疏图(边的数量远小于顶点数量的平方)更节省空间。

有向图的应用算法:

  1. 拓扑排序:在有向无环图(DAG)中,对顶点进行排序,使得对于每条边 (u, v),顶点 u 在排序中出现在顶点 v 之前。
  2. 最短路径算法:例如 Dijkstra 算法和 Bellman-Ford 算法,用于寻找图中两点间最短路径。
  3. 强连通分量算法:例如 Kosaraju’s 算法和 Tarjan’s 算法,用于识别有向图中的强连通分量。
  4. 流网络算法:例如 Ford-Fulkerson 算法,用于求解网络的最大流问题。

有向图在计算机科学和其他领域中有广泛的应用,掌握其基本概念和相关算法对于解决实际问题是至关重要的。

有向图在游戏开发中扮演着重要的角色,特别是在涉及路径寻找、任务规划、NPC行为、游戏地图生成等方面。有向图是由顶点(节点)和边组成的数据结构,其中边是有方向的,这意味着从一个顶点到另一个顶点的路径可能与反方向的路径不同。

在Java中,我们可以使用邻接表或者邻接矩阵的方式来表示有向图。下面我将使用邻接表的方式,结合一个简单的游戏场景来讲解有向图的应用。

游戏场景描述

想象一下,你正在开发一个角色扮演游戏,游戏中有一个由村庄、森林、山脉、城堡等组成的大陆。玩家可以从村庄出发,探索这个世界,完成各种任务。我们的目标是使用有向图来表示游戏世界中的各个地点以及它们之间的连接关系。

Java实现

import java.util.*;

public class GameWorld {
    private Map<String, List<String>> graph;

    public GameWorld() {
        graph = new HashMap<>();
    }

    // 添加地点
    public void addLocation(String location) {
        graph.put(location, new ArrayList<>());
    }

    // 添加边,即两个地点之间的连接
    public void addConnection(String from, String to) {
        List<String> connections = graph.get(from);
        if (!connections.contains(to)) {
            connections.add(to);
        }
    }

    // 获取地点的所有可前往的地点
    public List<String> getConnections(String location) {
        return graph.get(location);
    }

    // 深度优先遍历示例,可以用于探索游戏世界
    public void dfs(String start) {
        Set<String> visited = new HashSet<>();
        dfsHelper(start, visited);
    }

    private void dfsHelper(String current, Set<String> visited) {
        System.out.println("Visited " + current);
        visited.add(current);

        for (String neighbor : graph.get(current)) {
            if (!visited.contains(neighbor)) {
                dfsHelper(neighbor, visited);
            }
        }
    }

    // 测试代码
    public static void main(String[] args) {
        GameWorld world = new GameWorld();
        world.addLocation("Village");
        world.addLocation("Forest");
        world.addLocation("Mountain");
        world.addLocation("Castle");

        world.addConnection("Village", "Forest");
        world.addConnection("Forest", "Mountain");
        world.addConnection("Mountain", "Castle");
        world.addConnection("Castle", "Village");

        world.dfs("Village");
    }
}

游戏应用实例

在这个游戏中,我们创建了一个有向图表示游戏世界。我们首先添加了四个地点:“Village”、“Forest”、“Mountain”和“Castle”。然后,我们添加了连接,表示从一个地点到另一个地点的路径。最后,我们使用深度优先搜索算法来遍历整个游戏世界,模拟玩家的探索过程。

通过这种方式,我们可以在游戏中实现复杂的路径寻找和任务规划。例如,我们可以使用图算法来确定从一个地点到另一个地点的最短路径,或者规划一系列任务的最优顺序。有向图为我们提供了一种强大的工具,可以用来表示和处理游戏世界中的复杂关系。

为了进一步扩展游戏并深入利用有向图的概念,我们可以添加更多的功能,比如:

  1. 双向边:允许玩家从一个地点往返另一个地点。
  2. 边的权重:代表移动到下一个地点所需的时间或消耗的能量。
  3. 动态变化的图:游戏世界中的某些路径可能因为天气、时间或其他因素而暂时不可用。
  4. 任务系统:基于图的连通性,设计任务流程和奖励机制。

接下来,我们将通过更新之前的代码来实现这些功能。

import java.util.*;

public class GameWorld {
    private Map<String, List<Edge>> graph;
    
    public GameWorld() {
        graph = new HashMap<>();
    }
    
    public void addLocation(String location) {
        graph.put(location, new ArrayList<>());
    }
    
    public void addConnection(String from, String to, int weight) {
        Edge edge = new Edge(to, weight);
        List<Edge> connections = graph.get(from);
        if (!connections.contains(edge)) {
            connections.add(edge);
        }
    }
    
    public List<Edge> getConnections(String location) {
        return graph.get(location);
    }
    
    public void dfs(String start) {
        Set<String> visited = new HashSet<>();
        dfsHelper(start, visited);
    }
    
    private void dfsHelper(String current, Set<String> visited) {
        System.out.println("Visited " + current);
        visited.add(current);
        
        for (Edge edge : graph.get(current)) {
            if (!visited.contains(edge.to)) {
                dfsHelper(edge.to, visited);
            }
        }
    }
    
    // 新增方法:获取到达目的地的总权重
    public int getTotalWeight(String start, String end) {
        return getTotalWeightHelper(start, end, 0, new HashSet<>());
    }
    
    private int getTotalWeightHelper(String current, String end, int weight, Set<String> visited) {
        if (current.equals(end)) {
            return weight;
        }
        visited.add(current);
        int minWeight = Integer.MAX_VALUE;
        for (Edge edge : graph.get(current)) {
            if (!visited.contains(edge.to)) {
                int newWeight = getTotalWeightHelper(edge.to, end, weight + edge.weight, visited);
                if (newWeight != Integer.MAX_VALUE) {
                    minWeight = Math.min(minWeight, newWeight);
                }
            }
        }
        visited.remove(current);
        return minWeight;
    }
    
    // 边类
    private static class Edge {
        String to;
        int weight;
        
        Edge(String to, int weight) {
            this.to = to;
            this.weight = weight;
        }
        
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Edge edge = (Edge) o;
            return weight == edge.weight && Objects.equals(to, edge.to);
        }
        
        @Override
        public int hashCode() {
            return Objects.hash(to, weight);
        }
    }
    
    // 测试代码
    public static void main(String[] args) {
        GameWorld world = new GameWorld();
        world.addLocation("Village");
        world.addLocation("Forest");
        world.addLocation("Mountain");
        world.addLocation("Castle");
        world.addLocation("Lake");
        
        world.addConnection("Village", "Forest", 2);
        world.addConnection("Forest", "Mountain", 3);
        world.addConnection("Mountain", "Castle", 4);
        world.addConnection("Castle", "Village", 5);
        world.addConnection("Village", "Lake", 1);
        
        world.dfs("Village");
        System.out.println("Total Weight from Village to Castle: " + world.getTotalWeight("Village", "Castle"));
    }
}

扩展说明

在这个扩展版本中,我们增加了Edge类来表示带权重的边,这允许我们计算从一个地点到另一个地点的总消耗。我们还添加了一个getTotalWeight方法,它使用递归深度优先搜索来找到从起点到终点的最短路径,并返回这条路径上的总权重。

通过这种方式,我们可以为游戏增加更多真实感和策略性,例如,玩家需要权衡时间成本和资源消耗,选择最佳的旅行路线。此外,我们还可以在此基础上添加更多复杂的功能,如动态障碍物、动态边权重(例如,随天气变化的路径难度),以及更高级的任务和奖励系统。


这种设计不仅增强了游戏的可玩性和沉浸感,同时也展示了有向图在游戏开发中的强大应用潜力。通过不断迭代和改进,我们能够构建出更加丰富和多变的游戏世界。

为了进一步扩展这个游戏,我们可以考虑引入更复杂的元素,如角色状态、动态事件、NPC交互和物品系统。以下是针对这些新增功能的代码实现:

import java.util.*;

public class GameWorld {
    private Map<String, List<Edge>> graph;
    private Map<String, Location> locations;
    private Player player;

    public GameWorld() {
        graph = new HashMap<>();
        locations = new HashMap<>();
        player = new Player();
    }

    public void addLocation(String name, String description) {
        Location location = new Location(name, description);
        locations.put(name, location);
        graph.put(name, new ArrayList<>());
    }

    public void addConnection(String from, String to, int distance) {
        Edge edge = new Edge(to, distance);
        List<Edge> connections = graph.get(from);
        if (!connections.contains(edge)) {
            connections.add(edge);
        }
    }

    public List<Edge> getConnections(String location) {
        return graph.get(location);
    }

    public void movePlayer(String destination) {
        player.setCurrentLocation(destination);
    }

    public Location getPlayerLocation() {
        return player.getCurrentLocation();
    }

    public void interactWithNPC(String npcName) {
        Location currentLocation = player.getCurrentLocation();
        NPC npc = currentLocation.getNPC(npcName);
        if (npc != null) {
            npc.interact(player);
        } else {
            System.out.println("No such NPC in the current location.");
        }
    }

    public void addItemToInventory(String itemName) {
        Item item = new Item(itemName);
        player.addItemToInventory(item);
    }

    public void removeItemFromInventory(String itemName) {
        player.removeItemFromInventory(itemName);
    }

    public void printInventory() {
        player.printInventory();
    }

    public static void main(String[] args) {
        GameWorld world = new GameWorld();
        world.addLocation("Village", "A small village surrounded by dense forests.");
        world.addLocation("Forest", "A dark and mysterious forest with hidden paths.");
        world.addLocation("Mountain", "A steep mountain with breathtaking views.");
        world.addLocation("Castle", "An ancient castle with a rich history.");

        world.addConnection("Village", "Forest", 2);
        world.addConnection("Forest", "Mountain", 3);
        world.addConnection("Mountain", "Castle", 4);
        world.addConnection("Castle", "Village", 5);

        world.player.setCurrentLocation("Village");
        world.addItemToInventory("Map");
        world.addItemToInventory("Compass");

        world.movePlayer("Forest");
        world.interactWithNPC("Old Hermit");
        world.movePlayer("Mountain");
        world.interactWithNPC("Mountain Guide");
        world.movePlayer("Castle");
        world.interactWithNPC("King");

        world.printInventory();
    }
}

class Player {
    private Location currentLocation;
    private List<Item> inventory;

    public Player() {
        inventory = new ArrayList<>();
    }

    public void setCurrentLocation(String locationName) {
        currentLocation = GameWorld.this.locations.get(locationName);
    }

    public Location getCurrentLocation() {
        return currentLocation;
    }

    public void addItemToInventory(Item item) {
        inventory.add(item);
    }

    public void removeItemFromInventory(String itemName) {
        inventory.removeIf(item -> item.getName().equals(itemName));
    }

    public void printInventory() {
        System.out.println("Inventory:");
        for (Item item : inventory) {
            System.out.println("- " + item.getName());
        }
    }
}

class Location {
    private String name;
    private String description;
    private List<NPC> npcs;

    public Location(String name, String description) {
        this.name = name;
        this.description = description;
        npcs = new ArrayList<>();
    }

    public void addNPC(NPC npc) {
        npcs.add(npc);
    }

    public NPC getNPC(String name) {
        for (NPC npc : npcs) {
            if (npc.getName().equals(name)) {
                return npc;
            }
        }
        return null;
    }
}

class NPC {
    private String name;
    private String greeting;

    public NPC(String name, String greeting) {
        this.name = name;
        this.greeting = greeting;
    }

    public void interact(Player player) {
        System.out.println(greeting);
        // Additional interaction logic can be added here.
    }

    public String getName() {
        return name;
    }
}

class Item {
    private String name;

    public Item(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

class Edge {
    private String to;
    private int distance;

    public Edge(String to, int distance) {
        this.to = to;
        this.distance = distance;
    }

    public String getTo() {
        return to;
    }

    public int getDistance() {
        return distance;
    }
}

扩展功能说明:

  1. 角色状态:我们引入了Player类,用于管理玩家的状态,如当前位置和背包物品。
  2. 动态事件:虽然在这个简单示例中没有具体实现,但我们可以通过在NPC类中添加更多交互逻辑,以及在Location类中添加随机事件来实现动态事件。
  3. NPC交互:我们添加了NPC类,玩家可以与之互动。目前的交互仅限于打印问候语,但可以进一步扩展,如交易、接受任务等。
  4. 物品系统Item类用于表示玩家可以收集的物品。Player类中的inventory属性用于存储这些物品。

通过这些扩展,游戏变得更加丰富和有趣。玩家可以在游戏世界中探索、与NPC互动、收集物品,并根据自己的选择影响游戏进程。这不仅提高了游戏的可玩性,也为开发者提供了更多创造性的空间,以构建更加复杂和引人入胜的游戏体验。

为了进一步扩展游戏,我们可以增加一些更复杂的功能,如任务系统、战斗机制、技能树和角色成长。以下是在现有游戏框架基础上的扩展代码:

import java.util.*;

public class GameWorld {
    private Map<String, List<Edge>> graph;
    private Map<String, Location> locations;
    private Player player;

    public GameWorld() {
        graph = new HashMap<>();
        locations = new HashMap<>();
        player = new Player();
    }

    // ... 保留之前的方法 ...

    public void acceptQuest(Quest quest) {
        player.acceptQuest(quest);
    }

    public void completeQuest(Quest quest) {
        player.completeQuest(quest);
    }

    public void attackMonster(Monster monster) {
        player.attack(monster);
    }

    public void levelUp() {
        player.levelUp();
    }

    // ... 其他方法 ...

    public static void main(String[] args) {
        GameWorld world = new GameWorld();
        // ... 地图初始化代码 ...

        // 创建NPC并分配任务
        NPC oldHermit = new NPC("Old Hermit", "Greetings, young traveler!");
        Quest hermitQuest = new Quest("FindHerbs", "Collect 5 herbs", 10);
        oldHermit.setQuest(hermitQuest);
        world.locations.get("Forest").addNPC(oldHermit);

        // 创建怪物
        Monster wolf = new Monster("Wolf", 5, 2);
        world.locations.get("Forest").addMonster(wolf);

        // 主循环
        while (true) {
            Location currentLocation = world.getPlayerLocation();
            System.out.println("You are in " + currentLocation.getName() + ".");
            System.out.println(currentLocation.getDescription());

            // 处理NPC交互
            for (NPC npc : currentLocation.getNPCs()) {
                System.out.println("NPC: " + npc.getName());
                world.interactWithNPC(npc.getName());
            }

            // 处理怪物战斗
            for (Monster monster : currentLocation.getMonsters()) {
                System.out.println("Encountered a " + monster.getName() + "!");
                world.attackMonster(monster);
            }

            // 更新玩家状态
            world.player.update();

            // 休息和恢复
            System.out.println("Resting...");
            player.rest();

            // 接受和完成任务
            for (Quest quest : player.getQuests()) {
                if (quest.isCompleted()) {
                    System.out.println("Quest completed: " + quest.getName());
                    world.completeQuest(quest);
                }
            }

            // 级别提升
            if (player.canLevelUp()) {
                world.levelUp();
            }

            // 移动到下一个地点
            List<Edge> connections = world.getConnections(currentLocation.getName());
            if (!connections.isEmpty()) {
                Edge nextEdge = connections.get(new Random().nextInt(connections.size()));
                world.movePlayer(nextEdge.getTo());
            }
        }
    }
}

class Player {
    private Location currentLocation;
    private List<Item> inventory;
    private List<Quest> quests;
    private int level;
    private int experience;
    private int health;
    private int maxHealth;

    public Player() {
        inventory = new ArrayList<>();
        quests = new ArrayList<>();
        level = 1;
        experience = 0;
        health = maxHealth = 100;
    }

    // ... 保留之前的方法 ...

    public void acceptQuest(Quest quest) {
        quests.add(quest);
    }

    public void completeQuest(Quest quest) {
        quests.remove(quest);
        experience += quest.getExperienceReward();
    }

    public void attack(Monster monster) {
        // 攻击逻辑
        int damage = 10; // 假定固定伤害
        monster.takeDamage(damage);
    }

    public void levelUp() {
        level++;
        maxHealth += 10;
        health = maxHealth;
    }

    public boolean canLevelUp() {
        return experience >= level * 100;
    }

    public void rest() {
        health = maxHealth;
    }

    public void update() {
        // 更新玩家状态
    }

    // ... 其他方法 ...
}

// ... 其他类 ...

class Quest {
    private String name;
    private String description;
    private int experienceReward;

    public Quest(String name, String description, int experienceReward) {
        this.name = name;
        this.description = description;
        this.experienceReward = experienceReward;
    }

    public boolean isCompleted() {
        // 判断任务是否完成
        return false;
    }
}

class Monster {
    private String name;
    private int health;
    private int damage;

    public Monster(String name, int health, int damage) {
        this.name = name;
        this.health = health;
        this.damage = damage;
    }

    public void takeDamage(int damage) {
        this.health -= damage;
    }
}

// ... 其他类 ...

新增功能说明:

  1. 任务系统:我们引入了Quest类,NPC可以分配任务给玩家。在主循环中,玩家可以接受任务,并在完成后获得经验值奖励。
  2. 战斗机制Monster类表示游戏中的敌人,玩家可以攻击怪物。这里简化了战斗逻辑,但可以进一步扩展,如加入回合制战斗、技能释放等。
  3. 角色成长Player类中包含了级别、经验值、健康等属性,支持角色成长和升级。
  4. 主循环:游戏现在有了一个基本的主循环,处理玩家在不同地点之间的移动、与NPC的交互、战斗、任务完成和角色状态更新。

通过这些扩展,游戏变得更加复杂和吸引人。玩家可以享受探索、战斗、任务完成和角色成长的乐趣。当然,这只是一个基础框架,可以根据需要进一步完善和扩展,例如,增加更多的物品、技能、NPC对话、剧情分支等,以构建一个更加丰富多彩的游戏世界。

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

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

相关文章

torchtext安装后仍无法使用

Pytorch 、 torchtext和Python之间有严格的对应关系&#xff1a; 在安装前需要找到自己要安装的版本&#xff0c;如果直接在命令窗中以如下命令安装torchtext&#xff0c;会出现问题 &#xff1a; pip install torchtext 注意在这种安装方式&#xff0c;如果你的pytorch版本与…

在centos7上部署mysql8.0

1.安装MySQL的话会和MariaDB的文件冲突&#xff0c;所以需要先卸载掉MariaDB。查看是否安装mariadb rpm -qa | grep mariadb 2. 卸载mariadb rpm -e --nodeps 查看到的文件名 3.下载MySQL安装包 MySQL官网下载地址: MySQL :: Download MySQL Community Serverhttps://dev.mys…

【vue动态组件】VUE使用component :is 实现在多个组件间来回切换

VUE使用component :is 实现在多个组件间来回切换 component :is 动态父子组件传值 相关代码实现&#xff1a; <component:is"vuecomponent"></component>import componentA from xxx; import componentB from xxx; import componentC from xxx;switch(…

记一次mysql迁移Kingbase8

目录 一、下载Kingbase工具二、客户端安装三、数据库开发管理工具 KStudio3.1 主界面3.2 导出数据库建表语句DDL3.3 导出数据 四、数据迁移工具 KDTS4.1 启动KDTS4.2 新建源数据库4.3 新建目标数据库4.4 迁移任务管理 一、下载Kingbase工具 kingbase数据库服务&#xff08;内置…

Java启动虚拟机默认字符集编码

-Dfile.encodingUTF-8 java程序启动默认字符集编码参数 // 这里会创建一个Charset.defaultCharset().name()的流&#xff0c;在Windows命令行窗口启动&#xff0c;会出现字符编码为GBK的情况 // 导致乱码输入、输出都会有影响 // 解决办法流的读取指定编码new InputStreamRead…

kettle中调用restful接口时的SSL信任证书问题

1、找第三方获取SSL证书&#xff0c;&#xff08;本案例为自签名证书&#xff09; C:\Program Files\Java\jdk1.8.0_241\jre\lib\security>keytool -import -alias aliyun-maven -keystore cacerts -file E:\entSoftware\aliyun-maven.cer 输入密钥库口令: …………一堆证…

ABAP 发送正文含图片邮件

背景&#xff1a; 客户要求系统发送的邮件内容中含logo图片 解决&#xff1a; 参考outlook中带图片的邮件&#xff0c;有两种形式&#xff0c;一种为url链接&#xff0c;需要点击下载才展示图片&#xff0c;一种为直接显示&#xff1b;如果使用ABAP发送该类型的邮件&#xff0…

Educational Codeforces Round 167(Div.2) A~D

A.Catch the Coin&#xff08;思维&#xff09; 题意&#xff1a; Monocarp 参观了一家有街机柜的复古街机俱乐部。在那里&#xff0c;他对"抓硬币"游戏机产生了好奇。 游戏非常简单。屏幕上的坐标网格是这样的 X X X轴从左到右&#xff1b; Y Y Y轴从下往上&…

Java毕业设计 基于SSM vue新生报到系统小程序 微信小程序

Java毕业设计 基于SSM vue新生报到系统小程序 微信小程序 SSM 新生报到系统小程序 功能介绍 学生 登录 注册 忘记密码 首页 学校公告 录取信息 录取详情 师资力量 教师详情 收藏 评论 用户信息修改 宿舍安排 签到信息 在线缴费 教室分配 我的收藏管理 我要发贴 我的发贴 管理…

海外金融机构银行保险证券数字化转型营销销售数字化成功案例讲师培训师讲授开户销售营销客户AI人工智能创新思维

金融机构需要数字营销的主要原因 数字银行、直接存款和移动网络的兴起让客户无需前往当地分行即可轻松办理银行业务。这些举措不仅提升了用户体验&#xff0c;也迫使银行向数字化世界迈进。 金融服务公司需要在数字营销渠道上保持稳固的地位&#xff0c;以免落后于大型机构。…

罗剑锋的C++实战笔记学习(一):const、智能指针、lambda表达式

1、const 1&#xff09;、常量 const一般的用法就是修饰变量、引用、指针&#xff0c;修饰之后它们就变成了常量&#xff0c;需要注意的是const并未区分出编译期常量和运行期常量&#xff0c;并且const只保证了运行时不直接被修改 一般的情况&#xff0c;const放在左边&…

深度卷积神经网络 AlexNet

一、机器学习深度学习的发展 1、机器学习SVM方法 &#xff08;1&#xff09;20世纪90年代&#xff0c;基于统计学习理论的结果&#xff0c;开发了一种新型的学习算法——支持向量机&#xff08;SVM&#xff09;。这就产生了一类新的理论上优雅的学习机器&#xff0c;它们将SVM…

大厂面试官问我:MySQL宕机重启了,怎么知道哪些事务是需要回滚的哪些是需要提交的?【后端八股文九:Mysql事务八股文合集】

本文为【Mysql事务八股文合集】初版&#xff0c;后续还会进行优化更新&#xff0c;欢迎大家关注交流~ 大家第一眼看到这个标题&#xff0c;不知道心中是否有答案了&#xff1f;在面试当中&#xff0c;面试官经常对项目亮点进行深挖&#xff0c;来考察你对这个项目亮点的理解以及…

2024/7/6 英语每日一段

More than half of late-teens are specifically calling for more youth work that offers “fun”, with older teenagers particularly hankering for more jollity, according to a study carried out by the National Youth Agency. One in 10 said they have zero option…

vite+vue3整合less教程

1、安装依赖 pnpm install -D less less-loader2、定义全局css变量文件 src/assets/css/global.less :root {--public_background_font_Color: red;--publicHouver_background_Color: #fff;--header_background_Color: #fff;--menu_background: #fff; }3、引入less src/main.…

罗剑锋的C++实战笔记学习(二):容器、算法库、多线程

4、容器 1&#xff09;、容器的通用特性 所有容器都具有的一个基本特性&#xff1a;它保存元素采用的是值&#xff08;value&#xff09;语义&#xff0c;也就是说&#xff0c;容器里存储的是元素的拷贝、副本&#xff0c;而不是引用 容器操作元素的很大一块成本就是值的拷贝…

重大更新来袭!!《植物大战僵尸杂交版V2.1+修改器+融合版》

大家好&#xff01;每个软件更新总是令人兴奋不已。前段时间介绍的《植物大战僵尸》系列以其独特的策略玩法和丰富的植物角色&#xff0c;赢得了很多玩家的喜爱。而在今天&#xff0c;这款经典游戏全网最新版本——《植物大战僵尸&#xff1a;杂交版V2.1》正式推出&#xff0c;…

【Mindspore进阶】实战ResNet50图像分类

ResNet50图像分类 图像分类是最基础的计算机视觉应用&#xff0c;属于有监督学习类别&#xff0c;如给定一张图像(猫、狗、飞机、汽车等等)&#xff0c;判断图像所属的类别。本章将介绍使用ResNet50网络对CIFAR-10数据集进行分类。 ResNet网络介绍 ResNet50网络是2015年由微…

vue require引入静态文件报错

如果是通过向后端发送请求&#xff0c;动态的获取对应的文件数据流很容易做到文件的显示和加载。现在研究&#xff0c;一些不存放在后端而直接存放在vue前端项目中的静态媒体文件如何加载。 通常情况下&#xff0c;vue项目的图片jpg&#xff0c;png等都可以直接在/ass…

量化机器人:金融市场的智能助手

引言 想象一下&#xff0c;在繁忙的金融市场中&#xff0c;有一位不知疲倦、冷静客观的“超级交易员”&#xff0c;它能够迅速分析海量数据&#xff0c;精准捕捉交易机会&#xff0c;并自动完成买卖操作。这位“超级交易员”不是人类&#xff0c;而是我们今天要聊的主角——量…